bosko lekovic
/
ETHtoCOM_10
nova verzija tcp+udp->serial com
Diff: UdpToScom.cpp
- Revision:
- 18:5ee53205451a
- Parent:
- 17:74c41e3f10b8
- Child:
- 19:7bdb1a10043f
--- a/UdpToScom.cpp Wed May 06 00:42:53 2020 +0200 +++ b/UdpToScom.cpp Sun May 17 17:16:03 2020 +0200 @@ -4,99 +4,27 @@ #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( ); +// gp_eth = ethernet_setup( ); - if(gp_eth == NULL) printf("ethernet greska"); - else printf("eth OK\n\r"); +// if(gp_eth == NULL) printf("ethernet greska"); +// else printf("eth OK\n\r"); + ethRiseUp( ); -// if(gp_scomRxThread) delete gp_scomRxThread; -// gp_scomRxThread = new Thread(scomrx_fun); + //ethRestart( ); + + scomRxThreadRiseUp( ); - - /* - TCPSocket socket; - socket.open(ð); - socket.connect( - */ - - -// gp_udpRxThread = new Thread( udpRx_fun ); - udpRxThreadsRiseUp( ); + // udpRxThreadsRiseUp( ); -} \ No newline at end of file +}