bosko lekovic
/
EthToCom_11
nova proba
UdpToScom.cpp
- Committer:
- bosko001
- Date:
- 2020-05-01
- Revision:
- 12:cbfc10c15437
- Parent:
- 10:15f7fea18a2f
- Child:
- 16:c4e0e8b4d8fc
File content as of revision 12:cbfc10c15437:
#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); } } 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"); udpRxThreadCancel( ); /* 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 ); udpRxThreadRiseUp( ); }