![](/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:
- 65:0b653cfe95db
- Parent:
- 64:5b011d5707d2
- Child:
- 66:3f1d22e69e7b
--- a/prompt.cpp Tue Oct 28 13:53:14 2014 +0000 +++ b/prompt.cpp Tue Oct 28 18:33:47 2014 +0000 @@ -37,6 +37,7 @@ bool rx = false; bool tx = false; bool stats = false; +bool delayed_flood = false; uint16_t boot_counter = 0; uint16_t registry_counter = 0; @@ -664,6 +665,20 @@ } } } + + if( delayed_flood ){ + tflood.start(); + tflood.reset(); + floodcount =0; + pflood = 1; + flood_timeout.start(); + delayed_flood = false; + 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'; + } + } // Prompt commands here if ( bufret == 1 ) { @@ -686,17 +701,8 @@ strcpy( tmp_cmd, debug_buf ); }else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "++ ", 3 ) ){ miss_match = false; + delayed_flood = true; 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; @@ -939,37 +945,40 @@ strcpy( promptcb_last_cmd, debug_buf ); - ref = debug_buf; - - split = strtok( debug_buf + 8, " " ); - - //comparar com -h | --help - - start_ext = atoi( split ); - - split += strlen( split ) + 1; - - end_ext = atoi( split ); - - debug_buf = ref; - - if( start_ext < end_ext && ( end_ext - start_ext ) < 50 ){ - if( start_ext % 2 ) start_ext--; - if( !( end_ext % 2 ) ) end_ext++; + if( !( strcmp( debug_buf + 8, "-h" ) && strcmp( debug_buf + 8, "--help" ) ) ){ + pc.printf("\n\rUsage :: silence start_ext end_ext | start_ext must be greater than end_ext\n\rObs : ( end_ext - start_ext ) < 50 "); + + if( tcp_session ){ + snprintf( eth_buffer, __PROMPT_ETH_BUFFER_SIZE__, "Usage :: silence start_ext end_ext | start_ext must be greater than end_ext\n\rObs : ( end_ext - start_ext ) < 50 " ); + } + }else{ + ref = debug_buf; + + split = strtok( debug_buf + 8, " " ); + + start_ext = atoi( split ); + + split += strlen( split ) + 1; + + end_ext = atoi( split ); - ext_count = start_ext; - flood_silence_timer.start(); - }else{ - pc.printf("\n\rUsage Error :: silence start_ext end_ext | start_ext must be greater than end_ext\n\rObs : ( end_ext - start_ext ) < 50 "); - - snprintf( eth_buffer, __PROMPT_ETH_BUFFER_SIZE__, "\n\rUsage Error :: silence start_ext end_ext | start_ext must be greater than end_ext\n\rObs : ( end_ext - start_ext ) < 50 " ); - if( tcp_session ){ - tcp_client.send_all( eth_buffer, strlen( eth_buffer ) ); - }else if( udp_request ){ - udp_server.sendTo( udp_client, eth_buffer, strlen( eth_buffer ) ); + debug_buf = ref; + + if( start_ext < end_ext && ( end_ext - start_ext ) < 50 ){ + if( start_ext % 2 ) start_ext--; + if( !( end_ext % 2 ) ) end_ext++; + + ext_count = start_ext; + flood_silence_timer.start(); + }else{ + pc.printf("\n\rUsage Error :: silence start_ext end_ext | start_ext must be greater than end_ext\n\rObs : ( end_ext - start_ext ) < 50 "); + + if( tcp_session ){ + snprintf( eth_buffer, __PROMPT_ETH_BUFFER_SIZE__, "Usage Error :: silence start_ext end_ext | start_ext must be greater than end_ext\n\rObs : ( end_ext - start_ext ) < 50 " ); + } } + flood_silence = true; } - flood_silence = true; } else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "debug ",6 ) ){ @@ -1431,6 +1440,17 @@ udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ); } } + + pc.printf("silence <start_ext end_ext> - envia comando de flood off para os ramais no intervalo end_ext - start_ext\n\r"); + if( from_eth ){ + snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, "silence <start_ext end_ext> - envia comando de flood off para os ramais no intervalo end_ext - start_ext\n\r"); + if( tcp_session ) tcp_client.send_all( debug_buf, strlen( debug_buf ) ); + + else if( udp_request ){ + udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ); + } + } + pc.printf("++ ext - Header flood on, ext flood on\n\r"); if( from_eth ){ snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, "++ ext - Header flood on, ext flood on\n\r");