![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
Modularizando o src
Dependencies: EALib EthernetInterface_vz mbed-rtos mbed
Fork of header_main_colinas_V0-20-09-14 by
Diff: prompt.cpp
- Revision:
- 31:bb5fb28a77df
- Parent:
- 30:8dfb6d8de53d
- Child:
- 33:735fd60e96d8
--- a/prompt.cpp Thu Sep 25 14:37:02 2014 +0000 +++ b/prompt.cpp Thu Sep 25 19:34:46 2014 +0000 @@ -13,11 +13,17 @@ uint8_t debug_vector = 0; uint8_t debug_cb = 0; uint8_t debug_main = 0; +uint8_t debug_cks = 0; uint8_t pcks_s = 0; uint8_t pshowcb = 0; +uint8_t debug_cb_rx = 0; +uint8_t debug_cb_tx = 0; +uint8_t debug_eth_rx = 0; +uint8_t debug_eth_tx = 0; +uint8_t debug_file = 0; uint8_t test_debug = 1; -#define PVERSION 1 // Sempre atualizar a versao do prompt +#define PVERSION 1.1 // Sempre atualizar a versao do prompt #define DEBUGBUFSIZE 50 char debug_buf[DEBUGBUFSIZE]; @@ -128,12 +134,12 @@ fserext = fopen("/qspi/myext.txt", "r"); if ( fserext == NULL ){ fserext = fopen("/qspi/myext.txt", "w"); - fprintf( fserext, "%i\n\r" ,__MY_EXT__ ); //asterisk ext + fprintf( fserext, "%i" ,__MY_EXT__ ); //asterisk ext } fport = fopen("/qspi/mysipport.txt", "r"); if (fport == NULL){ fport = fopen("/qspi/mysipport.txt", "w"); - fprintf(fport, "%i\n\r",__MY_PORT__); //mysipport + fprintf(fport, "%i",__MY_PORT__); //mysipport } fsip = fopen("/qspi/serverip.txt", "r"); if (fsip == NULL){ @@ -145,25 +151,25 @@ fext = fopen("/qspi/peerext.txt", "r"); if ( fext == NULL ){ fext = fopen("/qspi/peerext.txt", "w"); - fprintf( fext, "%d\n\r",__PEER_EXT__ ); //asterisk ip + fprintf( fext, "%i",__PEER_EXT__ ); //asterisk ip } fsport = fopen("/qspi/serverport.txt", "r"); if (fsport == NULL){ fsport = fopen("/qspi/serverport.txt", "w"); - fprintf(fsport, "%i\n\r",__SERVER_PORT__ ); //asterisk port - pc.printf("\n\r Default configurations set! \n\r"); + fprintf(fsport, "%i",__SERVER_PORT__ ); //asterisk port } fmask = fopen("/qspi/mymask.txt", "r"); if (fmask == NULL){ fmask = fopen("/qspi/mymask.txt", "w"); - fprintf(fmask, "%s\n\r",__MY_MSK__); //mymask + fprintf(fmask, "%s",__MY_MSK__); //mymask } fgate = fopen("/qspi/mygateway.txt", "r"); if (fgate == NULL){ fgate = fopen("/qspi/mygate.txt", "w"); - fprintf(fgate, "%s\n\r",__MY_GTW__); //mygateway + fprintf(fgate, "%s",__MY_GTW__); //mygateway } + pc.printf("\n\r Default configurations set! \n\r"); } if (type == 'r' ){ // Just open for read @@ -189,16 +195,16 @@ //fprintf( fip, "%s\n\r", __MY_IP__ ); //myip fprintf( fip, "%s", __MY_IP__ ); //myip - fprintf( fport, "%d\n\r", __MY_PORT__ ); //mysipport - fprintf( fext, "%d\n\r", __MY_EXT__ ); //myext + fprintf( fport, "%i", __MY_PORT__ ); //mysipport + fprintf( fext, "%i", __MY_EXT__ ); //myext //fprintf( fsip, "%s\n\r", __SERVER_IP__ ); //asterisk ip fprintf( fsip, "%s", __SERVER_IP__ ); //asterisk ip - fprintf( fserext, "%d\n\r",__PEER_EXT__ ); //asterisk port - fprintf( fsport, "%d\n\r",__SERVER_PORT__ ); //asterisk port + fprintf( fserext, "%i",__PEER_EXT__ ); //asterisk port + fprintf( fsport, "%i",__SERVER_PORT__ ); //asterisk port - fprintf( fmask, "%s\n\r",__MY_MSK__ ); //mymask - fprintf( fgate, "%s\n\r", __MY_GTW__ ); //mygateway + fprintf( fmask, "%s",__MY_MSK__ ); //mymask + fprintf( fgate, "%i", __MY_GTW__ ); //mygateway files('c'); @@ -226,7 +232,6 @@ static Timer flood_timeout; if( flood_timeout.read() > 60 ){ - debug_msg(""); pflood = 0; flood_timeout.stop(); flood_timeout.reset(); @@ -245,6 +250,8 @@ if( bufptr > 0 ) debug_buf[ --bufptr ] = 0; //bufptr--; //pc.printf("."); + }else if( b == 0x09 ){ + // ignore tab }else{ debug_buf[bufptr] = b; //pc.printf("(%x)", (uint8_t)b ); @@ -293,7 +300,7 @@ if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "extset ", 7 )) { miss_match = false; fip = fopen("/qspi/myext.txt", "w"); - fprintf(fip, "%s\n\r" , ( debug_buf + 7) ); + fprintf(fip, "%s" , ( debug_buf + 7) ); fclose(fip); pc.printf("\n\r"); files('s'); @@ -396,16 +403,31 @@ } if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "debug ",6 )) { - if (xmemmatch( (uint8_t*)(debug_buf+6), (uint8_t*) "on",2 )) { + if( xmemmatch( (uint8_t*)(debug_buf+6), (uint8_t*) "on",2 )) { miss_match = false; pc.printf("\n\r\tDebug ON\n\r\t"); debug_alive = 1; } - if (xmemmatch( (uint8_t*)(debug_buf+6), (uint8_t*) "off",3 )) { + if( xmemmatch( (uint8_t*)(debug_buf+6), (uint8_t*) "off",3 )) { miss_match = false; pc.printf("\n\r\tDebug OFF\n\r\t"); debug_alive = 0; } + if( xmemmatch( (uint8_t*)(debug_buf+6), (uint8_t*) "show",4 )) { + miss_match = false; + pc.printf("\n\rdebug_sip"); + pc.printf("\n\rdebug_alive"); + pc.printf("\n\rdebug_prompt"); + pc.printf("\n\rdebug_vector"); + pc.printf("\n\rdebug_cb"); + pc.printf("\n\rdebug_main"); + pc.printf("\n\rdebug_cks"); + pc.printf("\n\rdebug_cb_rx"); + pc.printf("\n\rdebug_cb_tx*"); + pc.printf("\n\rdebug_eth_rx*"); + pc.printf("\n\rdebug_eth_tx*"); + pc.printf("\n\rdebug_file"); + } } if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "debug_sip ", 10 )) { @@ -420,7 +442,20 @@ debug_sip = 0; } } - + + if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "debug_cks ", 10 )) { + if (xmemmatch( (uint8_t*)(debug_buf + 10 ), (uint8_t*) "on",2 )) { + miss_match = false; + pc.printf( "\n\rCKS Debug ON\n\r" ); + debug_cks = 1; + } + if (xmemmatch( (uint8_t*)(debug_buf + 10 ), (uint8_t*) "off",3 )) { + miss_match = false; + pc.printf( "\n\rCKS Debug OFF\n\r" ); + debug_cks = 0; + } + } + if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "promptcb ", 9)) { //promptcb ramal porta comando static int id_msg = 0x10; uint8_t write_buffer[300]; @@ -474,7 +509,33 @@ debug_sip = 0; } } - + + if (xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "debug_cb_rx ", 12 )) { + if (xmemmatch( (uint8_t*)( debug_buf + 12 ), (uint8_t*) "on",2 )) { + miss_match = false; + pc.printf("\tDebug Cbx Rx ON"); + debug_cb_rx = 1; + } + if (xmemmatch( (uint8_t*)( debug_buf + 12 ), (uint8_t*) "off",3 )) { + miss_match = false; + pc.printf("Debug Cbx Rx OFF"); + debug_cb_rx = 0; + } + } + + if (xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "debug_file ", 11 )) { + if (xmemmatch( (uint8_t*)( debug_buf + 11 ), (uint8_t*) "on",2 )) { + miss_match = false; + pc.printf("\tDebug File ON"); + debug_cb_rx = 1; + } + if (xmemmatch( (uint8_t*)( debug_buf + 11 ), (uint8_t*) "off",3 )) { + miss_match = false; + pc.printf("Debug File OFF"); + debug_cb_rx = 0; + } + } + if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "help" )) { miss_match = false; pc.printf("\n\r****************************PROMPT HELP******************\n\r"); @@ -494,7 +555,8 @@ pc.printf("gatewayset [gateway] - Configura o gateway da cabeceira\n\r"); pc.printf("showcb - lista os Cbx registrados na header\n\r"); pc.printf("cks - exibe estatisticas de check sum\n\r"); - pc.printf("debug [on|off] - enable debugs\n\r"); + pc.printf(". - executa o comando anterior novamente\n\r"); + pc.printf("debug [on|off|show] - seleciona debugs gerais | lista de debugs \n\r"); pc.printf("flood [on|off] - simula envio de pacotes de audio\n\r"); pc.printf("PROMPT VERSION: V%d\n\r",PVERSION); }