bosko lekovic
/
EthToCom_11
nova proba
UdpToScom.cpp
- Committer:
- bosko001
- Date:
- 2020-05-06
- Revision:
- 17:74c41e3f10b8
- Parent:
- 16:c4e0e8b4d8fc
- Child:
- 18:5ee53205451a
File content as of revision 17:74c41e3f10b8:
#include "mbed.h" #include "clubbing.h" #include "UdpToScom.h" #include "EthernetSetup.h" //struct S_EthernetAddress_Remote /*{ char ip[16]; int port; }*/ //s_EthAddRemote = {"192.168.1.14", 13000 }, *ps_ear = &s_EthAddRemote, // s_EthAddBroadcast = {"0.0.0.0", 13000 }, *ps_eab = &s_EthAddBroadcast; /* globalni pointeri*/ extern EthernetInterface *gp_eth; /******************* Broadcast thread **********************/ Thread udpBroadcast_thread; void udpBroadcast_fun( void ) { while(true) { // sendUdp( ps_eab, (char *)"test broadcast", 14); wait(5); } } //extern void udpRxThreadCancel( void); void inic_1(void) { printf("\n\r -------- REINICIJALIZACIJA ------------- \n\r"); /* Gasenje UDP threada */ // if( gp_udpRxThread->get_state( ) && gp_udpRxThread->get_state( )<16 ) // gp_udpRxThread->flags_set( 1 ); // gp_udpRxThread->join( ); // if(gp_udpRxThread) {delete gp_udpRxThread; gp_udpRxThread = NULL;} // printf("udp thread zavrsio\n\r"); udpRxThreadsCancel( ); /* gasenje serial com thread-a */ // int st = gp_scomRxThread->get_state(); // if( st && st<16 )gp_scomRxThread->flags_set(1); // gp_scomRxThread->join(); // printf("ScomRx Thread upravo zavrsio\n\r"); // if(gp_scomRxThread) { delete gp_scomRxThread; gp_scomRxThread = NULL;} scomRxThreadCancel( ); gp_eth->disconnect(); /* gasenje ethernta */ gp_eth = ethernet_setup( ); /*paljenje etherneta*/ if(gp_eth == NULL) printf("ethernet greska\n\r"); else printf("eth OK\n\r"); /* paljenje UDP thread-a */ // gp_udpRxThread = new Thread( udpRx_fun ); // udpRxThreadRiseUp( ); // /* paljenje serial com thread-a */ // gp_scomRxThread = new Thread(scomrx_fun); scomRxThreadRiseUp( ); // fflush(stdout); } void init_EthToScom( void ) { gp_eth = ethernet_setup( ); if(gp_eth == NULL) printf("ethernet greska"); else printf("eth OK\n\r"); // if(gp_scomRxThread) delete gp_scomRxThread; // gp_scomRxThread = new Thread(scomrx_fun); scomRxThreadRiseUp( ); /* TCPSocket socket; socket.open(ð); socket.connect( */ // gp_udpRxThread = new Thread( udpRx_fun ); udpRxThreadsRiseUp( ); }