![](/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:
- 36:728498a78e1e
- Parent:
- 35:96885a7931f0
- Child:
- 38:af5ecd6997ab
diff -r 96885a7931f0 -r 728498a78e1e prompt.cpp --- a/prompt.cpp Tue Sep 30 18:15:08 2014 +0000 +++ b/prompt.cpp Tue Sep 30 19:23:53 2014 +0000 @@ -236,12 +236,13 @@ } // main prompt process -void prompt_process( char * ethernet_msg ){ +char * prompt_process( char * ethernet_msg ){ //FIXME dar flush na serial volatile char b = 0; static uint8_t bufret = 0; static Timer flood_timeout; - bool restore = false; + bool from_eth = false; + bool miss_match = true; if( flood_timeout.read() > 60 ){ pflood = 0; @@ -272,13 +273,12 @@ last_bufptr = bufptr; bufptr = strlen( ethernet_msg ); debug_buf = ethernet_msg; - restore = true; + from_eth = true; bufret = 1; } // Prompt commands here if ( bufret == 1 ) { - bool miss_match = true; static unsigned int promptcb_last_ext = 0; static unsigned int promptcb_last_port = 0; @@ -387,15 +387,17 @@ if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "reset" )) { miss_match = false; - //pc.printf("\n\r reset!!! \n\r"); pc.printf("\n\rJob is done\n\r"); - pc.putc(0x01); NVIC_SystemReset(); } 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 ){ + snprintf( debug_buf, __UDP_ETH_BUFFER_SIZE__, "MUUUUUUUuuuuUUUUUU - I'm not a dog!!!!\n"); + debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; + } dog = 0; } @@ -624,7 +626,16 @@ else strcpy( last_debug_buf, debug_buf ); } - + if( from_eth ){ + ethernet_msg = debug_buf; + debug_buf = __debug_buf__; + bufptr = last_bufptr; + bufret = 0; + from_eth = false; + if( miss_match ) return( NULL ); + + else return( ethernet_msg ); + } if ( b == 0x0D || bufret == 1 || bufptr > DEBUGBUFSIZE ) { bufptr = 0; for (uint8_t i =0; i < DEBUGBUFSIZE; i++) { @@ -634,11 +645,6 @@ pc.putc(0x0A); pc.putc(0x0D); pc.printf("> "); - } - if( restore ){ - debug_buf = __debug_buf__; - bufptr = last_bufptr; - bufret = 0; - restore = false; - } + } + return( NULL ); } \ No newline at end of file