bosko lekovic
/
EthToCom_11
nova proba
UdpToScom.cpp@12:cbfc10c15437, 2020-05-01 (annotated)
- Committer:
- bosko001
- Date:
- Fri May 01 23:15:28 2020 +0000
- Revision:
- 12:cbfc10c15437
- Parent:
- 10:15f7fea18a2f
- Child:
- 16:c4e0e8b4d8fc
popravljeno
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
bosko001 | 2:45b351b4fc2a | 1 | #include "mbed.h" |
bosko001 | 2:45b351b4fc2a | 2 | #include "clubbing.h" |
bosko001 | 2:45b351b4fc2a | 3 | #include "UdpToScom.h" |
bosko001 | 2:45b351b4fc2a | 4 | #include "EthernetSetup.h" |
bosko001 | 2:45b351b4fc2a | 5 | |
bosko001 | 2:45b351b4fc2a | 6 | |
bosko001 | 10:15f7fea18a2f | 7 | //struct S_EthernetAddress_Remote |
bosko001 | 2:45b351b4fc2a | 8 | /*{ |
bosko001 | 2:45b351b4fc2a | 9 | char ip[16]; |
bosko001 | 2:45b351b4fc2a | 10 | int port; |
bosko001 | 9:893843262a1f | 11 | }*/ //s_EthAddRemote = {"192.168.1.14", 13000 }, *ps_ear = &s_EthAddRemote, |
bosko001 | 10:15f7fea18a2f | 12 | // s_EthAddBroadcast = {"0.0.0.0", 13000 }, *ps_eab = &s_EthAddBroadcast; |
bosko001 | 2:45b351b4fc2a | 13 | |
bosko001 | 2:45b351b4fc2a | 14 | |
bosko001 | 2:45b351b4fc2a | 15 | /* globalni pointeri*/ |
bosko001 | 2:45b351b4fc2a | 16 | |
bosko001 | 2:45b351b4fc2a | 17 | |
bosko001 | 9:893843262a1f | 18 | extern EthernetInterface *gp_eth; |
bosko001 | 2:45b351b4fc2a | 19 | |
bosko001 | 2:45b351b4fc2a | 20 | |
bosko001 | 2:45b351b4fc2a | 21 | |
bosko001 | 2:45b351b4fc2a | 22 | /******************* Broadcast thread **********************/ |
bosko001 | 2:45b351b4fc2a | 23 | Thread udpBroadcast_thread; |
bosko001 | 2:45b351b4fc2a | 24 | void udpBroadcast_fun( void ) |
bosko001 | 2:45b351b4fc2a | 25 | { |
bosko001 | 2:45b351b4fc2a | 26 | while(true) |
bosko001 | 2:45b351b4fc2a | 27 | { |
bosko001 | 9:893843262a1f | 28 | // sendUdp( ps_eab, (char *)"test broadcast", 14); |
bosko001 | 2:45b351b4fc2a | 29 | wait(5); |
bosko001 | 2:45b351b4fc2a | 30 | } |
bosko001 | 2:45b351b4fc2a | 31 | } |
bosko001 | 2:45b351b4fc2a | 32 | |
bosko001 | 2:45b351b4fc2a | 33 | |
bosko001 | 2:45b351b4fc2a | 34 | |
bosko001 | 2:45b351b4fc2a | 35 | void inic_1(void) |
bosko001 | 2:45b351b4fc2a | 36 | { |
bosko001 | 2:45b351b4fc2a | 37 | |
bosko001 | 2:45b351b4fc2a | 38 | printf("\n\r -------- REINICIJALIZACIJA ------------- \n\r"); |
bosko001 | 2:45b351b4fc2a | 39 | |
bosko001 | 2:45b351b4fc2a | 40 | /* Gasenje UDP threada */ |
bosko001 | 9:893843262a1f | 41 | // if( gp_udpRxThread->get_state( ) && gp_udpRxThread->get_state( )<16 ) |
bosko001 | 9:893843262a1f | 42 | // gp_udpRxThread->flags_set( 1 ); |
bosko001 | 9:893843262a1f | 43 | // gp_udpRxThread->join( ); |
bosko001 | 9:893843262a1f | 44 | // if(gp_udpRxThread) {delete gp_udpRxThread; gp_udpRxThread = NULL;} |
bosko001 | 9:893843262a1f | 45 | // printf("udp thread zavrsio\n\r"); |
bosko001 | 2:45b351b4fc2a | 46 | |
bosko001 | 9:893843262a1f | 47 | udpRxThreadCancel( ); |
bosko001 | 9:893843262a1f | 48 | |
bosko001 | 2:45b351b4fc2a | 49 | /* gasenje serial com thread-a */ |
bosko001 | 9:893843262a1f | 50 | // int st = gp_scomRxThread->get_state(); |
bosko001 | 9:893843262a1f | 51 | // if( st && st<16 )gp_scomRxThread->flags_set(1); |
bosko001 | 9:893843262a1f | 52 | // gp_scomRxThread->join(); |
bosko001 | 9:893843262a1f | 53 | // printf("ScomRx Thread upravo zavrsio\n\r"); |
bosko001 | 9:893843262a1f | 54 | // if(gp_scomRxThread) { delete gp_scomRxThread; gp_scomRxThread = NULL;} |
bosko001 | 9:893843262a1f | 55 | scomRxThreadCancel( ); |
bosko001 | 2:45b351b4fc2a | 56 | |
bosko001 | 2:45b351b4fc2a | 57 | gp_eth->disconnect(); /* gasenje ethernta */ |
bosko001 | 2:45b351b4fc2a | 58 | |
bosko001 | 2:45b351b4fc2a | 59 | gp_eth = ethernet_setup( ); /*paljenje etherneta*/ |
bosko001 | 2:45b351b4fc2a | 60 | if(gp_eth == NULL) printf("ethernet greska\n\r"); |
bosko001 | 2:45b351b4fc2a | 61 | else printf("eth OK\n\r"); |
bosko001 | 2:45b351b4fc2a | 62 | |
bosko001 | 2:45b351b4fc2a | 63 | /* paljenje UDP thread-a */ |
bosko001 | 9:893843262a1f | 64 | // gp_udpRxThread = new Thread( udpRx_fun ); |
bosko001 | 9:893843262a1f | 65 | // udpRxThreadRiseUp( ); |
bosko001 | 2:45b351b4fc2a | 66 | |
bosko001 | 2:45b351b4fc2a | 67 | |
bosko001 | 9:893843262a1f | 68 | // /* paljenje serial com thread-a */ |
bosko001 | 9:893843262a1f | 69 | // gp_scomRxThread = new Thread(scomrx_fun); |
bosko001 | 9:893843262a1f | 70 | scomRxThreadRiseUp( ); |
bosko001 | 2:45b351b4fc2a | 71 | |
bosko001 | 2:45b351b4fc2a | 72 | |
bosko001 | 2:45b351b4fc2a | 73 | // |
bosko001 | 2:45b351b4fc2a | 74 | fflush(stdout); |
bosko001 | 2:45b351b4fc2a | 75 | |
bosko001 | 2:45b351b4fc2a | 76 | } |
bosko001 | 2:45b351b4fc2a | 77 | |
bosko001 | 2:45b351b4fc2a | 78 | void init_EthToScom( void ) |
bosko001 | 2:45b351b4fc2a | 79 | { |
bosko001 | 2:45b351b4fc2a | 80 | gp_eth = ethernet_setup( ); |
bosko001 | 2:45b351b4fc2a | 81 | |
bosko001 | 2:45b351b4fc2a | 82 | if(gp_eth == NULL) printf("ethernet greska"); |
bosko001 | 2:45b351b4fc2a | 83 | else printf("eth OK\n\r"); |
bosko001 | 2:45b351b4fc2a | 84 | |
bosko001 | 2:45b351b4fc2a | 85 | |
bosko001 | 9:893843262a1f | 86 | // if(gp_scomRxThread) delete gp_scomRxThread; |
bosko001 | 9:893843262a1f | 87 | // gp_scomRxThread = new Thread(scomrx_fun); |
bosko001 | 9:893843262a1f | 88 | scomRxThreadRiseUp( ); |
bosko001 | 2:45b351b4fc2a | 89 | |
bosko001 | 2:45b351b4fc2a | 90 | |
bosko001 | 2:45b351b4fc2a | 91 | /* |
bosko001 | 2:45b351b4fc2a | 92 | TCPSocket socket; |
bosko001 | 2:45b351b4fc2a | 93 | socket.open(ð); |
bosko001 | 2:45b351b4fc2a | 94 | socket.connect( |
bosko001 | 2:45b351b4fc2a | 95 | */ |
bosko001 | 2:45b351b4fc2a | 96 | |
bosko001 | 2:45b351b4fc2a | 97 | |
bosko001 | 9:893843262a1f | 98 | // gp_udpRxThread = new Thread( udpRx_fun ); |
bosko001 | 9:893843262a1f | 99 | udpRxThreadRiseUp( ); |
bosko001 | 2:45b351b4fc2a | 100 | |
bosko001 | 2:45b351b4fc2a | 101 | } |