nova verzija tcp+udp->serial com

Committer:
bosko001
Date:
Wed May 06 00:42:53 2020 +0200
Revision:
17:74c41e3f10b8
Parent:
16:c4e0e8b4d8fc
Child:
18:5ee53205451a
verzija od 5.5.2020. zapoceo TCP client-e

Who changed what in which revision?

UserRevisionLine numberNew 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 17:74c41e3f10b8 33 //extern void udpRxThreadCancel( void);
bosko001 2:45b351b4fc2a 34
bosko001 2:45b351b4fc2a 35
bosko001 2:45b351b4fc2a 36 void inic_1(void)
bosko001 2:45b351b4fc2a 37 {
bosko001 2:45b351b4fc2a 38
bosko001 2:45b351b4fc2a 39 printf("\n\r -------- REINICIJALIZACIJA ------------- \n\r");
bosko001 2:45b351b4fc2a 40
bosko001 2:45b351b4fc2a 41 /* Gasenje UDP threada */
bosko001 9:893843262a1f 42 // if( gp_udpRxThread->get_state( ) && gp_udpRxThread->get_state( )<16 )
bosko001 9:893843262a1f 43 // gp_udpRxThread->flags_set( 1 );
bosko001 9:893843262a1f 44 // gp_udpRxThread->join( );
bosko001 9:893843262a1f 45 // if(gp_udpRxThread) {delete gp_udpRxThread; gp_udpRxThread = NULL;}
bosko001 9:893843262a1f 46 // printf("udp thread zavrsio\n\r");
bosko001 2:45b351b4fc2a 47
bosko001 17:74c41e3f10b8 48 udpRxThreadsCancel( );
bosko001 9:893843262a1f 49
bosko001 2:45b351b4fc2a 50 /* gasenje serial com thread-a */
bosko001 9:893843262a1f 51 // int st = gp_scomRxThread->get_state();
bosko001 9:893843262a1f 52 // if( st && st<16 )gp_scomRxThread->flags_set(1);
bosko001 9:893843262a1f 53 // gp_scomRxThread->join();
bosko001 9:893843262a1f 54 // printf("ScomRx Thread upravo zavrsio\n\r");
bosko001 9:893843262a1f 55 // if(gp_scomRxThread) { delete gp_scomRxThread; gp_scomRxThread = NULL;}
bosko001 9:893843262a1f 56 scomRxThreadCancel( );
bosko001 2:45b351b4fc2a 57
bosko001 2:45b351b4fc2a 58 gp_eth->disconnect(); /* gasenje ethernta */
bosko001 2:45b351b4fc2a 59
bosko001 2:45b351b4fc2a 60 gp_eth = ethernet_setup( ); /*paljenje etherneta*/
bosko001 2:45b351b4fc2a 61 if(gp_eth == NULL) printf("ethernet greska\n\r");
bosko001 2:45b351b4fc2a 62 else printf("eth OK\n\r");
bosko001 2:45b351b4fc2a 63
bosko001 2:45b351b4fc2a 64 /* paljenje UDP thread-a */
bosko001 9:893843262a1f 65 // gp_udpRxThread = new Thread( udpRx_fun );
bosko001 9:893843262a1f 66 // udpRxThreadRiseUp( );
bosko001 2:45b351b4fc2a 67
bosko001 2:45b351b4fc2a 68
bosko001 9:893843262a1f 69 // /* paljenje serial com thread-a */
bosko001 9:893843262a1f 70 // gp_scomRxThread = new Thread(scomrx_fun);
bosko001 9:893843262a1f 71 scomRxThreadRiseUp( );
bosko001 2:45b351b4fc2a 72
bosko001 2:45b351b4fc2a 73
bosko001 2:45b351b4fc2a 74 //
bosko001 2:45b351b4fc2a 75 fflush(stdout);
bosko001 2:45b351b4fc2a 76
bosko001 2:45b351b4fc2a 77 }
bosko001 2:45b351b4fc2a 78
bosko001 2:45b351b4fc2a 79 void init_EthToScom( void )
bosko001 2:45b351b4fc2a 80 {
bosko001 2:45b351b4fc2a 81 gp_eth = ethernet_setup( );
bosko001 2:45b351b4fc2a 82
bosko001 2:45b351b4fc2a 83 if(gp_eth == NULL) printf("ethernet greska");
bosko001 2:45b351b4fc2a 84 else printf("eth OK\n\r");
bosko001 2:45b351b4fc2a 85
bosko001 2:45b351b4fc2a 86
bosko001 9:893843262a1f 87 // if(gp_scomRxThread) delete gp_scomRxThread;
bosko001 9:893843262a1f 88 // gp_scomRxThread = new Thread(scomrx_fun);
bosko001 9:893843262a1f 89 scomRxThreadRiseUp( );
bosko001 2:45b351b4fc2a 90
bosko001 2:45b351b4fc2a 91
bosko001 2:45b351b4fc2a 92 /*
bosko001 2:45b351b4fc2a 93 TCPSocket socket;
bosko001 2:45b351b4fc2a 94 socket.open(&eth);
bosko001 2:45b351b4fc2a 95 socket.connect(
bosko001 2:45b351b4fc2a 96 */
bosko001 2:45b351b4fc2a 97
bosko001 2:45b351b4fc2a 98
bosko001 9:893843262a1f 99 // gp_udpRxThread = new Thread( udpRx_fun );
bosko001 17:74c41e3f10b8 100 udpRxThreadsRiseUp( );
bosko001 2:45b351b4fc2a 101
bosko001 2:45b351b4fc2a 102 }