bosko lekovic
/
EthToCom_11
nova proba
main.cpp
- Committer:
- bosko001
- Date:
- 2020-05-23
- Revision:
- 20:d8277082f4e3
- Parent:
- 19:7bdb1a10043f
- Child:
- 21:2232f5a34eb4
File content as of revision 20:d8277082f4e3:
#include "mbed.h" #include "clubbing.h" #include "EthernetSetup.h" #include "UdpToScom.h" #include "TcpClients.h" #include "TcpServerToFlash.h" #include "dxml.h" #include "doHTML.h" #include "dataFlash.h" #include "string.h" volatile PFV pfv = NULL; DigitalOut GLed(LED2,1); void pfv_fun( void ) { while(true) { if(pfv) {pfv(); pfv = NULL;} cleanTcpServerToFlashThread( ); } } Thread pfv_thread(pfv_fun, osPriorityNormal, 1000); void input_fun( void ) { while(true) { unsigned char uc; int fltip, kanal, fleg; uc = (unsigned char)getchar( ); printf( "\n\runesen karakter %c\n\r", uc); switch( uc ) { case 'h': { extern C_HTMLparse *gpc_html; auto c = gpc_html->getHTML_free( ); printf("\n\r%s\n\r", c); free(c); } break; case 'c': fltip = 1; break; case 'f': fltip = 2; break; case '0': case '1': case '2': case '3': if(fltip == 1) kanal = uc - '0'; else fleg = uc - '0'; break; case 'd': { // extern void tcpRxThreadCancel( int i, int flag); // tcpRxThreadCancel( kanal, fleg ); printf(" komanda za tred[%d] fleg=%d\n\r", kanal, fleg); } break; case 'P': case 'p': restart_TcpClients( ); break; case 'S': case 's': { //get_rxStatus( int i ) puts("TCP Clients Threads satatus:\n\r"); printf("\n\r TCP statusi T[0]=%d T[1]=%d T[2]=%d T[3]=%d \n\r", get_rxStatus(0), get_rxStatus(1), get_rxStatus(2), get_rxStatus(3)); printf(" TCP validy T[0]=%d T[1]=%d T[2]=%d T[3]=%d \n\r", get_rxValidy(0), get_rxValidy(1), get_rxValidy(2), get_rxValidy(3)); printf("status ethernet mreze %d\n\r", getEthernetStatus( )); } break; case 'T': case 't': { puts("TCP Clients Thread controll, thread number input:"); char no = getchar()-'0'; puts("\n\rTCP Clients Thread controll, thread flag input:"); char fl = getchar()-'0'; void restart_TcpClient( int noClient, int typeRestart ); restart_TcpClientConnection( no, fl & 7 ); printf("\n\rthread = %d, flag =%d\n\r", no, fl); } break; case 'R': printf("systemInit()\n\r"); SystemInit(); //goto __main; break; } } } Thread input_thread(input_fun, osPriorityNormal, 1000); C_HTMLparse *gpc_html; int main(void) { printf("\n\r\n\n---------- POCETAK ------------- \n\n\r"); init_FlashData( ); gpc_html = new C_HTMLparse; C_HTMLparse *p_temp_html = new C_HTMLparse; // PROVERA KONZISTENCIJE FLASH PODATAKA putFLASHintoHTML( p_temp_html ); if( test_FlashDataProbity( )) { printf( "MAIN: dobri Flash podaci\n\r"); putFLASHintoHTML( gpc_html ); } else { printf("MAIN: losi FLASH podaci\n\r"); putHTMLintoFLASH( gpc_html ); putFLASHintoHTML( gpc_html ); } delete p_temp_html; // showFlashData( ); // init_EthToScom( ); extern EthernetInterface *gp_eth; init_EthToScom( ); //tcpRxThreadsRiseUp( ); // gp_eth = ethernet_setup( ); inic_TcpServerToFlash( ); extern void test_HTML(void); // test_HTML( ); int i=0; while(true) { if(i++ >10 ) { i=0; GLed = !GLed;} wait(0.01); } // deinit_FlashData( ); } // //enum nsapi_error { // NSAPI_ERROR_OK = 0, /*!< no error */ // NSAPI_ERROR_WOULD_BLOCK = -3001, /*!< no data is not available but call is non-blocking */ // NSAPI_ERROR_UNSUPPORTED = -3002, /*!< unsupported functionality */ // NSAPI_ERROR_PARAMETER = -3003, /*!< invalid configuration */ // NSAPI_ERROR_NO_CONNECTION = -3004, /*!< not connected to a network */ // NSAPI_ERROR_NO_SOCKET = -3005, /*!< socket not available for use */ // NSAPI_ERROR_NO_ADDRESS = -3006, /*!< IP address is not known */ // NSAPI_ERROR_NO_MEMORY = -3007, /*!< memory resource not available */ // NSAPI_ERROR_NO_SSID = -3008, /*!< ssid not found */ // NSAPI_ERROR_DNS_FAILURE = -3009, /*!< DNS failed to complete successfully */ // NSAPI_ERROR_DHCP_FAILURE = -3010, /*!< DHCP failed to complete successfully */ // NSAPI_ERROR_AUTH_FAILURE = -3011, /*!< connection to access point failed */ // NSAPI_ERROR_DEVICE_ERROR = -3012, /*!< failure interfacing with the network processor */ // NSAPI_ERROR_IN_PROGRESS = -3013, /*!< operation (eg connect) in progress */ // NSAPI_ERROR_ALREADY = -3014, /*!< operation (eg connect) already in progress */ // NSAPI_ERROR_IS_CONNECTED = -3015, /*!< socket is already connected */ // NSAPI_ERROR_CONNECTION_LOST = -3016, /*!< connection lost */ // NSAPI_ERROR_CONNECTION_TIMEOUT = -3017, /*!< connection timed out */ //};