Modularizando o src
Dependencies: EALib EthernetInterface_vz mbed-rtos mbed
Fork of header_main_colinas_V0-20-09-14 by
Diff: prompt.cpp
- Revision:
- 64:5b011d5707d2
- Parent:
- 63:0d95da692bb4
- Child:
- 65:0b653cfe95db
diff -r 0d95da692bb4 -r 5b011d5707d2 prompt.cpp --- a/prompt.cpp Tue Oct 28 12:44:45 2014 +0000 +++ b/prompt.cpp Tue Oct 28 13:53:14 2014 +0000 @@ -866,12 +866,34 @@ reset_cks = true; } - /*replaced by ls + //replaced by ls else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "status" ) ){ miss_match = false; - cb_status = true; + list = true; + } + + else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "types" ) ){ + miss_match = false; + + pc.printf( "\n\rhex :: dec :: Type \n\r0x00 :: 0 :: boot \n\r0x02 :: 2 :: registry \n\r0x04 :: 4 :: invite \n\r0x08 :: 8 :: audio \n\r0x10 :: 16 :: telemetry \n\r0x20 :: 32 :: cb_bye \n\r0x01 :: 1 :: prompt \n\r0x40 :: 64 :: flood \n\r" ); + + if( from_eth ){ + snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "\n\rhex :: dec :: Type \n\r0x00 :: 0 :: boot \n\r0x02 :: 2 :: registry \n\r0x04 :: 4 :: invite \n\r0x08 :: 8 :: audio \n\r0x10 :: 16 :: telemetry \n\r0x20 :: 32 :: cb_bye \n\r0x01 :: 1 :: prompt \n\r0x40 :: 64 :: flood \n\r" ); + //debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; + } } - */ + + else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "protocol" ) ){ + miss_match = false; + + pc.printf( "\n\r| E | E | P | P | C | C | T | [ Seq_num | Audio ] | 14[ Clock | Audio ] | [ TS | Audio ] | ... |\n\r \n\rE = Ext = Ramal\n\r \n\rP = Port = Porta\n\r \n\rC = Checksum\n\r \n\rT = Type = Tipo\n\r \n\rSeq_num = Sequence Number = Numero de sequencia\n\r \n\rClock = 14 bytes to sync\n\r \n\r... = demais __CB_BUFFER_SIZE__ - __VZ_HEADER_OFFSET__ bytes\n\r" ); + + if( from_eth ){ + snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "\n\r| E | E | P | P | C | C | T | [ Seq_num | Audio ] | 14[ Clock | Audio ] | [ TS | Audio ] | ... |\n\r \n\rE = Ext = Ramal\n\r \n\rP = Port = Porta\n\r \n\rC = Checksum\n\r \n\rT = Type = Tipo\n\r \n\rSeq_num = Sequence Number = Numero de sequencia\n\r \n\rClock = 14 bytes to sync\n\r \n\r... = demais __CB_BUFFER_SIZE__ - __VZ_HEADER_OFFSET__ bytes\n\r" ); + //debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; + } + } + 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; @@ -920,6 +942,9 @@ ref = debug_buf; split = strtok( debug_buf + 8, " " ); + + //comparar com -h | --help + start_ext = atoi( split ); split += strlen( split ) + 1; @@ -1379,7 +1404,6 @@ } } - pc.printf(". - executa o comando anterior novamente\n\r"); if( from_eth ){ snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, ". - executa o comando anterior novamente\n\r" ); @@ -1416,6 +1440,52 @@ udp_server.sendTo( udp_client, debug_buf, strlen( debug_buf ) ); } } + pc.printf("rx - Exibe ultimo pacote recebido dos CBx\n\r"); + if( from_eth ){ + snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, "rx - Exibe ultimo pacote recebido dos CBx\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("tx - Exibe ultimo pacote enviado para os CBx\n\r"); + if( from_eth ){ + snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, "tx - Exibe ultimo pacote enviado para os CBx\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("ls | status - Exibe uma lista ordenada por ext do CBx registrados na Header\n\r"); + if( from_eth ){ + snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, "ls | status - Exibe uma lista ordenada por ext do CBx registrados na Header\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("types - Lista os types usados no protocolo de comunicacao Header -- CBx\n\r"); + if( from_eth ){ + snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, "types - Lista os types usados no protocolo de comunicacao Header -- CBx\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("protocol - Exibe formato do pacote seguindo o protocolo de comunicacao Header -- CBx\n\r"); + if( from_eth ){ + snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, "protocol - Exibe formato do pacote seguindo o protocolo de comunicacao Header -- CBx\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("PROMPT VERSION: V%d\n\r",PVERSION); //Obs :: a ultima linha nao mandamos direto pro tcp porque ela eh enviada fora desse escopo if( from_eth ) snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, "PROMPT VERSION: V%d\n\r",PVERSION);