![](/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:
- 59:e1e300880d2d
- Parent:
- 58:af7e8788f106
- Child:
- 60:b4ec6beb3be3
--- a/prompt.cpp Thu Oct 23 19:58:09 2014 +0000 +++ b/prompt.cpp Thu Oct 23 21:12:22 2014 +0000 @@ -611,10 +611,44 @@ static char promptcb_last_cmd[ 300 ]; strcpy( tmp_cmd, debug_buf ); - if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) ".",1 )) { + if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "." ) ){ miss_match = false; strcpy( debug_buf, last_cmd ); strcpy( tmp_cmd, debug_buf ); + }else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "+" ) ){ + miss_match = false; + strcpy( debug_buf, "flood on" ); + strcpy( tmp_cmd, debug_buf ); + }else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "-" ) ){ + miss_match = false; + strcpy( debug_buf, "flood off" ); + strcpy( tmp_cmd, debug_buf ); + }else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "++ ", 3 ) ){ + miss_match = false; + int ext = atoi( debug_buf + 3 ); + pc.printf("\n\rFlood ON\n\r"); + if( from_eth ){ + snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Flood On\n\r" ); + //debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; + } + tflood.start(); + tflood.reset(); + floodcount =0; + pflood = 1; + flood_timeout.start(); + sprintf( debug_buf, "pcb %i flood on", ext ); + }else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "-- ", 3 ) ){ + miss_match = false; + int ext = atoi( debug_buf + 3 ); + pc.printf("\n\rFlood OFF\n\r"); + if( from_eth ){ + snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Flood OFF\n\r" ); + //debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; + } + pflood = 0; + tflood.stop(); + flood_timeout.reset(); + sprintf( debug_buf, "pcb %i flood off", ext ); } //tratamento dos enters @@ -629,7 +663,7 @@ pc.printf("\n\r"); files('s'); } - if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "format" ) ){ + else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "format" ) ){ miss_match = false; pc.printf("\n\rFormatando o sistema de arquivos... espere o sistema reiniciar\n\r"); if( from_eth ){ @@ -648,120 +682,74 @@ NVIC_SystemReset(); } - if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "ipset ", 6 )) { + else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "ipset ", 6 )) { miss_match = false; - //fip = fopen("/qspi/myip.txt", "w"); - //fprintf(fip,"%s\n\r",(debug_buf+6)); - //fclose(fip); - //pc.printf("\n\r"); set_ip( debug_buf + 6 ); files('s'); } - if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "extset ", 7 ) ){ + else 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) ); - fclose(fip); - pc.printf("\n\r"); - */ set_header_ext( atoi( debug_buf + 7 ) ); files('s'); } - if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "serextset ", 10 ) ){ + else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "serextset ", 10 ) ){ miss_match = false; - /* - fip = fopen("/qspi/peerext.txt", "w"); - fprintf(fip, "%i\n\r" , ( debug_buf + 10 ) ); - fclose(fip); - pc.printf("\n\r"); - */ set_server_ext( atoi( debug_buf + 10 ) ); files('s'); } - if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "maskset ",8 ) ){ + else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "maskset ",8 ) ){ miss_match = false; - /* - fmask = fopen("/qspi/mymask.txt", "w"); - fprintf(fmask,"%s\n\r",(debug_buf+8)); - fclose(fmask); - pc.printf("\n\r"); - */ set_mask( debug_buf + 8 ); files('s'); } - if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "gatewayset ",11 ) ){ + else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "gatewayset ",11 ) ){ miss_match = false; - /* - fgate = fopen("/qspi/mygate.txt", "w"); - fprintf(fgate,"%s\n\r",(debug_buf+11)); - fclose(fgate); - pc.printf("\n\r"); - */ set_gateway( debug_buf + 11 ); files('s'); } - if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "msipport ",9 ) ){ + else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "msipport ",9 ) ){ miss_match = false; - /* - fport = fopen("/qspi/mysipport.txt", "w"); - fprintf(fport,"%i\n\r",(debug_buf+9)); - fclose(fport); - pc.printf("\n\r"); - */ set_header_sip_port( atoi( debug_buf + 9 ) ); files('s'); } - if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "serverip ",9 ) ){ + else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "serverip ",9 ) ){ miss_match = false; - /* - fsip = fopen("/qspi/serverip.txt", "w"); - fprintf(fsip,"%s\n\r",(debug_buf+9)); - fclose(fsip); - pc.printf("\n\r"); - */ set_server_ip( debug_buf + 9 ); files('s'); } - if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "ssport ",7 ) ){ + else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "ssport ",7 ) ){ miss_match = false; - /* - fsport = fopen("/qspi/serverport.txt", "w"); - fprintf(fsport,"%i\n\r",(debug_buf+7)); - fclose(fsport); - pc.printf("\n\r"); - */ set_server_port( atoi( debug_buf + 7 ) ); files('s'); } - if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "telemetry_ip ", 13 ) ){ + else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "telemetry_ip ", 13 ) ){ miss_match = false; set_telemetry_ip( debug_buf + 13 ); files('s'); } - if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "telemetry_port ", 15 ) ){ + else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "telemetry_port ", 15 ) ){ miss_match = false; set_telemetry_port( atoi( debug_buf + 15 ) ); files('s'); } - if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "dconfig" ) ){ + else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "dconfig" ) ){ miss_match = false; files('e'); files('w'); files('s'); } - if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "reset" ) ){ + else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "reset" ) ){ miss_match = false; pc.printf("\n\rJob is done\n\r"); if( from_eth ){ @@ -778,7 +766,7 @@ NVIC_SystemReset(); } - if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "dog" ) ){ + else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "dog" ) ){ miss_match = false; pc.printf("\n\r MUUUUUUUuuuuUUUUUU - I'm not a dog!!!! \n\r"); if( from_eth ){ @@ -787,25 +775,24 @@ } } - if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "tt" ) ){ + else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "tt" ) ){ miss_match = false; main_test = true; } - - if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "reset_cks" ) ){ + else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "reset_cks" ) ){ miss_match = false; reset_cks = true; } - if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "status" ) ){ + else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "status" ) ){ miss_match = false; cb_status = true; } - if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "flood ",6 ) ){ + else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "flood ",6 ) ){ if (xmemmatch( (uint8_t*)(debug_buf+6), (uint8_t*) "on",2 ) ){ miss_match = false; pc.printf("\n\rFlood ON\n\r"); @@ -830,6 +817,7 @@ tflood.stop(); flood_timeout.reset(); } + //FIXME -- if (xmemmatch( (uint8_t*)(debug_buf+6), (uint8_t*) "disable",3 )) { miss_match = false; // implementar uma logica que recebe start ext e end ext e manda flood off pra eles @@ -844,7 +832,7 @@ } } - if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "debug ",6 )) { + else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "debug ",6 )) { if( xmemmatch( (uint8_t*)(debug_buf+6), (uint8_t*) "on",2 )) { miss_match = false; pc.printf("\n\rDebug ON\n\r"); @@ -885,7 +873,7 @@ } } - if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "dsip ",5 ) ){ + else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "dsip ",5 ) ){ if (xmemmatch( (uint8_t*)(debug_buf + 5 ), (uint8_t*) "on",2 ) ){ miss_match = false; pc.printf( "\n\rSip Debug ON\n\r" ); @@ -906,7 +894,7 @@ } } - if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "dtelemetry ", 11 ) ){ + else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "dtelemetry ", 11 ) ){ if (xmemmatch( (uint8_t*)(debug_buf + 11 ), (uint8_t*) "on",2 ) ){ miss_match = false; pc.printf( "\n\rTelemetry Debug ON\n\r" ); @@ -927,7 +915,7 @@ } } - if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "debug_cks ", 10 )) { + else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "debug_cks ", 10 )) { if (xmemmatch( (uint8_t*)(debug_buf + 5 ), (uint8_t*) "on",2 )) { miss_match = false; pc.printf( "\n\rCKS Debug ON\n\r" ); @@ -950,16 +938,20 @@ //promptcb ramal porta comando //FIXME colocar a parte eth de novo - if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "pcb ", 4 )) { + else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "pcb ", 4 )) { miss_match = false; static uint8_t id_msg = 0x10; uint8_t write_buffer[ 300 ]; int ext,port; char *split, *ref, *cmd; + pc.printf("\n\r%s\n\r", debug_buf ); + ref = debug_buf; - debug_buf[ bufptr++ ] = 0x0D; - debug_buf[ bufptr++ ] = 0x00; + //debug_buf[ bufptr++ ] = 0x0D; + debug_buf[ strlen( debug_buf ) ] = 0x0D; + //debug_buf[ bufptr++ ] = 0x00; + debug_buf[ strlen( debug_buf ) + 1 ] = 0x00; split = strtok( debug_buf + 4, " " ); ext = atoi( split ); @@ -1015,7 +1007,7 @@ */ } - if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "_pcb",4 )) { + else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "_pcb",4 )) { miss_match = false; static int id_msg = 0x30; uint8_t write_buffer[ 300 ];