![](/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
prompt.cpp@107:cf1e43414adb, 2015-03-16 (annotated)
- Committer:
- klauss
- Date:
- Mon Mar 16 14:05:05 2015 +0000
- Revision:
- 107:cf1e43414adb
- Parent:
- 106:a34fcf9f0e02
- Child:
- 108:18a3702650f3
inicio da implementa??o dos debugs do RTP
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
klauss | 44:cc4996469404 | 1 | #include "prompt.h" |
klauss | 45:c80574f24dc3 | 2 | |
klauss | 60:b4ec6beb3be3 | 3 | bool flood_silence = false; |
klauss | 65:0b653cfe95db | 4 | bool delayed_flood = false; |
klauss | 63:0d95da692bb4 | 5 | |
klauss | 78:1353744f01e1 | 6 | Timer tcp_timer; |
klauss | 105:a930035b6556 | 7 | |
klauss | 78:1353744f01e1 | 8 | bool tcp_alive = false; |
klauss | 105:a930035b6556 | 9 | bool serial_pc_pending = false; |
klauss | 19:ab2088e0dec6 | 10 | |
klauss | 58:af7e8788f106 | 11 | char __debug_buf__[ DEBUGBUFSIZE ]; |
klauss | 35:96885a7931f0 | 12 | char * debug_buf = __debug_buf__; |
klauss | 58:af7e8788f106 | 13 | char last_cmd[ DEBUGBUFSIZE ]; |
klauss | 58:af7e8788f106 | 14 | char tmp_cmd[ DEBUGBUFSIZE ] = "help"; |
klauss | 30:8dfb6d8de53d | 15 | char last_debug_buf[ DEBUGBUFSIZE ] = "help"; |
klauss | 105:a930035b6556 | 16 | char eth_buffer[ __PROMPT_ETH_BUFFER_SIZE__ ]; |
klauss | 105:a930035b6556 | 17 | char gp_buff[ DEBUGBUFSIZE ]; |
klauss | 60:b4ec6beb3be3 | 18 | |
klauss | 106:a34fcf9f0e02 | 19 | FILE *fip, *fmask, *fgate, *fport, *fsip, *fsport, *fext, *fserext, *fudpport, *ftcpport, *ffwip, *ffwport, *fmax, *fmin, *fshift_port; |
klauss | 81:3656f00ab3db | 20 | |
klauss | 19:ab2088e0dec6 | 21 | uint8_t bufptr = 0; |
klauss | 35:96885a7931f0 | 22 | uint8_t last_bufptr = 0; |
klauss | 19:ab2088e0dec6 | 23 | |
klauss | 105:a930035b6556 | 24 | void init_prompt_eth() |
klauss | 105:a930035b6556 | 25 | { |
klauss | 105:a930035b6556 | 26 | int udp_bind = udp_client.bind( UDP_PORT_LISTENER ); |
klauss | 105:a930035b6556 | 27 | udp_client.set_blocking( false, 0 ); |
klauss | 106:a34fcf9f0e02 | 28 | if( debug_uart3 && !( from_eth ) ) pc.printf("\r\n******* Prompt eth UDP Ready [ %d ] *******\r\n", udp_bind ); |
klauss | 19:ab2088e0dec6 | 29 | |
klauss | 105:a930035b6556 | 30 | int tcp_bind = tcp_server.bind( TCP_PORT_LISTENER ); |
klauss | 89:0fe315117b00 | 31 | tcp_server.set_blocking( false, 0 ); |
klauss | 105:a930035b6556 | 32 | int tcp_listen = tcp_server.listen(); |
klauss | 106:a34fcf9f0e02 | 33 | if( debug_uart3 && !( from_eth ) ) pc.printf("\r\n******* Prompt eth TCP Ready [ %d, %d ] *******\r\n", tcp_bind, tcp_listen ); |
klauss | 19:ab2088e0dec6 | 34 | } |
klauss | 19:ab2088e0dec6 | 35 | |
klauss | 28:94aec56c6329 | 36 | // main prompt process |
klauss | 105:a930035b6556 | 37 | char * prompt_process( char * msg_from_cb, int length ) |
klauss | 103:e3cabfc2f533 | 38 | { |
klauss | 28:94aec56c6329 | 39 | //FIXME dar flush na serial |
klauss | 19:ab2088e0dec6 | 40 | volatile char b = 0; |
klauss | 19:ab2088e0dec6 | 41 | static uint8_t bufret = 0; |
klauss | 30:8dfb6d8de53d | 42 | static Timer flood_timeout; |
klauss | 60:b4ec6beb3be3 | 43 | static Timer flood_silence_timer; |
klauss | 60:b4ec6beb3be3 | 44 | static uint8_t id_msg = 0x10; |
klauss | 60:b4ec6beb3be3 | 45 | static int start_ext, end_ext, ext_count; |
klauss | 36:728498a78e1e | 46 | bool miss_match = true; |
klauss | 105:a930035b6556 | 47 | uint8_t write_buffer[ CB_BUFFER_SIZE ]; |
klauss | 103:e3cabfc2f533 | 48 | |
klauss | 103:e3cabfc2f533 | 49 | if( flood_timeout.read() > 60 ) { |
klauss | 45:c80574f24dc3 | 50 | pflood = 0; |
klauss | 45:c80574f24dc3 | 51 | flood_timeout.stop(); |
klauss | 45:c80574f24dc3 | 52 | flood_timeout.reset(); |
klauss | 45:c80574f24dc3 | 53 | } |
klauss | 103:e3cabfc2f533 | 54 | |
klauss | 103:e3cabfc2f533 | 55 | if( tcp_timer.read() >= TCP_IDLE_MAX_TIME ) { |
klauss | 103:e3cabfc2f533 | 56 | tcp_alive = false; |
klauss | 103:e3cabfc2f533 | 57 | tcp_timer.stop(); |
klauss | 103:e3cabfc2f533 | 58 | tcp_timer.reset(); |
klauss | 103:e3cabfc2f533 | 59 | tcp_session = false; |
klauss | 103:e3cabfc2f533 | 60 | debug_buf = __debug_buf__; |
klauss | 103:e3cabfc2f533 | 61 | bufptr = last_bufptr; |
klauss | 103:e3cabfc2f533 | 62 | bufret = 0; |
klauss | 103:e3cabfc2f533 | 63 | from_eth = false; |
klauss | 103:e3cabfc2f533 | 64 | tcp_client.close(); |
klauss | 103:e3cabfc2f533 | 65 | return( NULL ); |
klauss | 105:a930035b6556 | 66 | } |
klauss | 105:a930035b6556 | 67 | |
klauss | 105:a930035b6556 | 68 | if( udp_query ) |
klauss | 105:a930035b6556 | 69 | { |
klauss | 105:a930035b6556 | 70 | if( msg_from_cb != NULL ) |
klauss | 105:a930035b6556 | 71 | { |
klauss | 105:a930035b6556 | 72 | last_bufptr = bufptr; |
klauss | 105:a930035b6556 | 73 | if( ( length > 2 ) && ( msg_from_cb[ length - 2 ] == '\r' ) ) msg_from_cb[ length - 2 ] = 0; |
klauss | 105:a930035b6556 | 74 | |
klauss | 105:a930035b6556 | 75 | if( ( length > 1 ) && ( msg_from_cb[ length - 1 ] == '\n' ) ) msg_from_cb[ length - 1 ] = 0; |
klauss | 103:e3cabfc2f533 | 76 | |
klauss | 105:a930035b6556 | 77 | if( ( length == 1 ) && msg_from_cb[ 0 ] == 0x0A ) strcpy( msg_from_cb, "\r" ); |
klauss | 105:a930035b6556 | 78 | |
klauss | 105:a930035b6556 | 79 | bufptr = strlen( msg_from_cb ); |
klauss | 105:a930035b6556 | 80 | debug_buf = msg_from_cb; |
klauss | 103:e3cabfc2f533 | 81 | from_eth = true; |
klauss | 103:e3cabfc2f533 | 82 | bufret = 1; |
klauss | 105:a930035b6556 | 83 | } |
klauss | 105:a930035b6556 | 84 | } |
klauss | 105:a930035b6556 | 85 | else |
klauss | 105:a930035b6556 | 86 | { |
klauss | 105:a930035b6556 | 87 | if( !tcp_server.accept( tcp_client ) ) |
klauss | 105:a930035b6556 | 88 | { |
klauss | 105:a930035b6556 | 89 | tcp_session = true; |
klauss | 105:a930035b6556 | 90 | tcp_timer.start(); |
klauss | 105:a930035b6556 | 91 | last_bufptr = bufptr; |
klauss | 105:a930035b6556 | 92 | for( register int i = 0; i < __PROMPT_ETH_BUFFER_SIZE__; i++ ) eth_buffer[ i ] = 0; |
klauss | 105:a930035b6556 | 93 | } |
klauss | 105:a930035b6556 | 94 | if( tcp_session && !udp_query ) |
klauss | 105:a930035b6556 | 95 | { |
klauss | 105:a930035b6556 | 96 | tcp_client.set_blocking( false, 0 ); |
klauss | 105:a930035b6556 | 97 | //for( register int i = 0; i < __PROMPT_ETH_BUFFER_SIZE__; i++ ) eth_buffer[ i ] = 0; |
klauss | 105:a930035b6556 | 98 | int n = tcp_client.receive( eth_buffer, sizeof( eth_buffer ) - 1 ); |
klauss | 105:a930035b6556 | 99 | if( n > 0 ) { |
klauss | 103:e3cabfc2f533 | 100 | tcp_timer.reset(); |
klauss | 105:a930035b6556 | 101 | |
klauss | 105:a930035b6556 | 102 | if( ( n > 2 ) && ( eth_buffer[ n - 2 ] == '\r' ) ) eth_buffer[ n - 2 ] = 0; |
klauss | 105:a930035b6556 | 103 | |
klauss | 105:a930035b6556 | 104 | if( ( n > 1 ) && ( eth_buffer[ n - 1 ] == '\n' ) ) eth_buffer[ n - 1 ] = 0; |
klauss | 105:a930035b6556 | 105 | |
klauss | 105:a930035b6556 | 106 | if( ( n == 1 ) && eth_buffer[ 0 ] == 0x0A ) strcpy( eth_buffer, "\r" ); |
klauss | 105:a930035b6556 | 107 | |
klauss | 105:a930035b6556 | 108 | bufptr = strlen( eth_buffer ); |
klauss | 105:a930035b6556 | 109 | debug_buf = eth_buffer; |
klauss | 105:a930035b6556 | 110 | from_eth = true; |
klauss | 105:a930035b6556 | 111 | bufret = 1; |
klauss | 105:a930035b6556 | 112 | |
klauss | 105:a930035b6556 | 113 | if( !( strcmp( eth_buffer, "quit" ) ) ) { |
klauss | 105:a930035b6556 | 114 | tcp_timer.reset(); |
klauss | 105:a930035b6556 | 115 | debug_buf = __debug_buf__; |
klauss | 105:a930035b6556 | 116 | bufptr = last_bufptr; |
klauss | 105:a930035b6556 | 117 | from_eth = false; |
klauss | 105:a930035b6556 | 118 | tcp_session = false; |
klauss | 105:a930035b6556 | 119 | tcp_client.close(); |
klauss | 105:a930035b6556 | 120 | bufret = 0; |
klauss | 105:a930035b6556 | 121 | return( NULL ); |
klauss | 105:a930035b6556 | 122 | } |
klauss | 105:a930035b6556 | 123 | } else { |
klauss | 48:195c97f12e8e | 124 | debug_buf = __debug_buf__; |
klauss | 48:195c97f12e8e | 125 | bufptr = last_bufptr; |
klauss | 57:78f7191a8b69 | 126 | from_eth = false; |
klauss | 45:c80574f24dc3 | 127 | } |
klauss | 103:e3cabfc2f533 | 128 | } |
klauss | 53:bb492a8f115a | 129 | } |
klauss | 105:a930035b6556 | 130 | |
klauss | 105:a930035b6556 | 131 | if( ( !from_eth ) && ( !udp_query ) ) |
klauss | 105:a930035b6556 | 132 | { |
klauss | 105:a930035b6556 | 133 | if( pc.readable() ) { |
klauss | 53:bb492a8f115a | 134 | b = pc.getc(); |
klauss | 105:a930035b6556 | 135 | if( b == 0x0D ) { |
klauss | 105:a930035b6556 | 136 | // enter |
klauss | 53:bb492a8f115a | 137 | bufret = 1; |
klauss | 105:a930035b6556 | 138 | if( from_eth ) serial_pc_pending = true; |
klauss | 105:a930035b6556 | 139 | } else { |
klauss | 53:bb492a8f115a | 140 | pc.putc( b ); |
klauss | 105:a930035b6556 | 141 | if( b == 0x08 || b == 0x7F ) { |
klauss | 105:a930035b6556 | 142 | // BS | DEL |
klauss | 105:a930035b6556 | 143 | if( bufptr > 0 ) { |
klauss | 105:a930035b6556 | 144 | __debug_buf__[ --bufptr ] = 0; |
klauss | 105:a930035b6556 | 145 | } |
klauss | 105:a930035b6556 | 146 | } else if( b == 0x09 ) { |
klauss | 53:bb492a8f115a | 147 | // ignore tab |
klauss | 105:a930035b6556 | 148 | } else { |
klauss | 105:a930035b6556 | 149 | //debug_msg("--%c,%d--%d--", b, bufptr, last_bufptr ); |
klauss | 105:a930035b6556 | 150 | __debug_buf__[ bufptr ] = b; |
klauss | 53:bb492a8f115a | 151 | bufptr++; |
klauss | 42:480335bdde12 | 152 | } |
klauss | 104:62646ef786a3 | 153 | last_bufptr = bufptr; |
klauss | 31:bb5fb28a77df | 154 | } |
klauss | 53:bb492a8f115a | 155 | } |
klauss | 48:195c97f12e8e | 156 | } |
klauss | 105:a930035b6556 | 157 | |
klauss | 105:a930035b6556 | 158 | if( flood_silence ) { |
klauss | 105:a930035b6556 | 159 | if( flood_silence_timer.read_ms() > 250 ) { |
klauss | 60:b4ec6beb3be3 | 160 | char cmd[ 16 ] = "flood off"; |
klauss | 60:b4ec6beb3be3 | 161 | int str_end = strlen( cmd ); |
klauss | 60:b4ec6beb3be3 | 162 | cmd[ str_end ] = 0x0D; |
klauss | 60:b4ec6beb3be3 | 163 | cmd[ str_end + 1 ] = 0x00; |
klauss | 105:a930035b6556 | 164 | |
klauss | 60:b4ec6beb3be3 | 165 | int port = convert_ext_to_port( ext_count ); |
klauss | 105:a930035b6556 | 166 | send2callboxes( build_cb_package( ext_count, port, __PROMPT__, cmd, id_msg++, CB_BUFFER_SIZE - __VZ_HEADER_OFFSET__, write_buffer ) ); |
klauss | 104:62646ef786a3 | 167 | if( debug_uart3 && !( from_eth ) ) pc.printf("\r\nSilence sent to ext=%d port=%d", ext_count, port ); |
klauss | 105:a930035b6556 | 168 | |
klauss | 105:a930035b6556 | 169 | if( tcp_session && !udp_query ) { |
klauss | 60:b4ec6beb3be3 | 170 | snprintf( eth_buffer, __PROMPT_ETH_BUFFER_SIZE__, "\r\nSilence sent to ext=%d port=%d", ext_count, port ); |
klauss | 60:b4ec6beb3be3 | 171 | tcp_client.send_all( eth_buffer, strlen( eth_buffer ) ); |
klauss | 105:a930035b6556 | 172 | } else if( udp_query ) { |
klauss | 60:b4ec6beb3be3 | 173 | snprintf( eth_buffer, __PROMPT_ETH_BUFFER_SIZE__, "\r\nSilence sent to ext=%d port=%d", ext_count, port ); |
klauss | 105:a930035b6556 | 174 | udp_query_send_msg( eth_buffer ); |
klauss | 60:b4ec6beb3be3 | 175 | } |
klauss | 60:b4ec6beb3be3 | 176 | flood_silence_timer.reset(); |
klauss | 105:a930035b6556 | 177 | |
klauss | 103:e3cabfc2f533 | 178 | // importante para o uso da funçao silence |
klauss | 105:a930035b6556 | 179 | if( ++ext_count > end_ext ) { |
klauss | 60:b4ec6beb3be3 | 180 | flood_silence = false; |
klauss | 60:b4ec6beb3be3 | 181 | flood_silence_timer.stop(); |
klauss | 60:b4ec6beb3be3 | 182 | flood_silence_timer.reset(); |
klauss | 105:a930035b6556 | 183 | |
klauss | 104:62646ef786a3 | 184 | if( debug_uart3 && !( from_eth ) ) pc.printf("\r\n> " ); |
klauss | 105:a930035b6556 | 185 | if( tcp_session && !udp_query ) { |
klauss | 60:b4ec6beb3be3 | 186 | snprintf( eth_buffer, __PROMPT_ETH_BUFFER_SIZE__, "\r\n> " ); |
klauss | 60:b4ec6beb3be3 | 187 | tcp_client.send_all( eth_buffer, strlen( eth_buffer ) ); |
klauss | 105:a930035b6556 | 188 | } else if( udp_query ) { |
klauss | 60:b4ec6beb3be3 | 189 | snprintf( eth_buffer, __PROMPT_ETH_BUFFER_SIZE__, "\r\n> " ); |
klauss | 105:a930035b6556 | 190 | udp_query_send_msg( eth_buffer ); |
klauss | 60:b4ec6beb3be3 | 191 | } |
klauss | 60:b4ec6beb3be3 | 192 | } |
klauss | 60:b4ec6beb3be3 | 193 | } |
klauss | 60:b4ec6beb3be3 | 194 | } |
klauss | 105:a930035b6556 | 195 | |
klauss | 105:a930035b6556 | 196 | if( delayed_flood ) { |
klauss | 65:0b653cfe95db | 197 | tflood.start(); |
klauss | 65:0b653cfe95db | 198 | tflood.reset(); |
klauss | 65:0b653cfe95db | 199 | floodcount =0; |
klauss | 65:0b653cfe95db | 200 | pflood = 1; |
klauss | 65:0b653cfe95db | 201 | flood_timeout.start(); |
klauss | 65:0b653cfe95db | 202 | delayed_flood = false; |
klauss | 104:62646ef786a3 | 203 | if( debug_uart3 && !( from_eth ) ) pc.printf("\n\rFlood ON\n\r"); |
klauss | 105:a930035b6556 | 204 | //FIXME avaliar melhor essa expressao |
klauss | 105:a930035b6556 | 205 | if( from_eth ) { |
klauss | 65:0b653cfe95db | 206 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Flood On\n\r" ); |
klauss | 65:0b653cfe95db | 207 | } |
klauss | 65:0b653cfe95db | 208 | } |
klauss | 105:a930035b6556 | 209 | |
klauss | 105:a930035b6556 | 210 | if( serial_pc_pending && !from_eth ) { |
klauss | 105:a930035b6556 | 211 | bufret = 1; |
klauss | 105:a930035b6556 | 212 | } |
klauss | 45:c80574f24dc3 | 213 | // Prompt commands here |
klauss | 58:af7e8788f106 | 214 | if ( bufret == 1 ) { |
klauss | 105:a930035b6556 | 215 | static unsigned int promptcb_last_ext = 0; |
klauss | 105:a930035b6556 | 216 | static unsigned int promptcb_last_port = 0; |
klauss | 55:2f5e7374af9d | 217 | static char promptcb_last_cmd[ 300 ]; |
klauss | 60:b4ec6beb3be3 | 218 | |
klauss | 58:af7e8788f106 | 219 | strcpy( tmp_cmd, debug_buf ); |
klauss | 105:a930035b6556 | 220 | if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "." ) ) { |
klauss | 45:c80574f24dc3 | 221 | miss_match = false; |
klauss | 58:af7e8788f106 | 222 | strcpy( debug_buf, last_cmd ); |
klauss | 58:af7e8788f106 | 223 | strcpy( tmp_cmd, debug_buf ); |
klauss | 105:a930035b6556 | 224 | } else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "+" ) ) { |
klauss | 59:e1e300880d2d | 225 | miss_match = false; |
klauss | 59:e1e300880d2d | 226 | strcpy( debug_buf, "flood on" ); |
klauss | 59:e1e300880d2d | 227 | strcpy( tmp_cmd, debug_buf ); |
klauss | 105:a930035b6556 | 228 | } else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "-" ) ) { |
klauss | 59:e1e300880d2d | 229 | miss_match = false; |
klauss | 59:e1e300880d2d | 230 | strcpy( debug_buf, "flood off" ); |
klauss | 59:e1e300880d2d | 231 | strcpy( tmp_cmd, debug_buf ); |
klauss | 105:a930035b6556 | 232 | } else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "++ ", 3 ) ) { |
klauss | 59:e1e300880d2d | 233 | miss_match = false; |
klauss | 65:0b653cfe95db | 234 | delayed_flood = true; |
klauss | 59:e1e300880d2d | 235 | int ext = atoi( debug_buf + 3 ); |
klauss | 59:e1e300880d2d | 236 | sprintf( debug_buf, "pcb %i flood on", ext ); |
klauss | 105:a930035b6556 | 237 | } else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "-- ", 3 ) ) { |
klauss | 59:e1e300880d2d | 238 | miss_match = false; |
klauss | 59:e1e300880d2d | 239 | int ext = atoi( debug_buf + 3 ); |
klauss | 104:62646ef786a3 | 240 | if( debug_uart3 && !( from_eth ) ) pc.printf("\n\rFlood OFF\n\r"); |
klauss | 105:a930035b6556 | 241 | if( from_eth ) { |
klauss | 59:e1e300880d2d | 242 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Flood OFF\n\r" ); |
klauss | 59:e1e300880d2d | 243 | } |
klauss | 59:e1e300880d2d | 244 | pflood = 0; |
klauss | 59:e1e300880d2d | 245 | tflood.stop(); |
klauss | 59:e1e300880d2d | 246 | flood_timeout.reset(); |
klauss | 105:a930035b6556 | 247 | sprintf( debug_buf, "pcb %i flood off", ext ); |
klauss | 45:c80574f24dc3 | 248 | } |
klauss | 105:a930035b6556 | 249 | |
klauss | 48:195c97f12e8e | 250 | //tratamento dos enters |
klauss | 105:a930035b6556 | 251 | if( !bufptr ) { |
klauss | 45:c80574f24dc3 | 252 | miss_match = false; |
klauss | 105:a930035b6556 | 253 | } else if( bufptr == 1 ) { |
klauss | 48:195c97f12e8e | 254 | if( debug_buf[ 0 ] == 0x0D || debug_buf[ 0 ] == 0x0D ) miss_match = false; |
klauss | 48:195c97f12e8e | 255 | } |
klauss | 105:a930035b6556 | 256 | |
klauss | 105:a930035b6556 | 257 | if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "ifconfig" ) ) { |
klauss | 45:c80574f24dc3 | 258 | miss_match = false; |
klauss | 104:62646ef786a3 | 259 | if( debug_uart3 && !( from_eth ) ) pc.printf("\n\r"); |
klauss | 45:c80574f24dc3 | 260 | files('s'); |
klauss | 106:a34fcf9f0e02 | 261 | for( register int i = 0; i < DEBUGBUFSIZE; i++ ) debug_buf[ i ] = 0; |
klauss | 106:a34fcf9f0e02 | 262 | bufptr = 0; |
klauss | 45:c80574f24dc3 | 263 | } |
klauss | 105:a930035b6556 | 264 | |
klauss | 105:a930035b6556 | 265 | else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "rx" ) ) { |
klauss | 62:07e5bdc9f8f7 | 266 | miss_match = false; |
klauss | 62:07e5bdc9f8f7 | 267 | rx = true; |
klauss | 62:07e5bdc9f8f7 | 268 | } |
klauss | 105:a930035b6556 | 269 | |
klauss | 105:a930035b6556 | 270 | else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "tx" ) ) { |
klauss | 63:0d95da692bb4 | 271 | miss_match = false; |
klauss | 63:0d95da692bb4 | 272 | tx = true; |
klauss | 63:0d95da692bb4 | 273 | } |
klauss | 105:a930035b6556 | 274 | |
klauss | 105:a930035b6556 | 275 | else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "stats" ) ) { |
klauss | 63:0d95da692bb4 | 276 | miss_match = false; |
klauss | 63:0d95da692bb4 | 277 | stats = true; |
klauss | 105:a930035b6556 | 278 | } else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "reset_stats" ) ) { |
klauss | 63:0d95da692bb4 | 279 | miss_match = false; |
klauss | 63:0d95da692bb4 | 280 | r_stats = true; |
klauss | 63:0d95da692bb4 | 281 | } |
klauss | 105:a930035b6556 | 282 | |
klauss | 105:a930035b6556 | 283 | else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "format" ) ) { |
klauss | 45:c80574f24dc3 | 284 | miss_match = false; |
klauss | 104:62646ef786a3 | 285 | if( debug_uart3 && !( from_eth ) ) pc.printf("\n\rFormatando o sistema de arquivos... espere o sistema reiniciar\n\r"); |
klauss | 105:a930035b6556 | 286 | |
klauss | 105:a930035b6556 | 287 | if( from_eth ) |
klauss | 105:a930035b6556 | 288 | { |
klauss | 105:a930035b6556 | 289 | char msg[ 32 ]; |
klauss | 105:a930035b6556 | 290 | snprintf( msg, 32, "Not Allowed\n\r"); |
klauss | 105:a930035b6556 | 291 | |
klauss | 105:a930035b6556 | 292 | if( tcp_session && !udp_query ) { |
klauss | 105:a930035b6556 | 293 | tcp_client.send_all( msg, strlen( msg ) ); |
klauss | 105:a930035b6556 | 294 | } else if( udp_query ) { |
klauss | 105:a930035b6556 | 295 | udp_query_send_msg( msg ); |
klauss | 105:a930035b6556 | 296 | } |
klauss | 105:a930035b6556 | 297 | } else { |
klauss | 62:07e5bdc9f8f7 | 298 | files('e'); |
klauss | 62:07e5bdc9f8f7 | 299 | files('w'); |
klauss | 62:07e5bdc9f8f7 | 300 | __disable_irq(); |
klauss | 62:07e5bdc9f8f7 | 301 | NVIC_SystemReset(); |
klauss | 42:480335bdde12 | 302 | } |
klauss | 45:c80574f24dc3 | 303 | } |
klauss | 45:c80574f24dc3 | 304 | |
klauss | 59:e1e300880d2d | 305 | else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "ipset ", 6 )) { |
klauss | 45:c80574f24dc3 | 306 | miss_match = false; |
klauss | 54:448d57291be6 | 307 | set_ip( debug_buf + 6 ); |
klauss | 45:c80574f24dc3 | 308 | files('s'); |
klauss | 45:c80574f24dc3 | 309 | } |
klauss | 105:a930035b6556 | 310 | |
klauss | 105:a930035b6556 | 311 | else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "extset ", 7 ) ) { |
klauss | 45:c80574f24dc3 | 312 | miss_match = false; |
klauss | 55:2f5e7374af9d | 313 | set_header_ext( atoi( debug_buf + 7 ) ); |
klauss | 45:c80574f24dc3 | 314 | files('s'); |
klauss | 45:c80574f24dc3 | 315 | } |
klauss | 105:a930035b6556 | 316 | |
klauss | 105:a930035b6556 | 317 | else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "serextset ", 10 ) ) { |
klauss | 45:c80574f24dc3 | 318 | miss_match = false; |
klauss | 55:2f5e7374af9d | 319 | set_server_ext( atoi( debug_buf + 10 ) ); |
klauss | 45:c80574f24dc3 | 320 | files('s'); |
klauss | 45:c80574f24dc3 | 321 | } |
klauss | 45:c80574f24dc3 | 322 | |
klauss | 105:a930035b6556 | 323 | else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "maskset ",8 ) ) { |
klauss | 45:c80574f24dc3 | 324 | miss_match = false; |
klauss | 55:2f5e7374af9d | 325 | set_mask( debug_buf + 8 ); |
klauss | 45:c80574f24dc3 | 326 | files('s'); |
klauss | 45:c80574f24dc3 | 327 | } |
klauss | 45:c80574f24dc3 | 328 | |
klauss | 105:a930035b6556 | 329 | else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "gatewayset ",11 ) ) { |
klauss | 45:c80574f24dc3 | 330 | miss_match = false; |
klauss | 55:2f5e7374af9d | 331 | set_gateway( debug_buf + 11 ); |
klauss | 45:c80574f24dc3 | 332 | files('s'); |
klauss | 45:c80574f24dc3 | 333 | } |
klauss | 45:c80574f24dc3 | 334 | |
klauss | 105:a930035b6556 | 335 | else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "msipport ",9 ) ) { |
klauss | 45:c80574f24dc3 | 336 | miss_match = false; |
klauss | 55:2f5e7374af9d | 337 | set_header_sip_port( atoi( debug_buf + 9 ) ); |
klauss | 45:c80574f24dc3 | 338 | files('s'); |
klauss | 45:c80574f24dc3 | 339 | } |
klauss | 45:c80574f24dc3 | 340 | |
klauss | 105:a930035b6556 | 341 | else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "serverip ",9 ) ) { |
klauss | 45:c80574f24dc3 | 342 | miss_match = false; |
klauss | 55:2f5e7374af9d | 343 | set_server_ip( debug_buf + 9 ); |
klauss | 45:c80574f24dc3 | 344 | files('s'); |
klauss | 45:c80574f24dc3 | 345 | } |
klauss | 105:a930035b6556 | 346 | |
klauss | 105:a930035b6556 | 347 | else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "maxext ", 7 ) ) { |
klauss | 81:3656f00ab3db | 348 | miss_match = false; |
klauss | 81:3656f00ab3db | 349 | set_max_ext( atoi( debug_buf + 7 ) ); |
klauss | 81:3656f00ab3db | 350 | files('s'); |
klauss | 81:3656f00ab3db | 351 | } |
klauss | 105:a930035b6556 | 352 | |
klauss | 105:a930035b6556 | 353 | else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "minext ", 7 ) ) { |
klauss | 81:3656f00ab3db | 354 | miss_match = false; |
klauss | 81:3656f00ab3db | 355 | set_min_ext( atoi( debug_buf + 7 ) ); |
klauss | 81:3656f00ab3db | 356 | files('s'); |
klauss | 81:3656f00ab3db | 357 | } |
klauss | 45:c80574f24dc3 | 358 | |
klauss | 105:a930035b6556 | 359 | else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "ssport ", 7 ) ) { |
klauss | 45:c80574f24dc3 | 360 | miss_match = false; |
klauss | 55:2f5e7374af9d | 361 | set_server_port( atoi( debug_buf + 7 ) ); |
klauss | 45:c80574f24dc3 | 362 | files('s'); |
klauss | 45:c80574f24dc3 | 363 | } |
klauss | 105:a930035b6556 | 364 | |
klauss | 105:a930035b6556 | 365 | else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "fw_ip ", 6 ) ) { |
klauss | 99:e80850c51106 | 366 | miss_match = false; |
klauss | 99:e80850c51106 | 367 | set_fw_ip( debug_buf + 6 ); |
klauss | 99:e80850c51106 | 368 | files('s'); |
klauss | 99:e80850c51106 | 369 | } |
klauss | 105:a930035b6556 | 370 | |
klauss | 105:a930035b6556 | 371 | else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "fw_port ", 8 ) ) { |
klauss | 99:e80850c51106 | 372 | miss_match = false; |
klauss | 99:e80850c51106 | 373 | set_fw_port( atoi( debug_buf + 8 ) ); |
klauss | 99:e80850c51106 | 374 | files('s'); |
klauss | 99:e80850c51106 | 375 | } |
klauss | 106:a34fcf9f0e02 | 376 | |
klauss | 106:a34fcf9f0e02 | 377 | else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "shift_port ", 11 ) ) { |
klauss | 106:a34fcf9f0e02 | 378 | miss_match = false; |
klauss | 106:a34fcf9f0e02 | 379 | set_shift_port( atoi( debug_buf + 11 ) ); |
klauss | 106:a34fcf9f0e02 | 380 | files('s'); |
klauss | 106:a34fcf9f0e02 | 381 | } |
klauss | 45:c80574f24dc3 | 382 | |
klauss | 105:a930035b6556 | 383 | else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "dconfig" ) ) { |
klauss | 45:c80574f24dc3 | 384 | miss_match = false; |
klauss | 50:d9b6577a70f5 | 385 | files('e'); |
klauss | 45:c80574f24dc3 | 386 | files('w'); |
klauss | 45:c80574f24dc3 | 387 | files('s'); |
klauss | 45:c80574f24dc3 | 388 | } |
klauss | 45:c80574f24dc3 | 389 | |
klauss | 105:a930035b6556 | 390 | else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "reset" ) ) { |
klauss | 45:c80574f24dc3 | 391 | miss_match = false; |
klauss | 104:62646ef786a3 | 392 | if( debug_uart3 && !( from_eth ) ) pc.printf("\n\rJob is done\n\r"); |
klauss | 105:a930035b6556 | 393 | if( from_eth ) { |
klauss | 45:c80574f24dc3 | 394 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Job is done\n\r"); |
klauss | 45:c80574f24dc3 | 395 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 105:a930035b6556 | 396 | if( tcp_session && !udp_query ) { |
klauss | 45:c80574f24dc3 | 397 | tcp_client.send_all( debug_buf, strlen( debug_buf ) ); |
klauss | 45:c80574f24dc3 | 398 | tcp_client.close(); |
klauss | 105:a930035b6556 | 399 | } else if( udp_query ) { |
klauss | 105:a930035b6556 | 400 | udp_query_send_msg( debug_buf ); |
klauss | 42:480335bdde12 | 401 | } |
klauss | 45:c80574f24dc3 | 402 | } |
klauss | 48:195c97f12e8e | 403 | __disable_irq(); |
klauss | 45:c80574f24dc3 | 404 | NVIC_SystemReset(); |
klauss | 45:c80574f24dc3 | 405 | } |
klauss | 45:c80574f24dc3 | 406 | |
klauss | 105:a930035b6556 | 407 | else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "dog" ) ) { |
klauss | 45:c80574f24dc3 | 408 | miss_match = false; |
klauss | 104:62646ef786a3 | 409 | if( debug_uart3 && !( from_eth ) ) pc.printf("\n\r MUUUUUUUuuuuUUUUUU - I'm not a dog!!!! \n\r"); |
klauss | 105:a930035b6556 | 410 | if( from_eth ) { |
klauss | 45:c80574f24dc3 | 411 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "MUUUUUUUuuuuUUUUUU - I'm not a dog!!!!\n\r"); |
klauss | 105:a930035b6556 | 412 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 105:a930035b6556 | 413 | if( tcp_session && !udp_query ) { |
klauss | 105:a930035b6556 | 414 | tcp_client.send_all( debug_buf, strlen( debug_buf ) ); |
klauss | 105:a930035b6556 | 415 | } else if( udp_query ) { |
klauss | 105:a930035b6556 | 416 | udp_query_send_msg( debug_buf ); |
klauss | 105:a930035b6556 | 417 | } |
klauss | 45:c80574f24dc3 | 418 | } |
klauss | 45:c80574f24dc3 | 419 | } |
klauss | 105:a930035b6556 | 420 | |
klauss | 105:a930035b6556 | 421 | else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "test" ) ) { |
klauss | 105:a930035b6556 | 422 | miss_match = false; |
klauss | 105:a930035b6556 | 423 | debug_msg("Test something"); |
klauss | 105:a930035b6556 | 424 | } |
klauss | 48:195c97f12e8e | 425 | |
klauss | 106:a34fcf9f0e02 | 426 | else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "deleted" ) ) { |
klauss | 106:a34fcf9f0e02 | 427 | miss_match = false; |
klauss | 106:a34fcf9f0e02 | 428 | send_msg("::%d::", deleted_sip ); |
klauss | 106:a34fcf9f0e02 | 429 | } |
klauss | 106:a34fcf9f0e02 | 430 | |
klauss | 105:a930035b6556 | 431 | else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "missed" ) ) { |
klauss | 105:a930035b6556 | 432 | miss_match = false; |
klauss | 105:a930035b6556 | 433 | missed_send_udp_pkg = true; |
klauss | 105:a930035b6556 | 434 | } |
klauss | 105:a930035b6556 | 435 | |
klauss | 105:a930035b6556 | 436 | else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "reset_missed" ) ) { |
klauss | 105:a930035b6556 | 437 | miss_match = false; |
klauss | 105:a930035b6556 | 438 | reset_missed_send_udp_pkg = true; |
klauss | 105:a930035b6556 | 439 | } |
klauss | 105:a930035b6556 | 440 | |
klauss | 105:a930035b6556 | 441 | else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "ftq" ) ) { |
klauss | 100:09a23fcd3bdf | 442 | miss_match = false; |
klauss | 104:62646ef786a3 | 443 | if( debug_uart3 && !( from_eth ) ) pc.printf( "\n\rFTQ ON\n\r" ); |
klauss | 105:a930035b6556 | 444 | send_msg("FTQ On"); |
klauss | 105:a930035b6556 | 445 | /* |
klauss | 105:a930035b6556 | 446 | if( from_eth ) { |
klauss | 105:a930035b6556 | 447 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "FTQ On\n\r" ); |
klauss | 105:a930035b6556 | 448 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 105:a930035b6556 | 449 | } |
klauss | 105:a930035b6556 | 450 | */ |
klauss | 105:a930035b6556 | 451 | big_bug_pkg = true; |
klauss | 100:09a23fcd3bdf | 452 | } |
klauss | 105:a930035b6556 | 453 | |
klauss | 105:a930035b6556 | 454 | else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "ktq" ) ) { |
klauss | 100:09a23fcd3bdf | 455 | miss_match = false; |
klauss | 104:62646ef786a3 | 456 | if( debug_uart3 && !( from_eth ) ) pc.printf( "\n\rFTQ!!!\n\r" ); |
klauss | 105:a930035b6556 | 457 | send_msg("FTQ"); |
klauss | 105:a930035b6556 | 458 | /* |
klauss | 105:a930035b6556 | 459 | if( from_eth ) { |
klauss | 105:a930035b6556 | 460 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "FTQ!!!\n\r" ); |
klauss | 105:a930035b6556 | 461 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 105:a930035b6556 | 462 | } |
klauss | 105:a930035b6556 | 463 | */ |
klauss | 105:a930035b6556 | 464 | flood_bug_pkg = !flood_bug_pkg; |
klauss | 100:09a23fcd3bdf | 465 | } |
klauss | 105:a930035b6556 | 466 | |
klauss | 105:a930035b6556 | 467 | else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "ls" ) ) { |
klauss | 62:07e5bdc9f8f7 | 468 | miss_match = false; |
klauss | 62:07e5bdc9f8f7 | 469 | list = true; |
klauss | 62:07e5bdc9f8f7 | 470 | } |
klauss | 105:a930035b6556 | 471 | |
klauss | 105:a930035b6556 | 472 | else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "ls -l" ) ) { |
klauss | 81:3656f00ab3db | 473 | miss_match = false; |
klauss | 81:3656f00ab3db | 474 | long_list = true; |
klauss | 81:3656f00ab3db | 475 | } |
klauss | 105:a930035b6556 | 476 | |
klauss | 105:a930035b6556 | 477 | else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "tt" ) ) { |
klauss | 53:bb492a8f115a | 478 | miss_match = false; |
klauss | 62:07e5bdc9f8f7 | 479 | main_test = !main_test; |
klauss | 53:bb492a8f115a | 480 | } |
klauss | 105:a930035b6556 | 481 | |
klauss | 105:a930035b6556 | 482 | else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "size" ) ) { |
klauss | 104:62646ef786a3 | 483 | miss_match = false; |
klauss | 104:62646ef786a3 | 484 | sizes = !sizes; |
klauss | 104:62646ef786a3 | 485 | } |
klauss | 105:a930035b6556 | 486 | |
klauss | 105:a930035b6556 | 487 | else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "show_sip" ) ) { |
klauss | 97:8985817e8847 | 488 | miss_match = false; |
klauss | 97:8985817e8847 | 489 | show_sip = true; |
klauss | 97:8985817e8847 | 490 | } |
klauss | 105:a930035b6556 | 491 | |
klauss | 105:a930035b6556 | 492 | else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "reset_cks" ) ) { |
klauss | 52:12930cef17c4 | 493 | miss_match = false; |
klauss | 52:12930cef17c4 | 494 | reset_cks = true; |
klauss | 52:12930cef17c4 | 495 | } |
klauss | 105:a930035b6556 | 496 | |
klauss | 64:5b011d5707d2 | 497 | //replaced by ls |
klauss | 105:a930035b6556 | 498 | else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "status" ) ) { |
klauss | 48:195c97f12e8e | 499 | miss_match = false; |
klauss | 64:5b011d5707d2 | 500 | list = true; |
klauss | 64:5b011d5707d2 | 501 | } |
klauss | 105:a930035b6556 | 502 | |
klauss | 105:a930035b6556 | 503 | else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "wdt" ) ) { |
klauss | 81:3656f00ab3db | 504 | miss_match = false; |
klauss | 81:3656f00ab3db | 505 | debug_wdt = true; |
klauss | 81:3656f00ab3db | 506 | } |
klauss | 105:a930035b6556 | 507 | |
klauss | 105:a930035b6556 | 508 | else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "eth" ) ) { |
klauss | 81:3656f00ab3db | 509 | miss_match = false; |
klauss | 81:3656f00ab3db | 510 | debug_eth = true; |
klauss | 81:3656f00ab3db | 511 | } |
klauss | 105:a930035b6556 | 512 | |
klauss | 105:a930035b6556 | 513 | else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "types" ) ) { |
klauss | 104:62646ef786a3 | 514 | miss_match = false; |
klauss | 105:a930035b6556 | 515 | |
klauss | 105:a930035b6556 | 516 | //send_msg("hex :: 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" ); |
klauss | 105:a930035b6556 | 517 | |
klauss | 104:62646ef786a3 | 518 | if( debug_uart3 && !( from_eth ) ) 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" ); |
klauss | 105:a930035b6556 | 519 | |
klauss | 105:a930035b6556 | 520 | if( from_eth ) { |
klauss | 105:a930035b6556 | 521 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "hex :: 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"); |
klauss | 105:a930035b6556 | 522 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 105:a930035b6556 | 523 | if( tcp_session && !udp_query ) { |
klauss | 105:a930035b6556 | 524 | tcp_client.send_all( debug_buf, strlen( debug_buf ) ); |
klauss | 105:a930035b6556 | 525 | } else if( udp_query ) { |
klauss | 105:a930035b6556 | 526 | udp_query_send_msg( debug_buf ); |
klauss | 105:a930035b6556 | 527 | } |
klauss | 64:5b011d5707d2 | 528 | } |
klauss | 48:195c97f12e8e | 529 | } |
klauss | 105:a930035b6556 | 530 | |
klauss | 105:a930035b6556 | 531 | else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "protocol" ) ) { |
klauss | 64:5b011d5707d2 | 532 | miss_match = false; |
klauss | 105:a930035b6556 | 533 | |
klauss | 105:a930035b6556 | 534 | if( debug_uart3 && !( from_eth ) ) 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" ); |
klauss | 105:a930035b6556 | 535 | |
klauss | 105:a930035b6556 | 536 | if( from_eth ) { |
klauss | 105:a930035b6556 | 537 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "| 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"); |
klauss | 105:a930035b6556 | 538 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 105:a930035b6556 | 539 | if( tcp_session && !udp_query ) { |
klauss | 105:a930035b6556 | 540 | tcp_client.send_all( debug_buf, strlen( debug_buf ) ); |
klauss | 105:a930035b6556 | 541 | } else if( udp_query ) { |
klauss | 105:a930035b6556 | 542 | udp_query_send_msg( debug_buf ); |
klauss | 105:a930035b6556 | 543 | } |
klauss | 64:5b011d5707d2 | 544 | } |
klauss | 64:5b011d5707d2 | 545 | } |
klauss | 105:a930035b6556 | 546 | |
klauss | 105:a930035b6556 | 547 | else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "flood ", 6 ) ) { |
klauss | 105:a930035b6556 | 548 | if (xmemmatch( (uint8_t*)(debug_buf+6), (uint8_t*) "on", 2 ) ) { |
klauss | 45:c80574f24dc3 | 549 | miss_match = false; |
klauss | 104:62646ef786a3 | 550 | if( debug_uart3 && !( from_eth ) ) pc.printf("\n\rFlood ON\n\r"); |
klauss | 105:a930035b6556 | 551 | |
klauss | 105:a930035b6556 | 552 | if( from_eth ) { |
klauss | 105:a930035b6556 | 553 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Flood On\n\r"); |
klauss | 45:c80574f24dc3 | 554 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 105:a930035b6556 | 555 | if( tcp_session && !udp_query ) { |
klauss | 105:a930035b6556 | 556 | tcp_client.send_all( debug_buf, strlen( debug_buf ) ); |
klauss | 105:a930035b6556 | 557 | } else if( udp_query ) { |
klauss | 105:a930035b6556 | 558 | udp_query_send_msg( debug_buf ); |
klauss | 105:a930035b6556 | 559 | } |
klauss | 105:a930035b6556 | 560 | } |
klauss | 45:c80574f24dc3 | 561 | tflood.start(); |
klauss | 45:c80574f24dc3 | 562 | tflood.reset(); |
klauss | 45:c80574f24dc3 | 563 | floodcount =0; |
klauss | 45:c80574f24dc3 | 564 | pflood = 1; |
klauss | 45:c80574f24dc3 | 565 | flood_timeout.start(); |
klauss | 45:c80574f24dc3 | 566 | } |
klauss | 105:a930035b6556 | 567 | |
klauss | 105:a930035b6556 | 568 | if (xmemmatch( (uint8_t*)(debug_buf+6), (uint8_t*) "more", 4 ) ) { |
klauss | 61:06e77dff6f00 | 569 | miss_match = false; |
klauss | 104:62646ef786a3 | 570 | if( debug_uart3 && !( from_eth ) ) pc.printf("\n\rFlood ON\n\r"); |
klauss | 105:a930035b6556 | 571 | if( from_eth ) { |
klauss | 105:a930035b6556 | 572 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Flood On\n\r"); |
klauss | 105:a930035b6556 | 573 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 105:a930035b6556 | 574 | if( tcp_session && !udp_query ) { |
klauss | 105:a930035b6556 | 575 | tcp_client.send_all( debug_buf, strlen( debug_buf ) ); |
klauss | 105:a930035b6556 | 576 | } else if( udp_query ) { |
klauss | 105:a930035b6556 | 577 | udp_query_send_msg( debug_buf ); |
klauss | 105:a930035b6556 | 578 | } |
klauss | 61:06e77dff6f00 | 579 | } |
klauss | 105:a930035b6556 | 580 | |
klauss | 61:06e77dff6f00 | 581 | tflood.start(); |
klauss | 61:06e77dff6f00 | 582 | tflood.reset(); |
klauss | 61:06e77dff6f00 | 583 | floodcount = 0; |
klauss | 61:06e77dff6f00 | 584 | pflood = 1; |
klauss | 61:06e77dff6f00 | 585 | } |
klauss | 105:a930035b6556 | 586 | |
klauss | 60:b4ec6beb3be3 | 587 | if (xmemmatch( (uint8_t*)(debug_buf+6), (uint8_t*) "off", 3 )) { |
klauss | 45:c80574f24dc3 | 588 | miss_match = false; |
klauss | 104:62646ef786a3 | 589 | if( debug_uart3 && !( from_eth ) ) pc.printf("\n\rFlood OFF\n\r"); |
klauss | 105:a930035b6556 | 590 | |
klauss | 105:a930035b6556 | 591 | if( from_eth ) { |
klauss | 105:a930035b6556 | 592 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Flood Off\n\r"); |
klauss | 45:c80574f24dc3 | 593 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 105:a930035b6556 | 594 | if( tcp_session && !udp_query ) { |
klauss | 105:a930035b6556 | 595 | tcp_client.send_all( debug_buf, strlen( debug_buf ) ); |
klauss | 105:a930035b6556 | 596 | } else if( udp_query ) { |
klauss | 105:a930035b6556 | 597 | udp_query_send_msg( debug_buf ); |
klauss | 105:a930035b6556 | 598 | } |
klauss | 42:480335bdde12 | 599 | } |
klauss | 45:c80574f24dc3 | 600 | pflood = 0; |
klauss | 45:c80574f24dc3 | 601 | tflood.stop(); |
klauss | 45:c80574f24dc3 | 602 | flood_timeout.reset(); |
klauss | 31:bb5fb28a77df | 603 | } |
klauss | 105:a930035b6556 | 604 | } else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "silence ", 8 ) ) { |
klauss | 60:b4ec6beb3be3 | 605 | miss_match = false; |
klauss | 60:b4ec6beb3be3 | 606 | char *ref, *split; |
klauss | 105:a930035b6556 | 607 | |
klauss | 60:b4ec6beb3be3 | 608 | strcpy( promptcb_last_cmd, debug_buf ); |
klauss | 105:a930035b6556 | 609 | |
klauss | 105:a930035b6556 | 610 | if( !( strcmp( debug_buf + 8, "-h" ) && strcmp( debug_buf + 8, "--help" ) ) ) { |
klauss | 104:62646ef786a3 | 611 | if( debug_uart3 && !( from_eth ) ) pc.printf("\n\rUsage :: silence start_ext end_ext | start_ext must be greater than end_ext\n\rObs : ( end_ext - start_ext ) < 50 "); |
klauss | 105:a930035b6556 | 612 | |
klauss | 105:a930035b6556 | 613 | if( from_eth ) { |
klauss | 105:a930035b6556 | 614 | snprintf( debug_buf, __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 "); |
klauss | 105:a930035b6556 | 615 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 105:a930035b6556 | 616 | if( tcp_session && !udp_query ) { |
klauss | 105:a930035b6556 | 617 | tcp_client.send_all( debug_buf, strlen( debug_buf ) ); |
klauss | 105:a930035b6556 | 618 | } else if( udp_query ) { |
klauss | 105:a930035b6556 | 619 | udp_query_send_msg( debug_buf ); |
klauss | 105:a930035b6556 | 620 | } |
klauss | 65:0b653cfe95db | 621 | } |
klauss | 105:a930035b6556 | 622 | } else { |
klauss | 65:0b653cfe95db | 623 | ref = debug_buf; |
klauss | 105:a930035b6556 | 624 | |
klauss | 65:0b653cfe95db | 625 | split = strtok( debug_buf + 8, " " ); |
klauss | 105:a930035b6556 | 626 | |
klauss | 65:0b653cfe95db | 627 | start_ext = atoi( split ); |
klauss | 105:a930035b6556 | 628 | |
klauss | 65:0b653cfe95db | 629 | split += strlen( split ) + 1; |
klauss | 105:a930035b6556 | 630 | |
klauss | 65:0b653cfe95db | 631 | end_ext = atoi( split ); |
klauss | 105:a930035b6556 | 632 | |
klauss | 65:0b653cfe95db | 633 | debug_buf = ref; |
klauss | 105:a930035b6556 | 634 | |
klauss | 105:a930035b6556 | 635 | if( start_ext < end_ext && ( end_ext - start_ext ) < 50 ) { |
klauss | 65:0b653cfe95db | 636 | if( start_ext % 2 ) start_ext--; |
klauss | 65:0b653cfe95db | 637 | if( !( end_ext % 2 ) ) end_ext++; |
klauss | 105:a930035b6556 | 638 | |
klauss | 65:0b653cfe95db | 639 | ext_count = start_ext; |
klauss | 65:0b653cfe95db | 640 | flood_silence_timer.start(); |
klauss | 105:a930035b6556 | 641 | } else { |
klauss | 104:62646ef786a3 | 642 | if( debug_uart3 && !( from_eth ) ) 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 "); |
klauss | 105:a930035b6556 | 643 | |
klauss | 105:a930035b6556 | 644 | if( from_eth ) { |
klauss | 105:a930035b6556 | 645 | snprintf( debug_buf, __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 "); |
klauss | 105:a930035b6556 | 646 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 105:a930035b6556 | 647 | if( tcp_session && !udp_query ) { |
klauss | 105:a930035b6556 | 648 | tcp_client.send_all( debug_buf, strlen( debug_buf ) ); |
klauss | 105:a930035b6556 | 649 | } else if( udp_query ) { |
klauss | 105:a930035b6556 | 650 | udp_query_send_msg( debug_buf ); |
klauss | 105:a930035b6556 | 651 | } |
klauss | 65:0b653cfe95db | 652 | } |
klauss | 48:195c97f12e8e | 653 | } |
klauss | 65:0b653cfe95db | 654 | flood_silence = true; |
klauss | 48:195c97f12e8e | 655 | } |
klauss | 45:c80574f24dc3 | 656 | } |
klauss | 105:a930035b6556 | 657 | |
klauss | 105:a930035b6556 | 658 | else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "debug ",6 ) ) { |
klauss | 45:c80574f24dc3 | 659 | if( xmemmatch( (uint8_t*)(debug_buf+6), (uint8_t*) "on",2 )) { |
klauss | 45:c80574f24dc3 | 660 | miss_match = false; |
klauss | 104:62646ef786a3 | 661 | if( debug_uart3 && !( from_eth ) ) pc.printf("\n\rDebug ON\n\r"); |
klauss | 105:a930035b6556 | 662 | if( from_eth ) { |
klauss | 105:a930035b6556 | 663 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Debug On\n\r"); |
klauss | 45:c80574f24dc3 | 664 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 105:a930035b6556 | 665 | if( tcp_session && !udp_query ) { |
klauss | 105:a930035b6556 | 666 | tcp_client.send_all( debug_buf, strlen( debug_buf ) ); |
klauss | 105:a930035b6556 | 667 | } else if( udp_query ) { |
klauss | 105:a930035b6556 | 668 | udp_query_send_msg( debug_buf ); |
klauss | 105:a930035b6556 | 669 | } |
klauss | 45:c80574f24dc3 | 670 | } |
klauss | 78:1353744f01e1 | 671 | debug_alive = true; |
klauss | 45:c80574f24dc3 | 672 | } |
klauss | 45:c80574f24dc3 | 673 | if( xmemmatch( (uint8_t*)(debug_buf+6), (uint8_t*) "off",3 )) { |
klauss | 45:c80574f24dc3 | 674 | miss_match = false; |
klauss | 104:62646ef786a3 | 675 | if( debug_uart3 && !( from_eth ) ) pc.printf("\n\rDebug OFF\n\r"); |
klauss | 105:a930035b6556 | 676 | if( from_eth ) { |
klauss | 105:a930035b6556 | 677 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Debug Off\n\r"); |
klauss | 45:c80574f24dc3 | 678 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 105:a930035b6556 | 679 | if( tcp_session && !udp_query ) { |
klauss | 105:a930035b6556 | 680 | tcp_client.send_all( debug_buf, strlen( debug_buf ) ); |
klauss | 105:a930035b6556 | 681 | } else if( udp_query ) { |
klauss | 105:a930035b6556 | 682 | udp_query_send_msg( debug_buf ); |
klauss | 105:a930035b6556 | 683 | } |
klauss | 42:480335bdde12 | 684 | } |
klauss | 78:1353744f01e1 | 685 | debug_alive = false; |
klauss | 31:bb5fb28a77df | 686 | } |
klauss | 105:a930035b6556 | 687 | if( xmemmatch( (uint8_t*)(debug_buf+6), (uint8_t*) "show",4 ) ) { |
klauss | 45:c80574f24dc3 | 688 | miss_match = false; |
klauss | 104:62646ef786a3 | 689 | if( debug_uart3 && !( from_eth ) ) pc.printf("\n\rdsip"); |
klauss | 104:62646ef786a3 | 690 | if( debug_uart3 && !( from_eth ) ) pc.printf("\n\rdebug_alive"); |
klauss | 104:62646ef786a3 | 691 | if( debug_uart3 && !( from_eth ) ) pc.printf("\n\rdebug_prompt"); |
klauss | 104:62646ef786a3 | 692 | if( debug_uart3 && !( from_eth ) ) pc.printf("\n\rdebug_vector"); |
klauss | 104:62646ef786a3 | 693 | if( debug_uart3 && !( from_eth ) ) pc.printf("\n\rdebug_cb"); |
klauss | 104:62646ef786a3 | 694 | if( debug_uart3 && !( from_eth ) ) pc.printf("\n\rdebug_main"); |
klauss | 104:62646ef786a3 | 695 | if( debug_uart3 && !( from_eth ) ) pc.printf("\n\rdcks"); |
klauss | 104:62646ef786a3 | 696 | if( debug_uart3 && !( from_eth ) ) pc.printf("\n\rdebug_cb_rx"); |
klauss | 104:62646ef786a3 | 697 | if( debug_uart3 && !( from_eth ) ) pc.printf("\n\rdebug_cb_tx*"); |
klauss | 104:62646ef786a3 | 698 | if( debug_uart3 && !( from_eth ) ) pc.printf("\n\rdebug_eth_rx*"); |
klauss | 104:62646ef786a3 | 699 | if( debug_uart3 && !( from_eth ) ) pc.printf("\n\rdebug_eth_tx*"); |
klauss | 104:62646ef786a3 | 700 | if( debug_uart3 && !( from_eth ) ) pc.printf("\n\rdebug_file"); |
klauss | 45:c80574f24dc3 | 701 | |
klauss | 105:a930035b6556 | 702 | if( from_eth ) { |
klauss | 105:a930035b6556 | 703 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "\n\rdsip \n\rdebug_alive \n\rdebug_prompt \n\rdebug_vector \n\rdebug_cb \n\rdebug_main \n\rdcks \n\rdebug_cb_rx \n\rdebug_cb_tx* \n\rdebug_eth_rx* \n\rdebug_eth_tx* \n\rdebug_file\n\r"); |
klauss | 42:480335bdde12 | 704 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 105:a930035b6556 | 705 | if( tcp_session && !udp_query ) { |
klauss | 105:a930035b6556 | 706 | tcp_client.send_all( debug_buf, strlen( debug_buf ) ); |
klauss | 105:a930035b6556 | 707 | } else if( udp_query ) { |
klauss | 105:a930035b6556 | 708 | udp_query_send_msg( debug_buf ); |
klauss | 105:a930035b6556 | 709 | } |
klauss | 42:480335bdde12 | 710 | } |
klauss | 42:480335bdde12 | 711 | } |
klauss | 45:c80574f24dc3 | 712 | } |
klauss | 105:a930035b6556 | 713 | |
klauss | 105:a930035b6556 | 714 | else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "dsip ", 5 ) ) { |
klauss | 105:a930035b6556 | 715 | if (xmemmatch( (uint8_t*)(debug_buf + 5 ), (uint8_t*) "on", 2 ) ) { |
klauss | 45:c80574f24dc3 | 716 | miss_match = false; |
klauss | 104:62646ef786a3 | 717 | if( debug_uart3 && !( from_eth ) ) pc.printf( "\n\rSip Debug ON\n\r" ); |
klauss | 105:a930035b6556 | 718 | if( from_eth ) { |
klauss | 105:a930035b6556 | 719 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Sip Debug On\n\r"); |
klauss | 45:c80574f24dc3 | 720 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 105:a930035b6556 | 721 | if( tcp_session && !udp_query ) { |
klauss | 105:a930035b6556 | 722 | tcp_client.send_all( debug_buf, strlen( debug_buf ) ); |
klauss | 105:a930035b6556 | 723 | } else if( udp_query ) { |
klauss | 105:a930035b6556 | 724 | udp_query_send_msg( debug_buf ); |
klauss | 105:a930035b6556 | 725 | } |
klauss | 45:c80574f24dc3 | 726 | } |
klauss | 78:1353744f01e1 | 727 | debug_sip = true; |
klauss | 45:c80574f24dc3 | 728 | } |
klauss | 50:d9b6577a70f5 | 729 | if (xmemmatch( (uint8_t*)(debug_buf + 5 ), (uint8_t*) "off",3 )) { |
klauss | 45:c80574f24dc3 | 730 | miss_match = false; |
klauss | 104:62646ef786a3 | 731 | if( debug_uart3 && !( from_eth ) ) pc.printf( "\n\rSip Debug OFF\n\r" ); |
klauss | 105:a930035b6556 | 732 | if( from_eth ) { |
klauss | 105:a930035b6556 | 733 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Sip Debug Off\n\r"); |
klauss | 45:c80574f24dc3 | 734 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 105:a930035b6556 | 735 | if( tcp_session && !udp_query ) { |
klauss | 105:a930035b6556 | 736 | tcp_client.send_all( debug_buf, strlen( debug_buf ) ); |
klauss | 105:a930035b6556 | 737 | } else if( udp_query ) { |
klauss | 105:a930035b6556 | 738 | udp_query_send_msg( debug_buf ); |
klauss | 105:a930035b6556 | 739 | } |
klauss | 45:c80574f24dc3 | 740 | } |
klauss | 78:1353744f01e1 | 741 | debug_sip = false; |
klauss | 78:1353744f01e1 | 742 | } |
klauss | 78:1353744f01e1 | 743 | } |
klauss | 78:1353744f01e1 | 744 | |
klauss | 107:cf1e43414adb | 745 | |
klauss | 107:cf1e43414adb | 746 | else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "drtp ", 5 ) ) { |
klauss | 107:cf1e43414adb | 747 | if (xmemmatch( (uint8_t*)(debug_buf + 5 ), (uint8_t*) "on", 2 ) ) { |
klauss | 107:cf1e43414adb | 748 | miss_match = false; |
klauss | 107:cf1e43414adb | 749 | if( debug_uart3 && !( from_eth ) ) pc.printf( "\n\rRtp Debug ON\n\r" ); |
klauss | 107:cf1e43414adb | 750 | if( from_eth ) { |
klauss | 107:cf1e43414adb | 751 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Rtp Debug On\n\r"); |
klauss | 107:cf1e43414adb | 752 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 107:cf1e43414adb | 753 | if( tcp_session && !udp_query ) { |
klauss | 107:cf1e43414adb | 754 | tcp_client.send_all( debug_buf, strlen( debug_buf ) ); |
klauss | 107:cf1e43414adb | 755 | } else if( udp_query ) { |
klauss | 107:cf1e43414adb | 756 | udp_query_send_msg( debug_buf ); |
klauss | 107:cf1e43414adb | 757 | } |
klauss | 107:cf1e43414adb | 758 | } |
klauss | 107:cf1e43414adb | 759 | debug_rtp = true; |
klauss | 107:cf1e43414adb | 760 | } |
klauss | 107:cf1e43414adb | 761 | if (xmemmatch( (uint8_t*)( debug_buf + 5 ), (uint8_t*) "off", 3 ) ){ |
klauss | 107:cf1e43414adb | 762 | miss_match = false; |
klauss | 107:cf1e43414adb | 763 | if( debug_uart3 && !( from_eth ) ) pc.printf( "\n\rRtp Debug OFF\n\r" ); |
klauss | 107:cf1e43414adb | 764 | if( from_eth ) { |
klauss | 107:cf1e43414adb | 765 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Rtp Debug Off\n\r"); |
klauss | 107:cf1e43414adb | 766 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 107:cf1e43414adb | 767 | if( tcp_session && !udp_query ) { |
klauss | 107:cf1e43414adb | 768 | tcp_client.send_all( debug_buf, strlen( debug_buf ) ); |
klauss | 107:cf1e43414adb | 769 | } else if( udp_query ) { |
klauss | 107:cf1e43414adb | 770 | udp_query_send_msg( debug_buf ); |
klauss | 107:cf1e43414adb | 771 | } |
klauss | 107:cf1e43414adb | 772 | } |
klauss | 107:cf1e43414adb | 773 | debug_rtp = false; |
klauss | 107:cf1e43414adb | 774 | } |
klauss | 107:cf1e43414adb | 775 | } |
klauss | 107:cf1e43414adb | 776 | |
klauss | 105:a930035b6556 | 777 | else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "dmissed ", 8 ) ) { |
klauss | 105:a930035b6556 | 778 | if (xmemmatch( (uint8_t*)(debug_buf + 8 ), (uint8_t*) "on", 2 ) ) { |
klauss | 105:a930035b6556 | 779 | miss_match = false; |
klauss | 105:a930035b6556 | 780 | if( debug_uart3 && !( from_eth ) ) pc.printf( "\n\rDebug Missed ON\n\r" ); |
klauss | 105:a930035b6556 | 781 | if( from_eth ) { |
klauss | 105:a930035b6556 | 782 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Debug Missed ON\n\r"); |
klauss | 105:a930035b6556 | 783 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 105:a930035b6556 | 784 | if( tcp_session && !udp_query ) { |
klauss | 105:a930035b6556 | 785 | tcp_client.send_all( debug_buf, strlen( debug_buf ) ); |
klauss | 105:a930035b6556 | 786 | } else if( udp_query ) { |
klauss | 105:a930035b6556 | 787 | udp_query_send_msg( debug_buf ); |
klauss | 105:a930035b6556 | 788 | } |
klauss | 105:a930035b6556 | 789 | } |
klauss | 105:a930035b6556 | 790 | debug_missed = true; |
klauss | 105:a930035b6556 | 791 | } |
klauss | 105:a930035b6556 | 792 | if (xmemmatch( (uint8_t*)(debug_buf + 8 ), (uint8_t*) "off", 3 )) { |
klauss | 105:a930035b6556 | 793 | miss_match = false; |
klauss | 105:a930035b6556 | 794 | if( debug_uart3 && !( from_eth ) ) pc.printf( "\n\rDebug Missed Off\n\r" ); |
klauss | 105:a930035b6556 | 795 | if( from_eth ) { |
klauss | 105:a930035b6556 | 796 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Debug Missed Off\n\r"); |
klauss | 105:a930035b6556 | 797 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 105:a930035b6556 | 798 | if( tcp_session && !udp_query ) { |
klauss | 105:a930035b6556 | 799 | tcp_client.send_all( debug_buf, strlen( debug_buf ) ); |
klauss | 105:a930035b6556 | 800 | } else if( udp_query ) { |
klauss | 105:a930035b6556 | 801 | udp_query_send_msg( debug_buf ); |
klauss | 105:a930035b6556 | 802 | } |
klauss | 105:a930035b6556 | 803 | } |
klauss | 105:a930035b6556 | 804 | debug_missed = false; |
klauss | 105:a930035b6556 | 805 | } |
klauss | 105:a930035b6556 | 806 | } |
klauss | 105:a930035b6556 | 807 | |
klauss | 105:a930035b6556 | 808 | else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "dreconnect ", 11 ) ) { |
klauss | 105:a930035b6556 | 809 | if (xmemmatch( (uint8_t*)(debug_buf + 11 ), (uint8_t*) "on", 2 ) ) { |
klauss | 104:62646ef786a3 | 810 | miss_match = false; |
klauss | 104:62646ef786a3 | 811 | if( debug_uart3 && !( from_eth ) ) pc.printf( "\n\rReconnecet Debug ON\n\r" ); |
klauss | 105:a930035b6556 | 812 | if( from_eth ) { |
klauss | 105:a930035b6556 | 813 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Reconnecet Debug On\n\r"); |
klauss | 104:62646ef786a3 | 814 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 105:a930035b6556 | 815 | if( tcp_session && !udp_query ) { |
klauss | 105:a930035b6556 | 816 | tcp_client.send_all( debug_buf, strlen( debug_buf ) ); |
klauss | 105:a930035b6556 | 817 | } else if( udp_query ) { |
klauss | 105:a930035b6556 | 818 | udp_query_send_msg( debug_buf ); |
klauss | 105:a930035b6556 | 819 | } |
klauss | 104:62646ef786a3 | 820 | } |
klauss | 104:62646ef786a3 | 821 | debug_reconnect = true; |
klauss | 104:62646ef786a3 | 822 | } |
klauss | 104:62646ef786a3 | 823 | if (xmemmatch( (uint8_t*)(debug_buf + 11 ), (uint8_t*) "off", 3 )) { |
klauss | 104:62646ef786a3 | 824 | miss_match = false; |
klauss | 104:62646ef786a3 | 825 | if( debug_uart3 && !( from_eth ) ) pc.printf( "\n\rReconnecet Debug OFF\n\r" ); |
klauss | 105:a930035b6556 | 826 | if( from_eth ) { |
klauss | 105:a930035b6556 | 827 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Reconnecet Debug Off\n\r"); |
klauss | 104:62646ef786a3 | 828 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 105:a930035b6556 | 829 | if( tcp_session && !udp_query ) { |
klauss | 105:a930035b6556 | 830 | tcp_client.send_all( debug_buf, strlen( debug_buf ) ); |
klauss | 105:a930035b6556 | 831 | } else if( udp_query ) { |
klauss | 105:a930035b6556 | 832 | udp_query_send_msg( debug_buf ); |
klauss | 105:a930035b6556 | 833 | } |
klauss | 104:62646ef786a3 | 834 | } |
klauss | 104:62646ef786a3 | 835 | debug_reconnect = false; |
klauss | 104:62646ef786a3 | 836 | } |
klauss | 104:62646ef786a3 | 837 | } |
klauss | 105:a930035b6556 | 838 | |
klauss | 105:a930035b6556 | 839 | else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "duart ", 6 ) ) { |
klauss | 105:a930035b6556 | 840 | if (xmemmatch( (uint8_t*)(debug_buf + 6 ), (uint8_t*) "on", 2 ) ) { |
klauss | 100:09a23fcd3bdf | 841 | miss_match = false; |
klauss | 104:62646ef786a3 | 842 | if( debug_uart3 && !( from_eth ) ) pc.printf( "\n\rEnable UART3 usage\n\r" ); |
klauss | 105:a930035b6556 | 843 | if( from_eth ) { |
klauss | 105:a930035b6556 | 844 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Enable UART3 usage\n\r"); |
klauss | 100:09a23fcd3bdf | 845 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 105:a930035b6556 | 846 | if( tcp_session && !udp_query ) { |
klauss | 105:a930035b6556 | 847 | tcp_client.send_all( debug_buf, strlen( debug_buf ) ); |
klauss | 105:a930035b6556 | 848 | } else if( udp_query ) { |
klauss | 105:a930035b6556 | 849 | udp_query_send_msg( debug_buf ); |
klauss | 105:a930035b6556 | 850 | } |
klauss | 100:09a23fcd3bdf | 851 | } |
klauss | 100:09a23fcd3bdf | 852 | debug_uart3 = true; |
klauss | 100:09a23fcd3bdf | 853 | } |
klauss | 100:09a23fcd3bdf | 854 | if (xmemmatch( (uint8_t*)(debug_buf + 6 ), (uint8_t*) "off",3 )) { |
klauss | 100:09a23fcd3bdf | 855 | miss_match = false; |
klauss | 104:62646ef786a3 | 856 | if( debug_uart3 && !( from_eth ) ) pc.printf( "\n\rDisable UART3 usage\n\r" ); |
klauss | 105:a930035b6556 | 857 | if( from_eth ) { |
klauss | 105:a930035b6556 | 858 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Disable UART3 usage\n\r"); |
klauss | 100:09a23fcd3bdf | 859 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 105:a930035b6556 | 860 | if( tcp_session && !udp_query ) { |
klauss | 105:a930035b6556 | 861 | tcp_client.send_all( debug_buf, strlen( debug_buf ) ); |
klauss | 105:a930035b6556 | 862 | } else if( udp_query ) { |
klauss | 105:a930035b6556 | 863 | udp_query_send_msg( debug_buf ); |
klauss | 105:a930035b6556 | 864 | } |
klauss | 100:09a23fcd3bdf | 865 | } |
klauss | 100:09a23fcd3bdf | 866 | debug_uart3 = false; |
klauss | 100:09a23fcd3bdf | 867 | } |
klauss | 100:09a23fcd3bdf | 868 | } |
klauss | 105:a930035b6556 | 869 | |
klauss | 105:a930035b6556 | 870 | else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "dmatch ", 7 ) ) { |
klauss | 105:a930035b6556 | 871 | if (xmemmatch( (uint8_t*)(debug_buf + 7 ), (uint8_t*) "on", 2 ) ) { |
klauss | 98:43b45f26b430 | 872 | miss_match = false; |
klauss | 104:62646ef786a3 | 873 | if( debug_uart3 && !( from_eth ) ) pc.printf( "\n\rPort Match Debug ON\n\r" ); |
klauss | 105:a930035b6556 | 874 | if( from_eth ) { |
klauss | 105:a930035b6556 | 875 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Port Match Debug On\n\r"); |
klauss | 98:43b45f26b430 | 876 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 105:a930035b6556 | 877 | if( tcp_session && !udp_query ) { |
klauss | 105:a930035b6556 | 878 | tcp_client.send_all( debug_buf, strlen( debug_buf ) ); |
klauss | 105:a930035b6556 | 879 | } else if( udp_query ) { |
klauss | 105:a930035b6556 | 880 | udp_query_send_msg( debug_buf ); |
klauss | 105:a930035b6556 | 881 | } |
klauss | 98:43b45f26b430 | 882 | } |
klauss | 98:43b45f26b430 | 883 | debug_port_match = true; |
klauss | 98:43b45f26b430 | 884 | } |
klauss | 98:43b45f26b430 | 885 | if (xmemmatch( (uint8_t*)(debug_buf + 7 ), (uint8_t*) "off",3 )) { |
klauss | 98:43b45f26b430 | 886 | miss_match = false; |
klauss | 104:62646ef786a3 | 887 | if( debug_uart3 && !( from_eth ) ) pc.printf( "\n\rPort Match Debug OFF\n\r" ); |
klauss | 105:a930035b6556 | 888 | if( from_eth ) { |
klauss | 105:a930035b6556 | 889 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Port Match Debug Off\n\r"); |
klauss | 98:43b45f26b430 | 890 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 105:a930035b6556 | 891 | if( tcp_session && !udp_query ) { |
klauss | 105:a930035b6556 | 892 | tcp_client.send_all( debug_buf, strlen( debug_buf ) ); |
klauss | 105:a930035b6556 | 893 | } else if( udp_query ) { |
klauss | 105:a930035b6556 | 894 | udp_query_send_msg( debug_buf ); |
klauss | 105:a930035b6556 | 895 | } |
klauss | 98:43b45f26b430 | 896 | } |
klauss | 98:43b45f26b430 | 897 | debug_port_match = false; |
klauss | 98:43b45f26b430 | 898 | } |
klauss | 98:43b45f26b430 | 899 | } |
klauss | 105:a930035b6556 | 900 | |
klauss | 105:a930035b6556 | 901 | else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "dmuted ", 7 ) ) { |
klauss | 105:a930035b6556 | 902 | if (xmemmatch( (uint8_t*)(debug_buf + 7 ), (uint8_t*) "on", 2 ) ) { |
klauss | 81:3656f00ab3db | 903 | miss_match = false; |
klauss | 104:62646ef786a3 | 904 | if( debug_uart3 && !( from_eth ) ) pc.printf( "\n\rMuted Debug ON\n\r" ); |
klauss | 105:a930035b6556 | 905 | if( from_eth ) { |
klauss | 105:a930035b6556 | 906 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Muted Debug On\n\r"); |
klauss | 81:3656f00ab3db | 907 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 105:a930035b6556 | 908 | if( tcp_session && !udp_query ) { |
klauss | 105:a930035b6556 | 909 | tcp_client.send_all( debug_buf, strlen( debug_buf ) ); |
klauss | 105:a930035b6556 | 910 | } else if( udp_query ) { |
klauss | 105:a930035b6556 | 911 | udp_query_send_msg( debug_buf ); |
klauss | 105:a930035b6556 | 912 | } |
klauss | 81:3656f00ab3db | 913 | } |
klauss | 81:3656f00ab3db | 914 | debug_muted = true; |
klauss | 81:3656f00ab3db | 915 | } |
klauss | 81:3656f00ab3db | 916 | if (xmemmatch( (uint8_t*)(debug_buf + 7 ), (uint8_t*) "off",3 )) { |
klauss | 81:3656f00ab3db | 917 | miss_match = false; |
klauss | 104:62646ef786a3 | 918 | if( debug_uart3 && !( from_eth ) ) pc.printf( "\n\rMuted Debug OFF\n\r" ); |
klauss | 105:a930035b6556 | 919 | if( from_eth ) { |
klauss | 105:a930035b6556 | 920 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Muted Debug Off\n\r"); |
klauss | 81:3656f00ab3db | 921 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 105:a930035b6556 | 922 | if( tcp_session && !udp_query ) { |
klauss | 105:a930035b6556 | 923 | tcp_client.send_all( debug_buf, strlen( debug_buf ) ); |
klauss | 105:a930035b6556 | 924 | } else if( udp_query ) { |
klauss | 105:a930035b6556 | 925 | udp_query_send_msg( debug_buf ); |
klauss | 105:a930035b6556 | 926 | } |
klauss | 81:3656f00ab3db | 927 | } |
klauss | 81:3656f00ab3db | 928 | debug_muted = false; |
klauss | 81:3656f00ab3db | 929 | } |
klauss | 81:3656f00ab3db | 930 | } |
klauss | 105:a930035b6556 | 931 | |
klauss | 105:a930035b6556 | 932 | else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "dwdt ", 5 ) ) { |
klauss | 105:a930035b6556 | 933 | if (xmemmatch( (uint8_t*)(debug_buf + 5 ), (uint8_t*) "on", 2 ) ) { |
klauss | 81:3656f00ab3db | 934 | miss_match = false; |
klauss | 104:62646ef786a3 | 935 | if( debug_uart3 && !( from_eth ) ) pc.printf( "\n\rWdt Debug ON\n\r" ); |
klauss | 105:a930035b6556 | 936 | if( from_eth ) { |
klauss | 105:a930035b6556 | 937 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Wdt Debug On\n\r"); |
klauss | 81:3656f00ab3db | 938 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 105:a930035b6556 | 939 | if( tcp_session && !udp_query ) { |
klauss | 105:a930035b6556 | 940 | tcp_client.send_all( debug_buf, strlen( debug_buf ) ); |
klauss | 105:a930035b6556 | 941 | } else if( udp_query ) { |
klauss | 105:a930035b6556 | 942 | udp_query_send_msg( debug_buf ); |
klauss | 105:a930035b6556 | 943 | } |
klauss | 81:3656f00ab3db | 944 | } |
klauss | 81:3656f00ab3db | 945 | wdt_show = true; |
klauss | 81:3656f00ab3db | 946 | } |
klauss | 81:3656f00ab3db | 947 | if (xmemmatch( (uint8_t*)(debug_buf + 5 ), (uint8_t*) "off",3 )) { |
klauss | 81:3656f00ab3db | 948 | miss_match = false; |
klauss | 104:62646ef786a3 | 949 | if( debug_uart3 && !( from_eth ) ) pc.printf( "\n\rWdt Debug OFF\n\r" ); |
klauss | 105:a930035b6556 | 950 | if( from_eth ) { |
klauss | 105:a930035b6556 | 951 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Wdt Debug Off\n\r"); |
klauss | 81:3656f00ab3db | 952 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 105:a930035b6556 | 953 | if( tcp_session && !udp_query ) { |
klauss | 105:a930035b6556 | 954 | tcp_client.send_all( debug_buf, strlen( debug_buf ) ); |
klauss | 105:a930035b6556 | 955 | } else if( udp_query ) { |
klauss | 105:a930035b6556 | 956 | udp_query_send_msg( debug_buf ); |
klauss | 105:a930035b6556 | 957 | } |
klauss | 81:3656f00ab3db | 958 | } |
klauss | 81:3656f00ab3db | 959 | wdt_show = false; |
klauss | 81:3656f00ab3db | 960 | } |
klauss | 81:3656f00ab3db | 961 | } |
klauss | 105:a930035b6556 | 962 | |
klauss | 105:a930035b6556 | 963 | else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "drefresh ", 9 ) ) { |
klauss | 105:a930035b6556 | 964 | if (xmemmatch( (uint8_t*)(debug_buf + 9 ), (uint8_t*) "on", 2 ) ) { |
klauss | 81:3656f00ab3db | 965 | miss_match = false; |
klauss | 104:62646ef786a3 | 966 | if( debug_uart3 && !( from_eth ) ) pc.printf( "\n\rRefresh Debug ON\n\r" ); |
klauss | 105:a930035b6556 | 967 | if( from_eth ) { |
klauss | 105:a930035b6556 | 968 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Refresh Debug On\n\r"); |
klauss | 81:3656f00ab3db | 969 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 105:a930035b6556 | 970 | if( tcp_session && !udp_query ) { |
klauss | 105:a930035b6556 | 971 | tcp_client.send_all( debug_buf, strlen( debug_buf ) ); |
klauss | 105:a930035b6556 | 972 | } else if( udp_query ) { |
klauss | 105:a930035b6556 | 973 | udp_query_send_msg( debug_buf ); |
klauss | 105:a930035b6556 | 974 | } |
klauss | 81:3656f00ab3db | 975 | } |
klauss | 81:3656f00ab3db | 976 | debug_refresh= true; |
klauss | 81:3656f00ab3db | 977 | } |
klauss | 81:3656f00ab3db | 978 | if (xmemmatch( (uint8_t*)(debug_buf + 9 ), (uint8_t*) "off",3 )) { |
klauss | 81:3656f00ab3db | 979 | miss_match = false; |
klauss | 104:62646ef786a3 | 980 | if( debug_uart3 && !( from_eth ) ) pc.printf( "\n\rRefresh Debug OFF\n\r" ); |
klauss | 105:a930035b6556 | 981 | if( from_eth ) { |
klauss | 105:a930035b6556 | 982 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Refresh Debug Off\n\r"); |
klauss | 81:3656f00ab3db | 983 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 105:a930035b6556 | 984 | if( tcp_session && !udp_query ) { |
klauss | 105:a930035b6556 | 985 | tcp_client.send_all( debug_buf, strlen( debug_buf ) ); |
klauss | 105:a930035b6556 | 986 | } else if( udp_query ) { |
klauss | 105:a930035b6556 | 987 | udp_query_send_msg( debug_buf ); |
klauss | 105:a930035b6556 | 988 | } |
klauss | 81:3656f00ab3db | 989 | } |
klauss | 81:3656f00ab3db | 990 | debug_refresh = false; |
klauss | 81:3656f00ab3db | 991 | } |
klauss | 81:3656f00ab3db | 992 | } |
klauss | 105:a930035b6556 | 993 | |
klauss | 105:a930035b6556 | 994 | else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "dping ", 6 ) ) { |
klauss | 105:a930035b6556 | 995 | if (xmemmatch( (uint8_t*)(debug_buf + 6 ), (uint8_t*) "on", 2 ) ) { |
klauss | 78:1353744f01e1 | 996 | miss_match = false; |
klauss | 104:62646ef786a3 | 997 | if( debug_uart3 && !( from_eth ) ) pc.printf( "\n\rPing Debug ON\n\r" ); |
klauss | 105:a930035b6556 | 998 | if( from_eth ) { |
klauss | 105:a930035b6556 | 999 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Ping Debug On\n\r"); |
klauss | 78:1353744f01e1 | 1000 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 105:a930035b6556 | 1001 | if( tcp_session && !udp_query ) { |
klauss | 105:a930035b6556 | 1002 | tcp_client.send_all( debug_buf, strlen( debug_buf ) ); |
klauss | 105:a930035b6556 | 1003 | } else if( udp_query ) { |
klauss | 105:a930035b6556 | 1004 | udp_query_send_msg( debug_buf ); |
klauss | 105:a930035b6556 | 1005 | } |
klauss | 78:1353744f01e1 | 1006 | } |
klauss | 78:1353744f01e1 | 1007 | debug_ping = true; |
klauss | 78:1353744f01e1 | 1008 | } |
klauss | 78:1353744f01e1 | 1009 | if (xmemmatch( (uint8_t*)(debug_buf + 6 ), (uint8_t*) "off",3 )) { |
klauss | 78:1353744f01e1 | 1010 | miss_match = false; |
klauss | 104:62646ef786a3 | 1011 | if( debug_uart3 && !( from_eth ) ) pc.printf( "\n\rPing Debug OFF\n\r" ); |
klauss | 105:a930035b6556 | 1012 | if( from_eth ) { |
klauss | 105:a930035b6556 | 1013 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Ping Debug Off\n\r"); |
klauss | 78:1353744f01e1 | 1014 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 105:a930035b6556 | 1015 | if( tcp_session && !udp_query ) { |
klauss | 105:a930035b6556 | 1016 | tcp_client.send_all( debug_buf, strlen( debug_buf ) ); |
klauss | 105:a930035b6556 | 1017 | } else if( udp_query ) { |
klauss | 105:a930035b6556 | 1018 | udp_query_send_msg( debug_buf ); |
klauss | 105:a930035b6556 | 1019 | } |
klauss | 78:1353744f01e1 | 1020 | } |
klauss | 78:1353744f01e1 | 1021 | debug_ping= false; |
klauss | 78:1353744f01e1 | 1022 | } |
klauss | 78:1353744f01e1 | 1023 | } |
klauss | 105:a930035b6556 | 1024 | |
klauss | 105:a930035b6556 | 1025 | else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "dwu ", 4 ) ) { |
klauss | 105:a930035b6556 | 1026 | if (xmemmatch( (uint8_t*)(debug_buf + 4 ), (uint8_t*) "on", 2 ) ) { |
klauss | 78:1353744f01e1 | 1027 | miss_match = false; |
klauss | 104:62646ef786a3 | 1028 | if( debug_uart3 && !( from_eth ) ) pc.printf( "\n\rWake Up Debug ON\n\r" ); |
klauss | 105:a930035b6556 | 1029 | if( from_eth ) { |
klauss | 105:a930035b6556 | 1030 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Wake Up Debug On\n\r"); |
klauss | 78:1353744f01e1 | 1031 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 105:a930035b6556 | 1032 | if( tcp_session && !udp_query ) { |
klauss | 105:a930035b6556 | 1033 | tcp_client.send_all( debug_buf, strlen( debug_buf ) ); |
klauss | 105:a930035b6556 | 1034 | } else if( udp_query ) { |
klauss | 105:a930035b6556 | 1035 | udp_query_send_msg( debug_buf ); |
klauss | 105:a930035b6556 | 1036 | } |
klauss | 78:1353744f01e1 | 1037 | } |
klauss | 78:1353744f01e1 | 1038 | debug_wake = true; |
klauss | 78:1353744f01e1 | 1039 | } |
klauss | 78:1353744f01e1 | 1040 | if (xmemmatch( (uint8_t*)(debug_buf + 4 ), (uint8_t*) "off",3 )) { |
klauss | 78:1353744f01e1 | 1041 | miss_match = false; |
klauss | 104:62646ef786a3 | 1042 | if( debug_uart3 && !( from_eth ) ) pc.printf( "\n\rWake Up Debug OFF\n\r" ); |
klauss | 105:a930035b6556 | 1043 | if( from_eth ) { |
klauss | 105:a930035b6556 | 1044 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Wake Up Debug Off\n\r"); |
klauss | 78:1353744f01e1 | 1045 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 105:a930035b6556 | 1046 | if( tcp_session && !udp_query ) { |
klauss | 105:a930035b6556 | 1047 | tcp_client.send_all( debug_buf, strlen( debug_buf ) ); |
klauss | 105:a930035b6556 | 1048 | } else if( udp_query ) { |
klauss | 105:a930035b6556 | 1049 | udp_query_send_msg( debug_buf ); |
klauss | 105:a930035b6556 | 1050 | } |
klauss | 78:1353744f01e1 | 1051 | } |
klauss | 78:1353744f01e1 | 1052 | debug_wake = false; |
klauss | 78:1353744f01e1 | 1053 | } |
klauss | 78:1353744f01e1 | 1054 | } |
klauss | 105:a930035b6556 | 1055 | |
klauss | 105:a930035b6556 | 1056 | else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "tcp_alive ", 10 ) ) { |
klauss | 105:a930035b6556 | 1057 | if (xmemmatch( (uint8_t*)(debug_buf + 10 ), (uint8_t*) "on", 2 ) ) { |
klauss | 78:1353744f01e1 | 1058 | miss_match = false; |
klauss | 104:62646ef786a3 | 1059 | if( debug_uart3 && !( from_eth ) ) pc.printf( "\n\rTCP don't drop mode on\n\r" ); |
klauss | 105:a930035b6556 | 1060 | if( from_eth ) { |
klauss | 105:a930035b6556 | 1061 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "TCP don't drop mode on\n\r"); |
klauss | 78:1353744f01e1 | 1062 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 105:a930035b6556 | 1063 | if( tcp_session && !udp_query ) { |
klauss | 105:a930035b6556 | 1064 | tcp_client.send_all( debug_buf, strlen( debug_buf ) ); |
klauss | 105:a930035b6556 | 1065 | } else if( udp_query ) { |
klauss | 105:a930035b6556 | 1066 | udp_query_send_msg( debug_buf ); |
klauss | 105:a930035b6556 | 1067 | } |
klauss | 78:1353744f01e1 | 1068 | } |
klauss | 78:1353744f01e1 | 1069 | tcp_alive = true; |
klauss | 78:1353744f01e1 | 1070 | } |
klauss | 78:1353744f01e1 | 1071 | if (xmemmatch( (uint8_t*)(debug_buf + 10 ), (uint8_t*) "off",3 )) { |
klauss | 78:1353744f01e1 | 1072 | miss_match = false; |
klauss | 104:62646ef786a3 | 1073 | if( debug_uart3 && !( from_eth ) ) pc.printf( "\n\rTCP don't drop mode off\n\r" ); |
klauss | 105:a930035b6556 | 1074 | if( from_eth ) { |
klauss | 105:a930035b6556 | 1075 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "TCP don't drop mode off\n\r"); |
klauss | 78:1353744f01e1 | 1076 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 105:a930035b6556 | 1077 | if( tcp_session && !udp_query ) { |
klauss | 105:a930035b6556 | 1078 | tcp_client.send_all( debug_buf, strlen( debug_buf ) ); |
klauss | 105:a930035b6556 | 1079 | } else if( udp_query ) { |
klauss | 105:a930035b6556 | 1080 | udp_query_send_msg( debug_buf ); |
klauss | 105:a930035b6556 | 1081 | } |
klauss | 78:1353744f01e1 | 1082 | } |
klauss | 78:1353744f01e1 | 1083 | tcp_alive = false; |
klauss | 78:1353744f01e1 | 1084 | } |
klauss | 78:1353744f01e1 | 1085 | } |
klauss | 105:a930035b6556 | 1086 | |
klauss | 105:a930035b6556 | 1087 | else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "daging ",7 ) ) { |
klauss | 105:a930035b6556 | 1088 | if (xmemmatch( (uint8_t*)(debug_buf + 7 ), (uint8_t*) "on", 2 ) ) { |
klauss | 78:1353744f01e1 | 1089 | miss_match = false; |
klauss | 104:62646ef786a3 | 1090 | if( debug_uart3 && !( from_eth ) ) pc.printf( "\n\rAging Debug ON\n\r" ); |
klauss | 105:a930035b6556 | 1091 | if( from_eth ) { |
klauss | 105:a930035b6556 | 1092 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Aging Debug On\n\r"); |
klauss | 78:1353744f01e1 | 1093 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 105:a930035b6556 | 1094 | if( tcp_session && !udp_query ) { |
klauss | 105:a930035b6556 | 1095 | tcp_client.send_all( debug_buf, strlen( debug_buf ) ); |
klauss | 105:a930035b6556 | 1096 | } else if( udp_query ) { |
klauss | 105:a930035b6556 | 1097 | udp_query_send_msg( debug_buf ); |
klauss | 105:a930035b6556 | 1098 | } |
klauss | 78:1353744f01e1 | 1099 | } |
klauss | 78:1353744f01e1 | 1100 | debug_aging = true; |
klauss | 78:1353744f01e1 | 1101 | } |
klauss | 78:1353744f01e1 | 1102 | if (xmemmatch( (uint8_t*)(debug_buf + 7 ), (uint8_t*) "off",3 )) { |
klauss | 78:1353744f01e1 | 1103 | miss_match = false; |
klauss | 104:62646ef786a3 | 1104 | if( debug_uart3 && !( from_eth ) ) pc.printf( "\n\rAging Debug OFF\n\r" ); |
klauss | 105:a930035b6556 | 1105 | if( from_eth ) { |
klauss | 105:a930035b6556 | 1106 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Aging Debug Off\n\r"); |
klauss | 78:1353744f01e1 | 1107 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 105:a930035b6556 | 1108 | if( tcp_session && !udp_query ) { |
klauss | 105:a930035b6556 | 1109 | tcp_client.send_all( debug_buf, strlen( debug_buf ) ); |
klauss | 105:a930035b6556 | 1110 | } else if( udp_query ) { |
klauss | 105:a930035b6556 | 1111 | udp_query_send_msg( debug_buf ); |
klauss | 105:a930035b6556 | 1112 | } |
klauss | 78:1353744f01e1 | 1113 | } |
klauss | 78:1353744f01e1 | 1114 | debug_aging = false; |
klauss | 78:1353744f01e1 | 1115 | } |
klauss | 78:1353744f01e1 | 1116 | } |
klauss | 105:a930035b6556 | 1117 | |
klauss | 105:a930035b6556 | 1118 | else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "dcpld ", 6 ) ) { |
klauss | 105:a930035b6556 | 1119 | if (xmemmatch( (uint8_t*)(debug_buf + 6 ), (uint8_t*) "on", 2 ) ) { |
klauss | 78:1353744f01e1 | 1120 | miss_match = false; |
klauss | 104:62646ef786a3 | 1121 | if( debug_uart3 && !( from_eth ) ) pc.printf( "\n\rDCPLD Debug ON\n\r" ); |
klauss | 105:a930035b6556 | 1122 | if( from_eth ) { |
klauss | 105:a930035b6556 | 1123 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "DCPLD Debug On\n\r"); |
klauss | 78:1353744f01e1 | 1124 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 105:a930035b6556 | 1125 | if( tcp_session && !udp_query ) { |
klauss | 105:a930035b6556 | 1126 | tcp_client.send_all( debug_buf, strlen( debug_buf ) ); |
klauss | 105:a930035b6556 | 1127 | } else if( udp_query ) { |
klauss | 105:a930035b6556 | 1128 | udp_query_send_msg( debug_buf ); |
klauss | 105:a930035b6556 | 1129 | } |
klauss | 78:1353744f01e1 | 1130 | } |
klauss | 78:1353744f01e1 | 1131 | debug_cpld = true; |
klauss | 105:a930035b6556 | 1132 | debug_cb_rx = true; |
klauss | 105:a930035b6556 | 1133 | debug_cb_tx = true; |
klauss | 78:1353744f01e1 | 1134 | } |
klauss | 105:a930035b6556 | 1135 | if (xmemmatch( (uint8_t*)(debug_buf + 6 ), (uint8_t*) "off",3 ) ) { |
klauss | 78:1353744f01e1 | 1136 | miss_match = false; |
klauss | 104:62646ef786a3 | 1137 | if( debug_uart3 && !( from_eth ) ) pc.printf( "\n\rDCPLD Debug OFF\n\r" ); |
klauss | 105:a930035b6556 | 1138 | if( from_eth ) { |
klauss | 105:a930035b6556 | 1139 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "DCPLD Debug Off\n\r"); |
klauss | 78:1353744f01e1 | 1140 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 105:a930035b6556 | 1141 | if( tcp_session && !udp_query ) { |
klauss | 105:a930035b6556 | 1142 | tcp_client.send_all( debug_buf, strlen( debug_buf ) ); |
klauss | 105:a930035b6556 | 1143 | } else if( udp_query ) { |
klauss | 105:a930035b6556 | 1144 | udp_query_send_msg( debug_buf ); |
klauss | 105:a930035b6556 | 1145 | } |
klauss | 78:1353744f01e1 | 1146 | } |
klauss | 78:1353744f01e1 | 1147 | debug_cpld = false; |
klauss | 105:a930035b6556 | 1148 | debug_cb_rx = false; |
klauss | 105:a930035b6556 | 1149 | debug_cb_tx = false; |
klauss | 78:1353744f01e1 | 1150 | } |
klauss | 78:1353744f01e1 | 1151 | } |
klauss | 78:1353744f01e1 | 1152 | |
klauss | 105:a930035b6556 | 1153 | else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "dshowcpld ", 10 ) ) { |
klauss | 105:a930035b6556 | 1154 | if (xmemmatch( (uint8_t*)(debug_buf + 10 ), (uint8_t*) "on", 2 ) ) { |
klauss | 105:a930035b6556 | 1155 | miss_match = false; |
klauss | 105:a930035b6556 | 1156 | if( debug_uart3 && !( from_eth ) ) pc.printf( "\n\rDCPLD Show Debug ON\n\r" ); |
klauss | 105:a930035b6556 | 1157 | if( from_eth ) { |
klauss | 105:a930035b6556 | 1158 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "DCPLD Show Debug On\n\r"); |
klauss | 105:a930035b6556 | 1159 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 105:a930035b6556 | 1160 | if( tcp_session && !udp_query ) { |
klauss | 105:a930035b6556 | 1161 | tcp_client.send_all( debug_buf, strlen( debug_buf ) ); |
klauss | 105:a930035b6556 | 1162 | } else if( udp_query ) { |
klauss | 105:a930035b6556 | 1163 | udp_query_send_msg( debug_buf ); |
klauss | 105:a930035b6556 | 1164 | } |
klauss | 105:a930035b6556 | 1165 | } |
klauss | 105:a930035b6556 | 1166 | debug_show_cpld = true; |
klauss | 105:a930035b6556 | 1167 | } |
klauss | 105:a930035b6556 | 1168 | if (xmemmatch( (uint8_t*)(debug_buf + 10 ), (uint8_t*) "off",3 ) ) { |
klauss | 105:a930035b6556 | 1169 | miss_match = false; |
klauss | 105:a930035b6556 | 1170 | if( debug_uart3 && !( from_eth ) ) pc.printf( "\n\rDCPLD Show Debug OFF\n\r" ); |
klauss | 105:a930035b6556 | 1171 | if( from_eth ) { |
klauss | 105:a930035b6556 | 1172 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "DCPLD Show Debug Off\n\r"); |
klauss | 105:a930035b6556 | 1173 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 105:a930035b6556 | 1174 | if( tcp_session && !udp_query ) { |
klauss | 105:a930035b6556 | 1175 | tcp_client.send_all( debug_buf, strlen( debug_buf ) ); |
klauss | 105:a930035b6556 | 1176 | } else if( udp_query ) { |
klauss | 105:a930035b6556 | 1177 | udp_query_send_msg( debug_buf ); |
klauss | 105:a930035b6556 | 1178 | } |
klauss | 105:a930035b6556 | 1179 | } |
klauss | 105:a930035b6556 | 1180 | debug_show_cpld = false; |
klauss | 105:a930035b6556 | 1181 | } |
klauss | 105:a930035b6556 | 1182 | } |
klauss | 105:a930035b6556 | 1183 | |
klauss | 105:a930035b6556 | 1184 | else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "dcks_err ", 9 ) ) { |
klauss | 105:a930035b6556 | 1185 | if (xmemmatch( (uint8_t*)(debug_buf + 9 ), (uint8_t*) "on", 2 ) ) { |
klauss | 78:1353744f01e1 | 1186 | miss_match = false; |
klauss | 104:62646ef786a3 | 1187 | if( debug_uart3 && !( from_eth ) ) pc.printf( "\n\rCKS_ERR Debug ON\n\r" ); |
klauss | 105:a930035b6556 | 1188 | if( from_eth ) { |
klauss | 105:a930035b6556 | 1189 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "CKS_ERR Debug On\n\r"); |
klauss | 78:1353744f01e1 | 1190 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 105:a930035b6556 | 1191 | if( tcp_session && !udp_query ) { |
klauss | 105:a930035b6556 | 1192 | tcp_client.send_all( debug_buf, strlen( debug_buf ) ); |
klauss | 105:a930035b6556 | 1193 | } else if( udp_query ) { |
klauss | 105:a930035b6556 | 1194 | udp_query_send_msg( debug_buf ); |
klauss | 105:a930035b6556 | 1195 | } |
klauss | 78:1353744f01e1 | 1196 | } |
klauss | 78:1353744f01e1 | 1197 | debug_cks_err = true; |
klauss | 78:1353744f01e1 | 1198 | } |
klauss | 105:a930035b6556 | 1199 | if (xmemmatch( (uint8_t*)(debug_buf + 9 ), (uint8_t*) "off", 3 ) ) { |
klauss | 78:1353744f01e1 | 1200 | miss_match = false; |
klauss | 104:62646ef786a3 | 1201 | if( debug_uart3 && !( from_eth ) ) pc.printf( "\n\rCKS_ERR Debug OFF\n\r" ); |
klauss | 105:a930035b6556 | 1202 | if( from_eth ) { |
klauss | 105:a930035b6556 | 1203 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "CKS_ERR Debug off\n\r"); |
klauss | 78:1353744f01e1 | 1204 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 105:a930035b6556 | 1205 | if( tcp_session && !udp_query ) { |
klauss | 105:a930035b6556 | 1206 | tcp_client.send_all( debug_buf, strlen( debug_buf ) ); |
klauss | 105:a930035b6556 | 1207 | } else if( udp_query ) { |
klauss | 105:a930035b6556 | 1208 | udp_query_send_msg( debug_buf ); |
klauss | 105:a930035b6556 | 1209 | } |
klauss | 78:1353744f01e1 | 1210 | } |
klauss | 78:1353744f01e1 | 1211 | debug_cks_err = false; |
klauss | 78:1353744f01e1 | 1212 | } |
klauss | 78:1353744f01e1 | 1213 | } |
klauss | 105:a930035b6556 | 1214 | |
klauss | 105:a930035b6556 | 1215 | else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "dinvite ", 8 ) ) { |
klauss | 105:a930035b6556 | 1216 | if( xmemmatch( (uint8_t*)(debug_buf + 8 ), (uint8_t*) "on", 2 ) ) { |
klauss | 78:1353744f01e1 | 1217 | miss_match = false; |
klauss | 104:62646ef786a3 | 1218 | if( debug_uart3 && !( from_eth ) ) pc.printf( "\n\rInvite Debug ON\n\r" ); |
klauss | 105:a930035b6556 | 1219 | if( from_eth ) { |
klauss | 105:a930035b6556 | 1220 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Invite Debug On\n\r"); |
klauss | 78:1353744f01e1 | 1221 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 105:a930035b6556 | 1222 | if( tcp_session && !udp_query ) { |
klauss | 105:a930035b6556 | 1223 | tcp_client.send_all( debug_buf, strlen( debug_buf ) ); |
klauss | 105:a930035b6556 | 1224 | } else if( udp_query ) { |
klauss | 105:a930035b6556 | 1225 | udp_query_send_msg( debug_buf ); |
klauss | 105:a930035b6556 | 1226 | } |
klauss | 78:1353744f01e1 | 1227 | } |
klauss | 81:3656f00ab3db | 1228 | debug_invite = true; |
klauss | 78:1353744f01e1 | 1229 | } |
klauss | 78:1353744f01e1 | 1230 | if( xmemmatch( (uint8_t*)(debug_buf + 8 ), (uint8_t*) "off",3 )) { |
klauss | 78:1353744f01e1 | 1231 | miss_match = false; |
klauss | 104:62646ef786a3 | 1232 | if( debug_uart3 && !( from_eth ) ) pc.printf( "\n\rInvite Debug OFF\n\r" ); |
klauss | 105:a930035b6556 | 1233 | if( from_eth ) { |
klauss | 105:a930035b6556 | 1234 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Invite Debug Off\n\r"); |
klauss | 78:1353744f01e1 | 1235 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 105:a930035b6556 | 1236 | if( tcp_session && !udp_query ) { |
klauss | 105:a930035b6556 | 1237 | tcp_client.send_all( debug_buf, strlen( debug_buf ) ); |
klauss | 105:a930035b6556 | 1238 | } else if( udp_query ) { |
klauss | 105:a930035b6556 | 1239 | udp_query_send_msg( debug_buf ); |
klauss | 105:a930035b6556 | 1240 | } |
klauss | 78:1353744f01e1 | 1241 | } |
klauss | 78:1353744f01e1 | 1242 | debug_invite = 0; |
klauss | 45:c80574f24dc3 | 1243 | } |
klauss | 45:c80574f24dc3 | 1244 | } |
klauss | 105:a930035b6556 | 1245 | |
klauss | 105:a930035b6556 | 1246 | else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "dparallel ", 10 ) ) { |
klauss | 105:a930035b6556 | 1247 | if( xmemmatch( ( uint8_t * )( debug_buf + 10 ), ( uint8_t * )"on", 2 ) ) { |
klauss | 72:895ca792c647 | 1248 | miss_match = false; |
klauss | 104:62646ef786a3 | 1249 | if( debug_uart3 && !( from_eth ) ) pc.printf( "\n\rParallel Write Debug ON\n\r" ); |
klauss | 105:a930035b6556 | 1250 | if( from_eth ) { |
klauss | 105:a930035b6556 | 1251 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "\n\rParallel Write Debug ON\n\r"); |
klauss | 72:895ca792c647 | 1252 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 105:a930035b6556 | 1253 | if( tcp_session && !udp_query ) { |
klauss | 105:a930035b6556 | 1254 | tcp_client.send_all( debug_buf, strlen( debug_buf ) ); |
klauss | 105:a930035b6556 | 1255 | } else if( udp_query ) { |
klauss | 105:a930035b6556 | 1256 | udp_query_send_msg( debug_buf ); |
klauss | 105:a930035b6556 | 1257 | } |
klauss | 72:895ca792c647 | 1258 | } |
klauss | 72:895ca792c647 | 1259 | dparallel = true; |
klauss | 72:895ca792c647 | 1260 | } |
klauss | 72:895ca792c647 | 1261 | if( xmemmatch( ( uint8_t * )( debug_buf + 10 ), ( uint8_t *)"off", 3 )) { |
klauss | 72:895ca792c647 | 1262 | miss_match = false; |
klauss | 104:62646ef786a3 | 1263 | if( debug_uart3 && !( from_eth ) ) pc.printf( "\n\rParallel Write Debug OFF\n\r" ); |
klauss | 105:a930035b6556 | 1264 | if( from_eth ) { |
klauss | 105:a930035b6556 | 1265 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "\n\rParallel Write Debug Off\n\r"); |
klauss | 72:895ca792c647 | 1266 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 105:a930035b6556 | 1267 | if( tcp_session && !udp_query ) { |
klauss | 105:a930035b6556 | 1268 | tcp_client.send_all( debug_buf, strlen( debug_buf ) ); |
klauss | 105:a930035b6556 | 1269 | } else if( udp_query ) { |
klauss | 105:a930035b6556 | 1270 | udp_query_send_msg( debug_buf ); |
klauss | 105:a930035b6556 | 1271 | } |
klauss | 72:895ca792c647 | 1272 | } |
klauss | 72:895ca792c647 | 1273 | dparallel = false; |
klauss | 72:895ca792c647 | 1274 | } |
klauss | 72:895ca792c647 | 1275 | } |
klauss | 105:a930035b6556 | 1276 | |
klauss | 105:a930035b6556 | 1277 | else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "dtelos ", 7 ) ) { |
klauss | 105:a930035b6556 | 1278 | if (xmemmatch( (uint8_t*)( debug_buf + 7 ), (uint8_t*) "on", 2 ) ) { |
klauss | 53:bb492a8f115a | 1279 | miss_match = false; |
klauss | 104:62646ef786a3 | 1280 | if( debug_uart3 && !( from_eth ) ) pc.printf( "\n\rTelemetry Debug ON\n\r" ); |
klauss | 105:a930035b6556 | 1281 | if( from_eth ) { |
klauss | 105:a930035b6556 | 1282 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "\n\rTelemetry Debug On\n\r"); |
klauss | 53:bb492a8f115a | 1283 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 105:a930035b6556 | 1284 | if( tcp_session && !udp_query ) { |
klauss | 105:a930035b6556 | 1285 | tcp_client.send_all( debug_buf, strlen( debug_buf ) ); |
klauss | 105:a930035b6556 | 1286 | } else if( udp_query ) { |
klauss | 105:a930035b6556 | 1287 | udp_query_send_msg( debug_buf ); |
klauss | 105:a930035b6556 | 1288 | } |
klauss | 53:bb492a8f115a | 1289 | } |
klauss | 53:bb492a8f115a | 1290 | debug_telemetry = true; |
klauss | 53:bb492a8f115a | 1291 | } |
klauss | 78:1353744f01e1 | 1292 | if (xmemmatch( (uint8_t*)(debug_buf + 7 ), (uint8_t*) "off", 3 )) { |
klauss | 53:bb492a8f115a | 1293 | miss_match = false; |
klauss | 104:62646ef786a3 | 1294 | if( debug_uart3 && !( from_eth ) ) pc.printf( "\n\rTelemetry Debug OFF\n\r" ); |
klauss | 105:a930035b6556 | 1295 | if( from_eth ) { |
klauss | 105:a930035b6556 | 1296 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "\n\rTelemetry Debug Off\n\r"); |
klauss | 53:bb492a8f115a | 1297 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 105:a930035b6556 | 1298 | if( tcp_session && !udp_query ) { |
klauss | 105:a930035b6556 | 1299 | tcp_client.send_all( debug_buf, strlen( debug_buf ) ); |
klauss | 105:a930035b6556 | 1300 | } else if( udp_query ) { |
klauss | 105:a930035b6556 | 1301 | udp_query_send_msg( debug_buf ); |
klauss | 105:a930035b6556 | 1302 | } |
klauss | 53:bb492a8f115a | 1303 | } |
klauss | 53:bb492a8f115a | 1304 | debug_telemetry = false; |
klauss | 53:bb492a8f115a | 1305 | } |
klauss | 53:bb492a8f115a | 1306 | } |
klauss | 105:a930035b6556 | 1307 | |
klauss | 105:a930035b6556 | 1308 | else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "dcks ", 5 ) ) { |
klauss | 105:a930035b6556 | 1309 | if (xmemmatch( (uint8_t*)(debug_buf + 5 ), (uint8_t*) "on",2 ) ) { |
klauss | 45:c80574f24dc3 | 1310 | miss_match = false; |
klauss | 104:62646ef786a3 | 1311 | if( debug_uart3 && !( from_eth ) ) pc.printf( "\n\rCKS Debug ON\n\r" ); |
klauss | 105:a930035b6556 | 1312 | if( from_eth ) { |
klauss | 105:a930035b6556 | 1313 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "CKS Debug On\n\r"); |
klauss | 45:c80574f24dc3 | 1314 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 105:a930035b6556 | 1315 | if( tcp_session && !udp_query ) { |
klauss | 105:a930035b6556 | 1316 | tcp_client.send_all( debug_buf, strlen( debug_buf ) ); |
klauss | 105:a930035b6556 | 1317 | } else if( udp_query ) { |
klauss | 105:a930035b6556 | 1318 | udp_query_send_msg( debug_buf ); |
klauss | 105:a930035b6556 | 1319 | } |
klauss | 45:c80574f24dc3 | 1320 | } |
klauss | 78:1353744f01e1 | 1321 | debug_cks = true; |
klauss | 45:c80574f24dc3 | 1322 | } |
klauss | 50:d9b6577a70f5 | 1323 | if (xmemmatch( (uint8_t*)(debug_buf + 5 ), (uint8_t*) "off",3 )) { |
klauss | 45:c80574f24dc3 | 1324 | miss_match = false; |
klauss | 104:62646ef786a3 | 1325 | if( debug_uart3 && !( from_eth ) ) pc.printf( "\n\rCKS Debug OFF\n\r" ); |
klauss | 105:a930035b6556 | 1326 | if( from_eth ) { |
klauss | 105:a930035b6556 | 1327 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "CKS Debug Off\n\r"); |
klauss | 45:c80574f24dc3 | 1328 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 105:a930035b6556 | 1329 | if( tcp_session && !udp_query ) { |
klauss | 105:a930035b6556 | 1330 | tcp_client.send_all( debug_buf, strlen( debug_buf ) ); |
klauss | 105:a930035b6556 | 1331 | } else if( udp_query ) { |
klauss | 105:a930035b6556 | 1332 | udp_query_send_msg( debug_buf ); |
klauss | 105:a930035b6556 | 1333 | } |
klauss | 45:c80574f24dc3 | 1334 | } |
klauss | 78:1353744f01e1 | 1335 | debug_cks = false; |
klauss | 45:c80574f24dc3 | 1336 | } |
klauss | 45:c80574f24dc3 | 1337 | } |
klauss | 105:a930035b6556 | 1338 | |
klauss | 105:a930035b6556 | 1339 | else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "promptcb ", 9 ) ) { |
klauss | 78:1353744f01e1 | 1340 | miss_match = false; |
klauss | 105:a930035b6556 | 1341 | uint8_t write_buffer[ CB_BUFFER_SIZE ]; |
klauss | 78:1353744f01e1 | 1342 | int ext,port; |
klauss | 78:1353744f01e1 | 1343 | char *split, *ref, *cmd; |
klauss | 105:a930035b6556 | 1344 | |
klauss | 78:1353744f01e1 | 1345 | ref = debug_buf; |
klauss | 105:a930035b6556 | 1346 | |
klauss | 78:1353744f01e1 | 1347 | strcat( debug_buf, "\r" ); |
klauss | 105:a930035b6556 | 1348 | |
klauss | 78:1353744f01e1 | 1349 | split = strtok( debug_buf + 9, " " ); |
klauss | 78:1353744f01e1 | 1350 | ext = atoi( split ); |
klauss | 78:1353744f01e1 | 1351 | split = strtok( NULL, " " ); |
klauss | 78:1353744f01e1 | 1352 | port = atoi( split ); |
klauss | 78:1353744f01e1 | 1353 | split += strlen( split ) + 1; |
klauss | 78:1353744f01e1 | 1354 | cmd = split; |
klauss | 105:a930035b6556 | 1355 | |
klauss | 78:1353744f01e1 | 1356 | promptcb_last_ext = ext; |
klauss | 78:1353744f01e1 | 1357 | promptcb_last_port = port; |
klauss | 105:a930035b6556 | 1358 | |
klauss | 78:1353744f01e1 | 1359 | strcpy( promptcb_last_cmd, cmd ); |
klauss | 78:1353744f01e1 | 1360 | strcat( cmd, "\r\r\r\n" ); |
klauss | 105:a930035b6556 | 1361 | |
klauss | 104:62646ef786a3 | 1362 | if( debug_uart3 && !( from_eth ) ) pc.printf("\r\next=%d port=%d cmd=%s", ext, port, cmd ); |
klauss | 105:a930035b6556 | 1363 | send2callboxes( build_cb_package( ext, port, __PROMPT__, cmd, id_msg++, CB_BUFFER_SIZE - __VZ_HEADER_OFFSET__, write_buffer ) ); |
klauss | 104:62646ef786a3 | 1364 | if( debug_uart3 && !( from_eth ) ) pc.printf("\n\rComando enviado"); |
klauss | 105:a930035b6556 | 1365 | |
klauss | 105:a930035b6556 | 1366 | if( from_eth ) { |
klauss | 78:1353744f01e1 | 1367 | char eth_msg[ 512 ]; |
klauss | 78:1353744f01e1 | 1368 | snprintf( eth_msg, 512 - 1, "\r\next=%d port=%d cmd=%s\r\nComando enviado\n\r", ext, port, cmd ); |
klauss | 105:a930035b6556 | 1369 | if( tcp_session && !udp_query ) { |
klauss | 78:1353744f01e1 | 1370 | tcp_client.send_all( eth_msg, strlen( eth_msg ) ); |
klauss | 105:a930035b6556 | 1371 | } else if( udp_query ) { |
klauss | 105:a930035b6556 | 1372 | udp_query_send_msg( eth_msg ); |
klauss | 78:1353744f01e1 | 1373 | } |
klauss | 78:1353744f01e1 | 1374 | } |
klauss | 105:a930035b6556 | 1375 | |
klauss | 78:1353744f01e1 | 1376 | debug_buf = ref; |
klauss | 78:1353744f01e1 | 1377 | bufptr = 0; |
klauss | 104:62646ef786a3 | 1378 | for( register int i = 0; i < DEBUGBUFSIZE; i++ ) debug_buf[ i ] = 0; |
klauss | 78:1353744f01e1 | 1379 | } |
klauss | 105:a930035b6556 | 1380 | |
klauss | 105:a930035b6556 | 1381 | else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "bye ", 4 ) ) { |
klauss | 92:92df17f538a8 | 1382 | miss_match = false; |
klauss | 92:92df17f538a8 | 1383 | int ext,port; |
klauss | 92:92df17f538a8 | 1384 | char *split, *ref; |
klauss | 105:a930035b6556 | 1385 | uint8_t write_buffer[ CB_BUFFER_SIZE ], data[ CB_BUFFER_SIZE ]; |
klauss | 105:a930035b6556 | 1386 | |
klauss | 92:92df17f538a8 | 1387 | ref = debug_buf; |
klauss | 105:a930035b6556 | 1388 | |
klauss | 92:92df17f538a8 | 1389 | strcat( debug_buf, "\r\r\r\n" ); |
klauss | 105:a930035b6556 | 1390 | |
klauss | 92:92df17f538a8 | 1391 | split = strtok( debug_buf + 4, " " ); |
klauss | 92:92df17f538a8 | 1392 | ext = atoi( split ); |
klauss | 92:92df17f538a8 | 1393 | port = convert_ext_to_port( ext ); |
klauss | 105:a930035b6556 | 1394 | |
klauss | 104:62646ef786a3 | 1395 | if( debug_uart3 && !( from_eth ) ) pc.printf("\r\next=%d port=%d request bye", ext, port ); |
klauss | 105:a930035b6556 | 1396 | send2callboxes( build_cb_package( ext, port, __CB_BYE__, (char * )data, 0x20, CB_BUFFER_SIZE - __VZ_HEADER_OFFSET__, write_buffer ) ); |
klauss | 104:62646ef786a3 | 1397 | if( debug_uart3 && !( from_eth ) ) pc.printf("\n\rBye enviado"); |
klauss | 105:a930035b6556 | 1398 | |
klauss | 105:a930035b6556 | 1399 | if( from_eth ) { |
klauss | 92:92df17f538a8 | 1400 | char eth_msg[ 512 ]; |
klauss | 92:92df17f538a8 | 1401 | snprintf( eth_msg, 512 - 1, "\r\next=%d port=%d request bye\n\r", ext, port ); |
klauss | 105:a930035b6556 | 1402 | if( tcp_session && !udp_query ) { |
klauss | 92:92df17f538a8 | 1403 | tcp_client.send_all( eth_msg, strlen( eth_msg ) ); |
klauss | 105:a930035b6556 | 1404 | } else if( udp_query ) { |
klauss | 105:a930035b6556 | 1405 | udp_query_send_msg( eth_msg ); |
klauss | 92:92df17f538a8 | 1406 | } |
klauss | 92:92df17f538a8 | 1407 | } |
klauss | 105:a930035b6556 | 1408 | |
klauss | 92:92df17f538a8 | 1409 | debug_buf = ref; |
klauss | 92:92df17f538a8 | 1410 | bufptr = 0; |
klauss | 104:62646ef786a3 | 1411 | for( register int i = 0; i < DEBUGBUFSIZE; i++ ) debug_buf[ i ] = 0; |
klauss | 92:92df17f538a8 | 1412 | } |
klauss | 105:a930035b6556 | 1413 | |
klauss | 45:c80574f24dc3 | 1414 | //promptcb ramal porta comando |
klauss | 50:d9b6577a70f5 | 1415 | //FIXME colocar a parte eth de novo |
klauss | 59:e1e300880d2d | 1416 | else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "pcb ", 4 )) { |
klauss | 45:c80574f24dc3 | 1417 | miss_match = false; |
klauss | 48:195c97f12e8e | 1418 | int ext,port; |
klauss | 54:448d57291be6 | 1419 | char *split, *ref, *cmd; |
klauss | 105:a930035b6556 | 1420 | |
klauss | 62:07e5bdc9f8f7 | 1421 | ref = debug_buf; |
klauss | 105:a930035b6556 | 1422 | |
klauss | 74:81c47fff88a5 | 1423 | strcat( debug_buf, "\r" ); |
klauss | 105:a930035b6556 | 1424 | |
klauss | 48:195c97f12e8e | 1425 | split = strtok( debug_buf + 4, " " ); |
klauss | 48:195c97f12e8e | 1426 | ext = atoi( split ); |
klauss | 105:a930035b6556 | 1427 | |
klauss | 50:d9b6577a70f5 | 1428 | port = convert_ext_to_port( ext ); |
klauss | 48:195c97f12e8e | 1429 | split += strlen( split ) + 1; |
klauss | 54:448d57291be6 | 1430 | cmd = split; |
klauss | 105:a930035b6556 | 1431 | |
klauss | 48:195c97f12e8e | 1432 | promptcb_last_ext = ext; |
klauss | 48:195c97f12e8e | 1433 | promptcb_last_port = port; |
klauss | 105:a930035b6556 | 1434 | |
klauss | 55:2f5e7374af9d | 1435 | strcpy( promptcb_last_cmd, cmd ); |
klauss | 105:a930035b6556 | 1436 | |
klauss | 104:62646ef786a3 | 1437 | for( register int i = strlen( cmd ); i < DEBUGBUFSIZE; i++ ) cmd[ i ] = 0; |
klauss | 105:a930035b6556 | 1438 | |
klauss | 104:62646ef786a3 | 1439 | if( debug_uart3 && !( from_eth ) ) pc.printf("\r\next=%d port=%d cmd=%s", ext, port, cmd ); |
klauss | 105:a930035b6556 | 1440 | send2callboxes( build_cb_package( ext, port, __PROMPT__, cmd, id_msg++, CB_BUFFER_SIZE - __VZ_HEADER_OFFSET__, write_buffer ) ); |
klauss | 104:62646ef786a3 | 1441 | if( debug_uart3 && !( from_eth ) ) pc.printf("\n\rComando enviado"); |
klauss | 105:a930035b6556 | 1442 | |
klauss | 105:a930035b6556 | 1443 | if( from_eth ) { |
klauss | 62:07e5bdc9f8f7 | 1444 | char eth_msg[ 512 ]; |
klauss | 78:1353744f01e1 | 1445 | snprintf( eth_msg, 512 - 1, "\r\next=%d port=%d cmd=%s\r\nComando enviado\n\r", ext, port, cmd ); |
klauss | 105:a930035b6556 | 1446 | if( tcp_session && !udp_query ) { |
klauss | 62:07e5bdc9f8f7 | 1447 | tcp_client.send_all( eth_msg, strlen( eth_msg ) ); |
klauss | 105:a930035b6556 | 1448 | } else if( udp_query ) { |
klauss | 105:a930035b6556 | 1449 | udp_query_send_msg( eth_msg ); |
klauss | 62:07e5bdc9f8f7 | 1450 | } |
klauss | 54:448d57291be6 | 1451 | } |
klauss | 105:a930035b6556 | 1452 | |
klauss | 48:195c97f12e8e | 1453 | debug_buf = ref; |
klauss | 62:07e5bdc9f8f7 | 1454 | bufptr = 0; |
klauss | 104:62646ef786a3 | 1455 | for( register int i = 0; i < DEBUGBUFSIZE; i++ ) debug_buf[ i ] = 0; |
klauss | 45:c80574f24dc3 | 1456 | } |
klauss | 105:a930035b6556 | 1457 | |
klauss | 98:43b45f26b430 | 1458 | else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "pcc ", 4 )) { |
klauss | 98:43b45f26b430 | 1459 | miss_match = false; |
klauss | 98:43b45f26b430 | 1460 | int ext,port; |
klauss | 98:43b45f26b430 | 1461 | char *split, *ref, *cmd; |
klauss | 105:a930035b6556 | 1462 | |
klauss | 98:43b45f26b430 | 1463 | ref = debug_buf; |
klauss | 105:a930035b6556 | 1464 | |
klauss | 98:43b45f26b430 | 1465 | strcat( debug_buf, "\r" ); |
klauss | 105:a930035b6556 | 1466 | |
klauss | 98:43b45f26b430 | 1467 | split = strtok( debug_buf + 4, " " ); |
klauss | 98:43b45f26b430 | 1468 | ext = atoi( split ); |
klauss | 105:a930035b6556 | 1469 | |
klauss | 98:43b45f26b430 | 1470 | split += strlen( split ) + 1; |
klauss | 98:43b45f26b430 | 1471 | split = strtok( NULL, " " ); |
klauss | 98:43b45f26b430 | 1472 | port = atoi( split ); |
klauss | 105:a930035b6556 | 1473 | |
klauss | 98:43b45f26b430 | 1474 | split += strlen( split ) + 1; |
klauss | 98:43b45f26b430 | 1475 | cmd = split; |
klauss | 105:a930035b6556 | 1476 | |
klauss | 98:43b45f26b430 | 1477 | promptcb_last_ext = ext; |
klauss | 98:43b45f26b430 | 1478 | promptcb_last_port = port; |
klauss | 105:a930035b6556 | 1479 | |
klauss | 98:43b45f26b430 | 1480 | strcpy( promptcb_last_cmd, cmd ); |
klauss | 105:a930035b6556 | 1481 | |
klauss | 104:62646ef786a3 | 1482 | for( register int i = strlen( cmd ); i < DEBUGBUFSIZE; i++ ) cmd[ i ] = 0; |
klauss | 105:a930035b6556 | 1483 | |
klauss | 104:62646ef786a3 | 1484 | if( debug_uart3 && !( from_eth ) ) pc.printf("\r\next=%d port=%d cmd=%s", ext, port, cmd ); |
klauss | 105:a930035b6556 | 1485 | send2callboxes( build_cb_package( ext, port, __PROMPT__, cmd, id_msg++, CB_BUFFER_SIZE - __VZ_HEADER_OFFSET__, write_buffer ) ); |
klauss | 104:62646ef786a3 | 1486 | if( debug_uart3 && !( from_eth ) ) pc.printf("\n\rComando enviado"); |
klauss | 105:a930035b6556 | 1487 | |
klauss | 105:a930035b6556 | 1488 | if( from_eth ) { |
klauss | 98:43b45f26b430 | 1489 | char eth_msg[ 512 ]; |
klauss | 98:43b45f26b430 | 1490 | snprintf( eth_msg, 512 - 1, "\r\next=%d port=%d cmd=%s\r\nComando enviado\n\r", ext, port, cmd ); |
klauss | 105:a930035b6556 | 1491 | if( tcp_session && !udp_query ) { |
klauss | 98:43b45f26b430 | 1492 | tcp_client.send_all( eth_msg, strlen( eth_msg ) ); |
klauss | 105:a930035b6556 | 1493 | } else if( udp_query ) { |
klauss | 105:a930035b6556 | 1494 | udp_query_send_msg( eth_msg ); |
klauss | 98:43b45f26b430 | 1495 | } |
klauss | 98:43b45f26b430 | 1496 | } |
klauss | 105:a930035b6556 | 1497 | |
klauss | 98:43b45f26b430 | 1498 | debug_buf = ref; |
klauss | 98:43b45f26b430 | 1499 | bufptr = 0; |
klauss | 104:62646ef786a3 | 1500 | for( register int i = 0; i < DEBUGBUFSIZE; i++ ) debug_buf[ i ] = 0; |
klauss | 98:43b45f26b430 | 1501 | } |
klauss | 105:a930035b6556 | 1502 | |
klauss | 99:e80850c51106 | 1503 | else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "rush ", 5 )) { |
klauss | 99:e80850c51106 | 1504 | miss_match = false; |
klauss | 99:e80850c51106 | 1505 | int ext,port; |
klauss | 99:e80850c51106 | 1506 | char *split, *ref, cmd[ 32 ]; |
klauss | 105:a930035b6556 | 1507 | |
klauss | 99:e80850c51106 | 1508 | ref = debug_buf; |
klauss | 105:a930035b6556 | 1509 | |
klauss | 99:e80850c51106 | 1510 | strcat( debug_buf, "\r" ); |
klauss | 105:a930035b6556 | 1511 | |
klauss | 99:e80850c51106 | 1512 | split = strtok( debug_buf + 5, " " ); |
klauss | 99:e80850c51106 | 1513 | ext = atoi( split ); |
klauss | 105:a930035b6556 | 1514 | |
klauss | 99:e80850c51106 | 1515 | split += strlen( split ) + 1; |
klauss | 99:e80850c51106 | 1516 | split = strtok( NULL, " " ); |
klauss | 99:e80850c51106 | 1517 | port = atoi( split ); |
klauss | 105:a930035b6556 | 1518 | |
klauss | 99:e80850c51106 | 1519 | strcpy( cmd, "ping\r\n" ); |
klauss | 105:a930035b6556 | 1520 | |
klauss | 99:e80850c51106 | 1521 | promptcb_last_ext = ext; |
klauss | 99:e80850c51106 | 1522 | promptcb_last_port = port; |
klauss | 105:a930035b6556 | 1523 | |
klauss | 99:e80850c51106 | 1524 | strcpy( promptcb_last_cmd, cmd ); |
klauss | 99:e80850c51106 | 1525 | strcat( cmd, "\r\r\r\n" ); |
klauss | 105:a930035b6556 | 1526 | |
klauss | 105:a930035b6556 | 1527 | for( register uint8_t i = 0; i < 3; i++ ) { |
klauss | 104:62646ef786a3 | 1528 | if( debug_uart3 && !( from_eth ) ) pc.printf("\r\next=%d port=%d cmd=%s", ext, port, cmd ); |
klauss | 105:a930035b6556 | 1529 | send2callboxes( build_cb_package( ext, port, __PROMPT__, cmd, id_msg++, CB_BUFFER_SIZE - __VZ_HEADER_OFFSET__, write_buffer ) ); |
klauss | 104:62646ef786a3 | 1530 | if( debug_uart3 && !( from_eth ) ) pc.printf("\n\rComando enviado"); |
klauss | 105:a930035b6556 | 1531 | |
klauss | 105:a930035b6556 | 1532 | if( from_eth ) { |
klauss | 99:e80850c51106 | 1533 | char eth_msg[ 512 ]; |
klauss | 99:e80850c51106 | 1534 | snprintf( eth_msg, 512 - 1, "\r\next=%d port=%d cmd=%s\r\nComando enviado\n\r", ext, port, cmd ); |
klauss | 105:a930035b6556 | 1535 | if( tcp_session && !udp_query ) { |
klauss | 99:e80850c51106 | 1536 | tcp_client.send_all( eth_msg, strlen( eth_msg ) ); |
klauss | 105:a930035b6556 | 1537 | } else if( udp_query ) { |
klauss | 105:a930035b6556 | 1538 | udp_query_send_msg( eth_msg ); |
klauss | 99:e80850c51106 | 1539 | } |
klauss | 99:e80850c51106 | 1540 | } |
klauss | 99:e80850c51106 | 1541 | } |
klauss | 105:a930035b6556 | 1542 | |
klauss | 99:e80850c51106 | 1543 | debug_buf = ref; |
klauss | 99:e80850c51106 | 1544 | bufptr = 0; |
klauss | 104:62646ef786a3 | 1545 | for( register int i = 0; i < DEBUGBUFSIZE; i++ ) debug_buf[ i ] = 0; |
klauss | 99:e80850c51106 | 1546 | } |
klauss | 105:a930035b6556 | 1547 | |
klauss | 105:a930035b6556 | 1548 | |
klauss | 105:a930035b6556 | 1549 | |
klauss | 59:e1e300880d2d | 1550 | else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "_pcb",4 )) { |
klauss | 45:c80574f24dc3 | 1551 | miss_match = false; |
klauss | 48:195c97f12e8e | 1552 | debug_buf[ bufptr++ ] = 0x0D; |
klauss | 48:195c97f12e8e | 1553 | debug_buf[ bufptr++ ] = 0x00; |
klauss | 45:c80574f24dc3 | 1554 | |
klauss | 104:62646ef786a3 | 1555 | if( debug_uart3 && !( from_eth ) ) pc.printf("\r\next=%d port=%d\r\ncmd=%s\r\n",promptcb_last_ext, promptcb_last_port, debug_buf + 4 ); |
klauss | 105:a930035b6556 | 1556 | send2callboxes( build_cb_package( promptcb_last_ext, promptcb_last_port, __PROMPT__, debug_buf + 4, id_msg++, CB_BUFFER_SIZE - __VZ_HEADER_OFFSET__, write_buffer ) ); |
klauss | 104:62646ef786a3 | 1557 | if( debug_uart3 && !( from_eth ) ) pc.printf("\n\rComando enviado\n\r"); |
klauss | 45:c80574f24dc3 | 1558 | } |
klauss | 62:07e5bdc9f8f7 | 1559 | |
klauss | 58:af7e8788f106 | 1560 | else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "cks",3 )) { |
klauss | 45:c80574f24dc3 | 1561 | miss_match = false; |
klauss | 81:3656f00ab3db | 1562 | pcks_s = true; |
klauss | 45:c80574f24dc3 | 1563 | } |
klauss | 45:c80574f24dc3 | 1564 | |
klauss | 58:af7e8788f106 | 1565 | else if (xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "showcb",6 )) { |
klauss | 45:c80574f24dc3 | 1566 | miss_match = false; |
klauss | 81:3656f00ab3db | 1567 | pshowcb = true; |
klauss | 45:c80574f24dc3 | 1568 | } |
klauss | 105:a930035b6556 | 1569 | |
klauss | 58:af7e8788f106 | 1570 | else if (xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "debug_main ", 11 )) { |
klauss | 81:3656f00ab3db | 1571 | if (xmemmatch( (uint8_t*)( debug_buf + 11 ), (uint8_t*) "on", 2 )) { |
klauss | 45:c80574f24dc3 | 1572 | miss_match = false; |
klauss | 104:62646ef786a3 | 1573 | if( debug_uart3 && !( from_eth ) ) pc.printf("\r\nDebug Main ON"); |
klauss | 105:a930035b6556 | 1574 | if( from_eth ) { |
klauss | 105:a930035b6556 | 1575 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Debug Main On\n\r"); |
klauss | 45:c80574f24dc3 | 1576 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 105:a930035b6556 | 1577 | if( tcp_session && !udp_query ) { |
klauss | 105:a930035b6556 | 1578 | tcp_client.send_all( debug_buf, strlen( debug_buf ) ); |
klauss | 105:a930035b6556 | 1579 | } else if( udp_query ) { |
klauss | 105:a930035b6556 | 1580 | udp_query_send_msg( debug_buf ); |
klauss | 105:a930035b6556 | 1581 | } |
klauss | 45:c80574f24dc3 | 1582 | } |
klauss | 81:3656f00ab3db | 1583 | debug_main = true; |
klauss | 45:c80574f24dc3 | 1584 | } |
klauss | 81:3656f00ab3db | 1585 | if (xmemmatch( (uint8_t*)( debug_buf + 11 ), (uint8_t*) "off", 3 )) { |
klauss | 45:c80574f24dc3 | 1586 | miss_match = false; |
klauss | 104:62646ef786a3 | 1587 | if( debug_uart3 && !( from_eth ) ) pc.printf("\r\nDebug Main OFF"); |
klauss | 105:a930035b6556 | 1588 | if( from_eth ) { |
klauss | 105:a930035b6556 | 1589 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Debug Main Off\n\r"); |
klauss | 45:c80574f24dc3 | 1590 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 105:a930035b6556 | 1591 | if( tcp_session && !udp_query ) { |
klauss | 105:a930035b6556 | 1592 | tcp_client.send_all( debug_buf, strlen( debug_buf ) ); |
klauss | 105:a930035b6556 | 1593 | } else if( udp_query ) { |
klauss | 105:a930035b6556 | 1594 | udp_query_send_msg( debug_buf ); |
klauss | 105:a930035b6556 | 1595 | } |
klauss | 45:c80574f24dc3 | 1596 | } |
klauss | 45:c80574f24dc3 | 1597 | debug_main = 0; |
klauss | 45:c80574f24dc3 | 1598 | } |
klauss | 45:c80574f24dc3 | 1599 | } |
klauss | 105:a930035b6556 | 1600 | |
klauss | 105:a930035b6556 | 1601 | else if (xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "dout ", 5 ) ) { |
klauss | 105:a930035b6556 | 1602 | if (xmemmatch( (uint8_t*)( debug_buf + 5 ), (uint8_t*) "on", 2 ) ) { |
klauss | 81:3656f00ab3db | 1603 | miss_match = false; |
klauss | 104:62646ef786a3 | 1604 | if( debug_uart3 && !( from_eth ) ) pc.printf("\r\nOut Debug ON"); |
klauss | 105:a930035b6556 | 1605 | if( from_eth ) { |
klauss | 105:a930035b6556 | 1606 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Out Debug On\n\r"); |
klauss | 81:3656f00ab3db | 1607 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 105:a930035b6556 | 1608 | if( tcp_session && !udp_query ) { |
klauss | 105:a930035b6556 | 1609 | tcp_client.send_all( debug_buf, strlen( debug_buf ) ); |
klauss | 105:a930035b6556 | 1610 | } else if( udp_query ) { |
klauss | 105:a930035b6556 | 1611 | udp_query_send_msg( debug_buf ); |
klauss | 105:a930035b6556 | 1612 | } |
klauss | 81:3656f00ab3db | 1613 | } |
klauss | 81:3656f00ab3db | 1614 | debug_out_of_range = true; |
klauss | 81:3656f00ab3db | 1615 | } |
klauss | 105:a930035b6556 | 1616 | if (xmemmatch( (uint8_t*)( debug_buf + 5 ), (uint8_t*) "off", 3 ) ) { |
klauss | 81:3656f00ab3db | 1617 | miss_match = false; |
klauss | 104:62646ef786a3 | 1618 | if( debug_uart3 && !( from_eth ) ) pc.printf("\r\nOut Debug OFF"); |
klauss | 105:a930035b6556 | 1619 | if( from_eth ) { |
klauss | 105:a930035b6556 | 1620 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Out Debug Off\n\r"); |
klauss | 81:3656f00ab3db | 1621 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 105:a930035b6556 | 1622 | if( tcp_session && !udp_query ) { |
klauss | 105:a930035b6556 | 1623 | tcp_client.send_all( debug_buf, strlen( debug_buf ) ); |
klauss | 105:a930035b6556 | 1624 | } else if( udp_query ) { |
klauss | 105:a930035b6556 | 1625 | udp_query_send_msg( debug_buf ); |
klauss | 105:a930035b6556 | 1626 | } |
klauss | 81:3656f00ab3db | 1627 | } |
klauss | 81:3656f00ab3db | 1628 | debug_out_of_range = false; |
klauss | 81:3656f00ab3db | 1629 | } |
klauss | 81:3656f00ab3db | 1630 | } |
klauss | 105:a930035b6556 | 1631 | |
klauss | 105:a930035b6556 | 1632 | else if (xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "dboot ", 6 ) ) { |
klauss | 105:a930035b6556 | 1633 | if (xmemmatch( (uint8_t*)( debug_buf + 6 ), (uint8_t*) "on", 2 ) ) { |
klauss | 99:e80850c51106 | 1634 | miss_match = false; |
klauss | 104:62646ef786a3 | 1635 | if( debug_uart3 && !( from_eth ) ) pc.printf("\r\nBoot Debug ON"); |
klauss | 105:a930035b6556 | 1636 | if( from_eth ) { |
klauss | 105:a930035b6556 | 1637 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Boot Debug On\n\r"); |
klauss | 99:e80850c51106 | 1638 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 105:a930035b6556 | 1639 | if( tcp_session && !udp_query ) { |
klauss | 105:a930035b6556 | 1640 | tcp_client.send_all( debug_buf, strlen( debug_buf ) ); |
klauss | 105:a930035b6556 | 1641 | } else if( udp_query ) { |
klauss | 105:a930035b6556 | 1642 | udp_query_send_msg( debug_buf ); |
klauss | 105:a930035b6556 | 1643 | } |
klauss | 99:e80850c51106 | 1644 | } |
klauss | 99:e80850c51106 | 1645 | debug_boot = true; |
klauss | 99:e80850c51106 | 1646 | } |
klauss | 105:a930035b6556 | 1647 | if (xmemmatch( (uint8_t*)( debug_buf + 6 ), (uint8_t*) "off", 3 ) ) { |
klauss | 99:e80850c51106 | 1648 | miss_match = false; |
klauss | 104:62646ef786a3 | 1649 | if( debug_uart3 && !( from_eth ) ) pc.printf("\r\nBoot Debug OFF"); |
klauss | 105:a930035b6556 | 1650 | if( from_eth ) { |
klauss | 105:a930035b6556 | 1651 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Boot Debug Off\n\r"); |
klauss | 99:e80850c51106 | 1652 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 105:a930035b6556 | 1653 | if( tcp_session && !udp_query ) { |
klauss | 105:a930035b6556 | 1654 | tcp_client.send_all( debug_buf, strlen( debug_buf ) ); |
klauss | 105:a930035b6556 | 1655 | } else if( udp_query ) { |
klauss | 105:a930035b6556 | 1656 | udp_query_send_msg( debug_buf ); |
klauss | 105:a930035b6556 | 1657 | } |
klauss | 99:e80850c51106 | 1658 | } |
klauss | 99:e80850c51106 | 1659 | debug_boot = false; |
klauss | 99:e80850c51106 | 1660 | } |
klauss | 99:e80850c51106 | 1661 | } |
klauss | 105:a930035b6556 | 1662 | |
klauss | 105:a930035b6556 | 1663 | else if (xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "dfw ", 4 ) ) { |
klauss | 105:a930035b6556 | 1664 | if (xmemmatch( (uint8_t*)( debug_buf + 4 ), (uint8_t*) "on", 2 ) ) { |
klauss | 99:e80850c51106 | 1665 | miss_match = false; |
klauss | 104:62646ef786a3 | 1666 | if( debug_uart3 && !( from_eth ) ) pc.printf("\r\nFW Debug ON"); |
klauss | 105:a930035b6556 | 1667 | if( from_eth ) { |
klauss | 105:a930035b6556 | 1668 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "FW Debug On\n\r"); |
klauss | 99:e80850c51106 | 1669 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 105:a930035b6556 | 1670 | if( tcp_session && !udp_query ) { |
klauss | 105:a930035b6556 | 1671 | tcp_client.send_all( debug_buf, strlen( debug_buf ) ); |
klauss | 105:a930035b6556 | 1672 | } else if( udp_query ) { |
klauss | 105:a930035b6556 | 1673 | udp_query_send_msg( debug_buf ); |
klauss | 105:a930035b6556 | 1674 | } |
klauss | 99:e80850c51106 | 1675 | } |
klauss | 99:e80850c51106 | 1676 | debug_fw = true; |
klauss | 99:e80850c51106 | 1677 | } |
klauss | 105:a930035b6556 | 1678 | if (xmemmatch( (uint8_t*)( debug_buf + 4 ), (uint8_t*) "off", 3 ) ) { |
klauss | 99:e80850c51106 | 1679 | miss_match = false; |
klauss | 104:62646ef786a3 | 1680 | if( debug_uart3 && !( from_eth ) ) pc.printf("\r\nFW Debug OFF"); |
klauss | 105:a930035b6556 | 1681 | if( from_eth ) { |
klauss | 105:a930035b6556 | 1682 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "FW Debug Off\n\r"); |
klauss | 99:e80850c51106 | 1683 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 105:a930035b6556 | 1684 | if( tcp_session && !udp_query ) { |
klauss | 105:a930035b6556 | 1685 | tcp_client.send_all( debug_buf, strlen( debug_buf ) ); |
klauss | 105:a930035b6556 | 1686 | } else if( udp_query ) { |
klauss | 105:a930035b6556 | 1687 | udp_query_send_msg( debug_buf ); |
klauss | 105:a930035b6556 | 1688 | } |
klauss | 99:e80850c51106 | 1689 | } |
klauss | 99:e80850c51106 | 1690 | debug_fw = false; |
klauss | 99:e80850c51106 | 1691 | } |
klauss | 99:e80850c51106 | 1692 | } |
klauss | 105:a930035b6556 | 1693 | |
klauss | 105:a930035b6556 | 1694 | else if (xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "dfwp ", 5 ) ) { |
klauss | 105:a930035b6556 | 1695 | if (xmemmatch( (uint8_t*)( debug_buf + 5 ), (uint8_t*) "on", 2 ) ) { |
klauss | 99:e80850c51106 | 1696 | miss_match = false; |
klauss | 104:62646ef786a3 | 1697 | if( debug_uart3 && !( from_eth ) ) pc.printf("\r\nFWPrint Debug ON"); |
klauss | 105:a930035b6556 | 1698 | if( from_eth ) { |
klauss | 105:a930035b6556 | 1699 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "FWPrint Debug On\n\r"); |
klauss | 99:e80850c51106 | 1700 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 105:a930035b6556 | 1701 | if( tcp_session && !udp_query ) { |
klauss | 105:a930035b6556 | 1702 | tcp_client.send_all( debug_buf, strlen( debug_buf ) ); |
klauss | 105:a930035b6556 | 1703 | } else if( udp_query ) { |
klauss | 105:a930035b6556 | 1704 | udp_query_send_msg( debug_buf ); |
klauss | 105:a930035b6556 | 1705 | } |
klauss | 99:e80850c51106 | 1706 | } |
klauss | 99:e80850c51106 | 1707 | debug_fw_print = true; |
klauss | 99:e80850c51106 | 1708 | } |
klauss | 105:a930035b6556 | 1709 | if (xmemmatch( (uint8_t*)( debug_buf + 5 ), (uint8_t*) "off", 3 ) ) { |
klauss | 99:e80850c51106 | 1710 | miss_match = false; |
klauss | 104:62646ef786a3 | 1711 | if( debug_uart3 && !( from_eth ) ) pc.printf("\r\nFWPrint Debug OFF"); |
klauss | 105:a930035b6556 | 1712 | if( from_eth ) { |
klauss | 105:a930035b6556 | 1713 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "FWPrint Debug Off\n\r"); |
klauss | 99:e80850c51106 | 1714 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 105:a930035b6556 | 1715 | if( tcp_session && !udp_query ) { |
klauss | 105:a930035b6556 | 1716 | tcp_client.send_all( debug_buf, strlen( debug_buf ) ); |
klauss | 105:a930035b6556 | 1717 | } else if( udp_query ) { |
klauss | 105:a930035b6556 | 1718 | udp_query_send_msg( debug_buf ); |
klauss | 105:a930035b6556 | 1719 | } |
klauss | 99:e80850c51106 | 1720 | } |
klauss | 99:e80850c51106 | 1721 | debug_fw_print = false; |
klauss | 99:e80850c51106 | 1722 | } |
klauss | 99:e80850c51106 | 1723 | } |
klauss | 105:a930035b6556 | 1724 | |
klauss | 99:e80850c51106 | 1725 | else if (xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "drx ", 4 )) { |
klauss | 99:e80850c51106 | 1726 | if (xmemmatch( (uint8_t*)( debug_buf + 4 ), (uint8_t*) "on",2 )) { |
klauss | 45:c80574f24dc3 | 1727 | miss_match = false; |
klauss | 104:62646ef786a3 | 1728 | if( debug_uart3 && !( from_eth ) ) pc.printf("\tDebug Cbx Rx ON"); |
klauss | 105:a930035b6556 | 1729 | if( from_eth ) { |
klauss | 105:a930035b6556 | 1730 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "\tDebug Cbx On Rx on\n\r"); |
klauss | 45:c80574f24dc3 | 1731 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 105:a930035b6556 | 1732 | if( tcp_session && !udp_query ) { |
klauss | 105:a930035b6556 | 1733 | tcp_client.send_all( debug_buf, strlen( debug_buf ) ); |
klauss | 105:a930035b6556 | 1734 | } else if( udp_query ) { |
klauss | 105:a930035b6556 | 1735 | udp_query_send_msg( debug_buf ); |
klauss | 105:a930035b6556 | 1736 | } |
klauss | 45:c80574f24dc3 | 1737 | } |
klauss | 81:3656f00ab3db | 1738 | debug_cb_rx = true; |
klauss | 45:c80574f24dc3 | 1739 | } |
klauss | 99:e80850c51106 | 1740 | if (xmemmatch( (uint8_t*)( debug_buf + 4 ), (uint8_t*) "off",3 )) { |
klauss | 45:c80574f24dc3 | 1741 | miss_match = false; |
klauss | 104:62646ef786a3 | 1742 | if( debug_uart3 && !( from_eth ) ) pc.printf("\tDebug Cbx Rx OFF"); |
klauss | 105:a930035b6556 | 1743 | if( from_eth ) { |
klauss | 105:a930035b6556 | 1744 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "\tDebug Cbx On Rx off\n\r"); |
klauss | 45:c80574f24dc3 | 1745 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 105:a930035b6556 | 1746 | if( tcp_session && !udp_query ) { |
klauss | 105:a930035b6556 | 1747 | tcp_client.send_all( debug_buf, strlen( debug_buf ) ); |
klauss | 105:a930035b6556 | 1748 | } else if( udp_query ) { |
klauss | 105:a930035b6556 | 1749 | udp_query_send_msg( debug_buf ); |
klauss | 105:a930035b6556 | 1750 | } |
klauss | 45:c80574f24dc3 | 1751 | } |
klauss | 99:e80850c51106 | 1752 | debug_cb_rx = false; |
klauss | 99:e80850c51106 | 1753 | } |
klauss | 99:e80850c51106 | 1754 | } |
klauss | 105:a930035b6556 | 1755 | |
klauss | 99:e80850c51106 | 1756 | else if (xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "dtx ", 4 )) { |
klauss | 99:e80850c51106 | 1757 | if (xmemmatch( (uint8_t*)( debug_buf + 4 ), (uint8_t*) "on",2 )) { |
klauss | 99:e80850c51106 | 1758 | miss_match = false; |
klauss | 104:62646ef786a3 | 1759 | if( debug_uart3 && !( from_eth ) ) pc.printf("\tDebug Cbx Tx ON"); |
klauss | 105:a930035b6556 | 1760 | if( from_eth ) { |
klauss | 105:a930035b6556 | 1761 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "\tDebug Cbx Tx on\n\r"); |
klauss | 99:e80850c51106 | 1762 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 105:a930035b6556 | 1763 | if( tcp_session && !udp_query ) { |
klauss | 105:a930035b6556 | 1764 | tcp_client.send_all( debug_buf, strlen( debug_buf ) ); |
klauss | 105:a930035b6556 | 1765 | } else if( udp_query ) { |
klauss | 105:a930035b6556 | 1766 | udp_query_send_msg( debug_buf ); |
klauss | 105:a930035b6556 | 1767 | } |
klauss | 99:e80850c51106 | 1768 | } |
klauss | 99:e80850c51106 | 1769 | debug_cb_tx = true; |
klauss | 99:e80850c51106 | 1770 | } |
klauss | 99:e80850c51106 | 1771 | if (xmemmatch( (uint8_t*)( debug_buf + 4 ), (uint8_t*) "off",3 )) { |
klauss | 99:e80850c51106 | 1772 | miss_match = false; |
klauss | 104:62646ef786a3 | 1773 | if( debug_uart3 && !( from_eth ) ) pc.printf("\tDebug Cbx Tx OFF"); |
klauss | 105:a930035b6556 | 1774 | if( from_eth ) { |
klauss | 105:a930035b6556 | 1775 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "\tDebug Cbx Tx off\n\r"); |
klauss | 99:e80850c51106 | 1776 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 105:a930035b6556 | 1777 | if( tcp_session && !udp_query ) { |
klauss | 105:a930035b6556 | 1778 | tcp_client.send_all( debug_buf, strlen( debug_buf ) ); |
klauss | 105:a930035b6556 | 1779 | } else if( udp_query ) { |
klauss | 105:a930035b6556 | 1780 | udp_query_send_msg( debug_buf ); |
klauss | 105:a930035b6556 | 1781 | } |
klauss | 99:e80850c51106 | 1782 | } |
klauss | 99:e80850c51106 | 1783 | debug_cb_tx = false; |
klauss | 45:c80574f24dc3 | 1784 | } |
klauss | 45:c80574f24dc3 | 1785 | } |
klauss | 105:a930035b6556 | 1786 | |
klauss | 58:af7e8788f106 | 1787 | else if (xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "debug_file ", 11 )) { |
klauss | 45:c80574f24dc3 | 1788 | if (xmemmatch( (uint8_t*)( debug_buf + 11 ), (uint8_t*) "on",2 )) { |
klauss | 45:c80574f24dc3 | 1789 | miss_match = false; |
klauss | 104:62646ef786a3 | 1790 | if( debug_uart3 && !( from_eth ) ) pc.printf("\tDebug File ON"); |
klauss | 105:a930035b6556 | 1791 | if( from_eth ) { |
klauss | 105:a930035b6556 | 1792 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "\tDebug File On\n\r"); |
klauss | 45:c80574f24dc3 | 1793 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 105:a930035b6556 | 1794 | if( tcp_session && !udp_query ) { |
klauss | 105:a930035b6556 | 1795 | tcp_client.send_all( debug_buf, strlen( debug_buf ) ); |
klauss | 105:a930035b6556 | 1796 | } else if( udp_query ) { |
klauss | 105:a930035b6556 | 1797 | udp_query_send_msg( debug_buf ); |
klauss | 105:a930035b6556 | 1798 | } |
klauss | 45:c80574f24dc3 | 1799 | } |
klauss | 105:a930035b6556 | 1800 | debug_file = true; |
klauss | 45:c80574f24dc3 | 1801 | } |
klauss | 45:c80574f24dc3 | 1802 | if (xmemmatch( (uint8_t*)( debug_buf + 11 ), (uint8_t*) "off",3 )) { |
klauss | 45:c80574f24dc3 | 1803 | miss_match = false; |
klauss | 104:62646ef786a3 | 1804 | if( debug_uart3 && !( from_eth ) ) pc.printf("Debug File OFF"); |
klauss | 105:a930035b6556 | 1805 | if( from_eth ) { |
klauss | 105:a930035b6556 | 1806 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Debug File Off\n\r"); |
klauss | 45:c80574f24dc3 | 1807 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 105:a930035b6556 | 1808 | if( tcp_session && !udp_query ) { |
klauss | 105:a930035b6556 | 1809 | tcp_client.send_all( debug_buf, strlen( debug_buf ) ); |
klauss | 105:a930035b6556 | 1810 | } else if( udp_query ) { |
klauss | 105:a930035b6556 | 1811 | udp_query_send_msg( debug_buf ); |
klauss | 105:a930035b6556 | 1812 | } |
klauss | 45:c80574f24dc3 | 1813 | } |
klauss | 105:a930035b6556 | 1814 | debug_file = false; |
klauss | 45:c80574f24dc3 | 1815 | } |
klauss | 45:c80574f24dc3 | 1816 | } |
klauss | 45:c80574f24dc3 | 1817 | |
klauss | 105:a930035b6556 | 1818 | else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "uptime" ) ) |
klauss | 105:a930035b6556 | 1819 | { |
klauss | 105:a930035b6556 | 1820 | miss_match = false; |
klauss | 105:a930035b6556 | 1821 | show_uptime = true; |
klauss | 105:a930035b6556 | 1822 | } |
klauss | 105:a930035b6556 | 1823 | |
klauss | 58:af7e8788f106 | 1824 | else if( xstrmatch( (uint8_t*)debug_buf, (uint8_t*) "help" )) { |
klauss | 45:c80574f24dc3 | 1825 | miss_match = false; |
klauss | 104:62646ef786a3 | 1826 | if( debug_uart3 && !( from_eth ) ) pc.printf("\n\r****************************PROMPT HELP******************\n\r"); |
klauss | 105:a930035b6556 | 1827 | if( from_eth ) { |
klauss | 45:c80574f24dc3 | 1828 | snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, "\n\r****************************PROMPT HELP******************\n\r" ); |
klauss | 105:a930035b6556 | 1829 | if( tcp_session && !udp_query ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 105:a930035b6556 | 1830 | |
klauss | 105:a930035b6556 | 1831 | else if( udp_query ) { |
klauss | 105:a930035b6556 | 1832 | udp_query_send_msg( debug_buf ); |
klauss | 105:a930035b6556 | 1833 | /* |
klauss | 105:a930035b6556 | 1834 | int send = udp_client.sendTo( udp_server, debug_buf, strlen( debug_buf ) ); |
klauss | 105:a930035b6556 | 1835 | |
klauss | 105:a930035b6556 | 1836 | if( send != strlen( debug_buf ) ) { |
klauss | 105:a930035b6556 | 1837 | if( debug_reconnect ) send_msg("Reconnect udp_query client"); |
klauss | 104:62646ef786a3 | 1838 | reconnect_prompt_udp_socket(); |
klauss | 104:62646ef786a3 | 1839 | miss_prompt_udp_send_pkg++; |
klauss | 104:62646ef786a3 | 1840 | } |
klauss | 105:a930035b6556 | 1841 | */ |
klauss | 45:c80574f24dc3 | 1842 | } |
klauss | 44:cc4996469404 | 1843 | } |
klauss | 105:a930035b6556 | 1844 | |
klauss | 104:62646ef786a3 | 1845 | if( debug_uart3 && !( from_eth ) ) pc.printf("ifconfig - mostra o arquivo de configuracao do sistema\n\r"); |
klauss | 105:a930035b6556 | 1846 | if( from_eth ) { |
klauss | 45:c80574f24dc3 | 1847 | snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, "ifconfig - mostra o arquivo de configuracao do sistema\n\r" ); |
klauss | 105:a930035b6556 | 1848 | if( tcp_session && !udp_query ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 105:a930035b6556 | 1849 | |
klauss | 105:a930035b6556 | 1850 | else if( udp_query ) { |
klauss | 105:a930035b6556 | 1851 | udp_query_send_msg( debug_buf ); |
klauss | 45:c80574f24dc3 | 1852 | } |
klauss | 45:c80574f24dc3 | 1853 | } |
klauss | 104:62646ef786a3 | 1854 | if( debug_uart3 && !( from_eth ) ) pc.printf("dconfig - volta as configuracoes do sistema para o padrao de fabrica\n\r"); |
klauss | 105:a930035b6556 | 1855 | if( from_eth ) { |
klauss | 45:c80574f24dc3 | 1856 | snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, "dconfig - volta as configuracoes do sistema para o padrao de fabrica\n\r" ); |
klauss | 105:a930035b6556 | 1857 | if( tcp_session && !udp_query ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 105:a930035b6556 | 1858 | |
klauss | 105:a930035b6556 | 1859 | else if( udp_query ) { |
klauss | 105:a930035b6556 | 1860 | udp_query_send_msg( debug_buf ); |
klauss | 45:c80574f24dc3 | 1861 | } |
klauss | 45:c80574f24dc3 | 1862 | } |
klauss | 104:62646ef786a3 | 1863 | if( debug_uart3 && !( from_eth ) ) pc.printf("callme [ramal porta] - envia o pedido de ligacao para o callbox com o ramal e porta indicada\n\r"); |
klauss | 105:a930035b6556 | 1864 | if( from_eth ) { |
klauss | 45:c80574f24dc3 | 1865 | snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, "callme [ramal porta] - envia o pedido de ligacao para o callbox com o ramal e porta indicada\n\r" ); |
klauss | 105:a930035b6556 | 1866 | if( tcp_session && !udp_query ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 105:a930035b6556 | 1867 | |
klauss | 105:a930035b6556 | 1868 | else if( udp_query ) { |
klauss | 105:a930035b6556 | 1869 | udp_query_send_msg( debug_buf ); |
klauss | 45:c80574f24dc3 | 1870 | } |
klauss | 45:c80574f24dc3 | 1871 | } |
klauss | 104:62646ef786a3 | 1872 | if( debug_uart3 && !( from_eth ) ) pc.printf("pcb porta comando - envia o <comando> para o cbx <ramal> e <porta> executar\n\r"); |
klauss | 105:a930035b6556 | 1873 | if( from_eth ) { |
klauss | 45:c80574f24dc3 | 1874 | snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, "promptcb ramal porta comando - envia o <comando> para o cbx <ramal> e <porta> executar\n\r" ); |
klauss | 105:a930035b6556 | 1875 | if( tcp_session && !udp_query ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 105:a930035b6556 | 1876 | |
klauss | 105:a930035b6556 | 1877 | else if( udp_query ) { |
klauss | 105:a930035b6556 | 1878 | udp_query_send_msg( debug_buf ); |
klauss | 45:c80574f24dc3 | 1879 | } |
klauss | 45:c80574f24dc3 | 1880 | } |
klauss | 104:62646ef786a3 | 1881 | if( debug_uart3 && !( from_eth ) ) pc.printf("format - formata o sistema de arquivos\n\r"); |
klauss | 104:62646ef786a3 | 1882 | if( debug_uart3 && !( from_eth ) ) pc.printf("reset - resta o sistema\n\r"); |
klauss | 105:a930035b6556 | 1883 | if( from_eth ) { |
klauss | 45:c80574f24dc3 | 1884 | snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, "reset - resta o sistema\n\r" ); |
klauss | 105:a930035b6556 | 1885 | if( tcp_session && !udp_query ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 105:a930035b6556 | 1886 | |
klauss | 105:a930035b6556 | 1887 | else if( udp_query ) { |
klauss | 105:a930035b6556 | 1888 | udp_query_send_msg( debug_buf ); |
klauss | 45:c80574f24dc3 | 1889 | } |
klauss | 45:c80574f24dc3 | 1890 | } |
klauss | 104:62646ef786a3 | 1891 | if( debug_uart3 && !( from_eth ) ) pc.printf("ipset [ip] - Configura o IP da cabeceira\n\r"); |
klauss | 105:a930035b6556 | 1892 | if( from_eth ) { |
klauss | 45:c80574f24dc3 | 1893 | snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, "ipset [ip] - Configura o IP da cabeceira\n\r" ); |
klauss | 105:a930035b6556 | 1894 | if( tcp_session && !udp_query ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 105:a930035b6556 | 1895 | |
klauss | 105:a930035b6556 | 1896 | else if( udp_query ) { |
klauss | 105:a930035b6556 | 1897 | udp_query_send_msg( debug_buf ); |
klauss | 45:c80574f24dc3 | 1898 | } |
klauss | 45:c80574f24dc3 | 1899 | } |
klauss | 104:62646ef786a3 | 1900 | if( debug_uart3 && !( from_eth ) ) pc.printf("extset [ext] - Configura a ext da cabeceira\n\r"); |
klauss | 105:a930035b6556 | 1901 | if( from_eth ) { |
klauss | 45:c80574f24dc3 | 1902 | snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, "extset [ext] - Configura a ext da cabeceira\n\r" ); |
klauss | 105:a930035b6556 | 1903 | if( tcp_session && !udp_query ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 105:a930035b6556 | 1904 | |
klauss | 105:a930035b6556 | 1905 | else if( udp_query ) { |
klauss | 105:a930035b6556 | 1906 | udp_query_send_msg( debug_buf ); |
klauss | 45:c80574f24dc3 | 1907 | } |
klauss | 45:c80574f24dc3 | 1908 | } |
klauss | 104:62646ef786a3 | 1909 | if( debug_uart3 && !( from_eth ) ) pc.printf("msipport [port] - Configura a porta SIP da cabeceira\n\r"); |
klauss | 105:a930035b6556 | 1910 | if( from_eth ) { |
klauss | 45:c80574f24dc3 | 1911 | snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, "msipport [port] - Configura a porta SIP da cabeceira\n\r" ); |
klauss | 105:a930035b6556 | 1912 | if( tcp_session && !udp_query ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 105:a930035b6556 | 1913 | |
klauss | 105:a930035b6556 | 1914 | else if( udp_query ) { |
klauss | 105:a930035b6556 | 1915 | udp_query_send_msg( debug_buf ); |
klauss | 45:c80574f24dc3 | 1916 | } |
klauss | 45:c80574f24dc3 | 1917 | } |
klauss | 104:62646ef786a3 | 1918 | if( debug_uart3 && !( from_eth ) ) pc.printf("serverip [ip] - Configura o ip do servidor asterisk\n\r"); |
klauss | 105:a930035b6556 | 1919 | if( from_eth ) { |
klauss | 45:c80574f24dc3 | 1920 | snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, "serverip [ip] - Configura o ip do servidor asterisk\n\r" ); |
klauss | 105:a930035b6556 | 1921 | if( tcp_session && !udp_query ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 105:a930035b6556 | 1922 | |
klauss | 105:a930035b6556 | 1923 | else if( udp_query ) { |
klauss | 105:a930035b6556 | 1924 | udp_query_send_msg( debug_buf ); |
klauss | 45:c80574f24dc3 | 1925 | } |
klauss | 45:c80574f24dc3 | 1926 | } |
klauss | 104:62646ef786a3 | 1927 | if( debug_uart3 && !( from_eth ) ) pc.printf("serextset [ext] - Configura a server ext da cabeceira\n\r"); |
klauss | 105:a930035b6556 | 1928 | if( from_eth ) { |
klauss | 45:c80574f24dc3 | 1929 | snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, "serextset [ext] - Configura a server ext da cabeceira\n\r" ); |
klauss | 105:a930035b6556 | 1930 | if( tcp_session && !udp_query ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 105:a930035b6556 | 1931 | |
klauss | 105:a930035b6556 | 1932 | else if( udp_query ) { |
klauss | 105:a930035b6556 | 1933 | udp_query_send_msg( debug_buf ); |
klauss | 45:c80574f24dc3 | 1934 | } |
klauss | 45:c80574f24dc3 | 1935 | } |
klauss | 104:62646ef786a3 | 1936 | if( debug_uart3 && !( from_eth ) ) pc.printf("ssport [port] - Configura a porta SIP do servidor asterisk\n\r"); |
klauss | 105:a930035b6556 | 1937 | if( from_eth ) { |
klauss | 45:c80574f24dc3 | 1938 | snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, "ssport [port] - Configura a porta SIP do servidor asterisk\n\r" ); |
klauss | 105:a930035b6556 | 1939 | if( tcp_session && !udp_query ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 105:a930035b6556 | 1940 | |
klauss | 105:a930035b6556 | 1941 | else if( udp_query ) { |
klauss | 105:a930035b6556 | 1942 | udp_query_send_msg( debug_buf ); |
klauss | 45:c80574f24dc3 | 1943 | } |
klauss | 45:c80574f24dc3 | 1944 | } |
klauss | 104:62646ef786a3 | 1945 | if( debug_uart3 && !( from_eth ) ) pc.printf("maskset [mask] - Configura a mascara da cabeceira\n\r"); |
klauss | 105:a930035b6556 | 1946 | if( from_eth ) { |
klauss | 45:c80574f24dc3 | 1947 | snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, "maskset [mask] - Configura a mascara da cabeceira\n\r" ); |
klauss | 105:a930035b6556 | 1948 | if( tcp_session && !udp_query ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 105:a930035b6556 | 1949 | |
klauss | 105:a930035b6556 | 1950 | else if( udp_query ) { |
klauss | 105:a930035b6556 | 1951 | udp_query_send_msg( debug_buf ); |
klauss | 45:c80574f24dc3 | 1952 | } |
klauss | 45:c80574f24dc3 | 1953 | } |
klauss | 104:62646ef786a3 | 1954 | if( debug_uart3 && !( from_eth ) ) pc.printf("gatewayset [gateway] - Configura o gateway da cabeceira\n\r"); |
klauss | 105:a930035b6556 | 1955 | if( from_eth ) { |
klauss | 45:c80574f24dc3 | 1956 | snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, "gatewayset [gateway] - Configura o gateway da cabeceira\n\r" ); |
klauss | 105:a930035b6556 | 1957 | if( tcp_session && !udp_query ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 105:a930035b6556 | 1958 | |
klauss | 105:a930035b6556 | 1959 | else if( udp_query ) { |
klauss | 105:a930035b6556 | 1960 | udp_query_send_msg( debug_buf ); |
klauss | 56:c64bcbaa621a | 1961 | } |
klauss | 56:c64bcbaa621a | 1962 | } |
klauss | 105:a930035b6556 | 1963 | |
klauss | 104:62646ef786a3 | 1964 | if( debug_uart3 && !( from_eth ) ) pc.printf("fw_ip - Configura o IP do servidor de fw\n\r"); |
klauss | 105:a930035b6556 | 1965 | if( from_eth ) { |
klauss | 99:e80850c51106 | 1966 | snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, "fw_ip - Configura o IP do servidor de fw\n\r" ); |
klauss | 105:a930035b6556 | 1967 | if( tcp_session && !udp_query ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 105:a930035b6556 | 1968 | |
klauss | 105:a930035b6556 | 1969 | else if( udp_query ) { |
klauss | 105:a930035b6556 | 1970 | udp_query_send_msg( debug_buf ); |
klauss | 99:e80850c51106 | 1971 | } |
klauss | 99:e80850c51106 | 1972 | } |
klauss | 104:62646ef786a3 | 1973 | if( debug_uart3 && !( from_eth ) ) pc.printf("fw_port - Configura a porta do servidor de fw\n\r"); |
klauss | 105:a930035b6556 | 1974 | if( from_eth ) { |
klauss | 99:e80850c51106 | 1975 | snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, "fw_port - Configura a porta do servidor de fw\n\r" ); |
klauss | 105:a930035b6556 | 1976 | if( tcp_session && !udp_query ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 105:a930035b6556 | 1977 | |
klauss | 105:a930035b6556 | 1978 | else if( udp_query ) { |
klauss | 105:a930035b6556 | 1979 | udp_query_send_msg( debug_buf ); |
klauss | 99:e80850c51106 | 1980 | } |
klauss | 99:e80850c51106 | 1981 | } |
klauss | 105:a930035b6556 | 1982 | |
klauss | 104:62646ef786a3 | 1983 | if( debug_uart3 && !( from_eth ) ) pc.printf("maxext - Configura o maior ramal possivel de ser registrado nesse ramo\n\r"); |
klauss | 105:a930035b6556 | 1984 | if( from_eth ) { |
klauss | 81:3656f00ab3db | 1985 | snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, "maxext - Configura o maior ramal possivel de ser registrado nesse ramo\n\r" ); |
klauss | 105:a930035b6556 | 1986 | if( tcp_session && !udp_query ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 105:a930035b6556 | 1987 | |
klauss | 105:a930035b6556 | 1988 | else if( udp_query ) { |
klauss | 105:a930035b6556 | 1989 | udp_query_send_msg( debug_buf ); |
klauss | 81:3656f00ab3db | 1990 | } |
klauss | 81:3656f00ab3db | 1991 | } |
klauss | 105:a930035b6556 | 1992 | |
klauss | 104:62646ef786a3 | 1993 | if( debug_uart3 && !( from_eth ) ) pc.printf("minext - Configura o menor ramal possivel de ser registrado nesse ramo\n\r"); |
klauss | 105:a930035b6556 | 1994 | if( from_eth ) { |
klauss | 81:3656f00ab3db | 1995 | snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, "minext - Configura o menor ramal possivel de ser registrado nesse ramo\n\r" ); |
klauss | 105:a930035b6556 | 1996 | if( tcp_session && !udp_query ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 105:a930035b6556 | 1997 | |
klauss | 105:a930035b6556 | 1998 | else if( udp_query ) { |
klauss | 105:a930035b6556 | 1999 | udp_query_send_msg( debug_buf ); |
klauss | 81:3656f00ab3db | 2000 | } |
klauss | 81:3656f00ab3db | 2001 | } |
klauss | 105:a930035b6556 | 2002 | |
klauss | 104:62646ef786a3 | 2003 | if( debug_uart3 && !( from_eth ) ) pc.printf("showcb - lista os Cbx registrados na header\n\r"); |
klauss | 105:a930035b6556 | 2004 | if( from_eth ) { |
klauss | 45:c80574f24dc3 | 2005 | snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, "showcb - lista os Cbx registrados na header\n\r" ); |
klauss | 105:a930035b6556 | 2006 | if( tcp_session && !udp_query ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 105:a930035b6556 | 2007 | |
klauss | 105:a930035b6556 | 2008 | else if( udp_query ) { |
klauss | 105:a930035b6556 | 2009 | udp_query_send_msg( debug_buf ); |
klauss | 45:c80574f24dc3 | 2010 | } |
klauss | 45:c80574f24dc3 | 2011 | } |
klauss | 104:62646ef786a3 | 2012 | if( debug_uart3 && !( from_eth ) ) pc.printf("cks - exibe estatisticas de check sum\n\r"); |
klauss | 105:a930035b6556 | 2013 | if( from_eth ) { |
klauss | 45:c80574f24dc3 | 2014 | snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, "cks - exibe estatisticas de check sum\n\r" ); |
klauss | 105:a930035b6556 | 2015 | if( tcp_session && !udp_query ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 105:a930035b6556 | 2016 | |
klauss | 105:a930035b6556 | 2017 | else if( udp_query ) { |
klauss | 105:a930035b6556 | 2018 | udp_query_send_msg( debug_buf ); |
klauss | 45:c80574f24dc3 | 2019 | } |
klauss | 45:c80574f24dc3 | 2020 | } |
klauss | 104:62646ef786a3 | 2021 | if( debug_uart3 && !( from_eth ) ) pc.printf("reset_cks - reseta estatisticas de check sum\n\r"); |
klauss | 105:a930035b6556 | 2022 | if( from_eth ) { |
klauss | 52:12930cef17c4 | 2023 | snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, "reset_cks - reseta estatisticas de check sum\n\r" ); |
klauss | 105:a930035b6556 | 2024 | if( tcp_session && !udp_query ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 105:a930035b6556 | 2025 | |
klauss | 105:a930035b6556 | 2026 | else if( udp_query ) { |
klauss | 105:a930035b6556 | 2027 | udp_query_send_msg( debug_buf ); |
klauss | 52:12930cef17c4 | 2028 | } |
klauss | 52:12930cef17c4 | 2029 | } |
klauss | 105:a930035b6556 | 2030 | |
klauss | 104:62646ef786a3 | 2031 | if( debug_uart3 && !( from_eth ) ) pc.printf(". - executa o comando anterior novamente\n\r"); |
klauss | 105:a930035b6556 | 2032 | if( from_eth ) { |
klauss | 45:c80574f24dc3 | 2033 | snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, ". - executa o comando anterior novamente\n\r" ); |
klauss | 105:a930035b6556 | 2034 | if( tcp_session && !udp_query ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 105:a930035b6556 | 2035 | |
klauss | 105:a930035b6556 | 2036 | else if( udp_query ) { |
klauss | 105:a930035b6556 | 2037 | udp_query_send_msg( debug_buf ); |
klauss | 45:c80574f24dc3 | 2038 | } |
klauss | 45:c80574f24dc3 | 2039 | } |
klauss | 104:62646ef786a3 | 2040 | if( debug_uart3 && !( from_eth ) ) pc.printf("debug [on|off|show] - seleciona debugs gerais | lista de debugs \n\r"); |
klauss | 105:a930035b6556 | 2041 | if( from_eth ) { |
klauss | 45:c80574f24dc3 | 2042 | snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, "debug [on|off|show] - seleciona debugs gerais | lista de debugs \n\r" ); |
klauss | 105:a930035b6556 | 2043 | if( tcp_session && !udp_query ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 105:a930035b6556 | 2044 | |
klauss | 105:a930035b6556 | 2045 | else if( udp_query ) { |
klauss | 105:a930035b6556 | 2046 | udp_query_send_msg( debug_buf ); |
klauss | 45:c80574f24dc3 | 2047 | } |
klauss | 45:c80574f24dc3 | 2048 | } |
klauss | 104:62646ef786a3 | 2049 | if( debug_uart3 && !( from_eth ) ) pc.printf("{ flood [ on | off ] | [+|-] } - simula envio de pacotes de audio\n\r"); |
klauss | 105:a930035b6556 | 2050 | if( from_eth ) { |
klauss | 62:07e5bdc9f8f7 | 2051 | snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, "{ flood [ on | off ] | [+|-] } - simula envio de pacotes de audio\n\r"); |
klauss | 105:a930035b6556 | 2052 | if( tcp_session && !udp_query ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 105:a930035b6556 | 2053 | |
klauss | 105:a930035b6556 | 2054 | else if( udp_query ) { |
klauss | 105:a930035b6556 | 2055 | udp_query_send_msg( debug_buf ); |
klauss | 62:07e5bdc9f8f7 | 2056 | } |
klauss | 62:07e5bdc9f8f7 | 2057 | } |
klauss | 105:a930035b6556 | 2058 | |
klauss | 104:62646ef786a3 | 2059 | if( debug_uart3 && !( from_eth ) ) pc.printf("silence <start_ext end_ext> - envia comando de flood off para os ramais no intervalo end_ext - start_ext\n\r"); |
klauss | 105:a930035b6556 | 2060 | if( from_eth ) { |
klauss | 65:0b653cfe95db | 2061 | 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"); |
klauss | 105:a930035b6556 | 2062 | if( tcp_session && !udp_query ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 105:a930035b6556 | 2063 | |
klauss | 105:a930035b6556 | 2064 | else if( udp_query ) { |
klauss | 105:a930035b6556 | 2065 | udp_query_send_msg( debug_buf ); |
klauss | 65:0b653cfe95db | 2066 | } |
klauss | 65:0b653cfe95db | 2067 | } |
klauss | 105:a930035b6556 | 2068 | |
klauss | 104:62646ef786a3 | 2069 | if( debug_uart3 && !( from_eth ) ) pc.printf("++ ext - Header flood on, ext flood on\n\r"); |
klauss | 105:a930035b6556 | 2070 | if( from_eth ) { |
klauss | 62:07e5bdc9f8f7 | 2071 | snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, "++ ext - Header flood on, ext flood on\n\r"); |
klauss | 105:a930035b6556 | 2072 | if( tcp_session && !udp_query ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 105:a930035b6556 | 2073 | |
klauss | 105:a930035b6556 | 2074 | else if( udp_query ) { |
klauss | 105:a930035b6556 | 2075 | udp_query_send_msg( debug_buf ); |
klauss | 45:c80574f24dc3 | 2076 | } |
klauss | 45:c80574f24dc3 | 2077 | } |
klauss | 105:a930035b6556 | 2078 | |
klauss | 104:62646ef786a3 | 2079 | if( debug_uart3 && !( from_eth ) ) pc.printf("-- ext - Header flood off, ext flood off\n\r"); |
klauss | 105:a930035b6556 | 2080 | if( from_eth ) { |
klauss | 66:3f1d22e69e7b | 2081 | snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, "++ ext - Header flood on, ext flood on\n\r"); |
klauss | 105:a930035b6556 | 2082 | if( tcp_session && !udp_query ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 105:a930035b6556 | 2083 | |
klauss | 105:a930035b6556 | 2084 | else if( udp_query ) { |
klauss | 105:a930035b6556 | 2085 | udp_query_send_msg( debug_buf ); |
klauss | 66:3f1d22e69e7b | 2086 | } |
klauss | 66:3f1d22e69e7b | 2087 | } |
klauss | 105:a930035b6556 | 2088 | |
klauss | 104:62646ef786a3 | 2089 | if( debug_uart3 && !( from_eth ) ) pc.printf("rx - Exibe ultimo pacote recebido dos CBx\n\r"); |
klauss | 105:a930035b6556 | 2090 | if( from_eth ) { |
klauss | 64:5b011d5707d2 | 2091 | snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, "rx - Exibe ultimo pacote recebido dos CBx\n\r"); |
klauss | 105:a930035b6556 | 2092 | if( tcp_session && !udp_query ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 105:a930035b6556 | 2093 | |
klauss | 105:a930035b6556 | 2094 | else if( udp_query ) { |
klauss | 105:a930035b6556 | 2095 | udp_query_send_msg( debug_buf ); |
klauss | 64:5b011d5707d2 | 2096 | } |
klauss | 64:5b011d5707d2 | 2097 | } |
klauss | 104:62646ef786a3 | 2098 | if( debug_uart3 && !( from_eth ) ) pc.printf("tx - Exibe ultimo pacote enviado para os CBx\n\r"); |
klauss | 105:a930035b6556 | 2099 | if( from_eth ) { |
klauss | 64:5b011d5707d2 | 2100 | snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, "tx - Exibe ultimo pacote enviado para os CBx\n\r"); |
klauss | 105:a930035b6556 | 2101 | if( tcp_session && !udp_query ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 105:a930035b6556 | 2102 | |
klauss | 105:a930035b6556 | 2103 | else if( udp_query ) { |
klauss | 105:a930035b6556 | 2104 | udp_query_send_msg( debug_buf ); |
klauss | 64:5b011d5707d2 | 2105 | } |
klauss | 64:5b011d5707d2 | 2106 | } |
klauss | 104:62646ef786a3 | 2107 | if( debug_uart3 && !( from_eth ) ) pc.printf("ls | status - Exibe uma lista ordenada por ext do CBx registrados na Header\n\r"); |
klauss | 105:a930035b6556 | 2108 | if( from_eth ) { |
klauss | 64:5b011d5707d2 | 2109 | snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, "ls | status - Exibe uma lista ordenada por ext do CBx registrados na Header\n\r"); |
klauss | 105:a930035b6556 | 2110 | if( tcp_session && !udp_query ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 105:a930035b6556 | 2111 | |
klauss | 105:a930035b6556 | 2112 | else if( udp_query ) { |
klauss | 105:a930035b6556 | 2113 | udp_query_send_msg( debug_buf ); |
klauss | 64:5b011d5707d2 | 2114 | } |
klauss | 64:5b011d5707d2 | 2115 | } |
klauss | 104:62646ef786a3 | 2116 | if( debug_uart3 && !( from_eth ) ) pc.printf("types - Lista os types usados no protocolo de comunicacao Header -- CBx\n\r"); |
klauss | 105:a930035b6556 | 2117 | if( from_eth ) { |
klauss | 64:5b011d5707d2 | 2118 | snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, "types - Lista os types usados no protocolo de comunicacao Header -- CBx\n\r"); |
klauss | 105:a930035b6556 | 2119 | if( tcp_session && !udp_query ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 105:a930035b6556 | 2120 | |
klauss | 105:a930035b6556 | 2121 | else if( udp_query ) { |
klauss | 105:a930035b6556 | 2122 | udp_query_send_msg( debug_buf ); |
klauss | 64:5b011d5707d2 | 2123 | } |
klauss | 64:5b011d5707d2 | 2124 | } |
klauss | 104:62646ef786a3 | 2125 | if( debug_uart3 && !( from_eth ) ) pc.printf("protocol - Exibe formato do pacote seguindo o protocolo de comunicacao Header -- CBx\n\r"); |
klauss | 105:a930035b6556 | 2126 | if( from_eth ) { |
klauss | 64:5b011d5707d2 | 2127 | snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, "protocol - Exibe formato do pacote seguindo o protocolo de comunicacao Header -- CBx\n\r"); |
klauss | 105:a930035b6556 | 2128 | if( tcp_session && !udp_query ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 105:a930035b6556 | 2129 | |
klauss | 105:a930035b6556 | 2130 | else if( udp_query ) { |
klauss | 105:a930035b6556 | 2131 | udp_query_send_msg( debug_buf ); |
klauss | 64:5b011d5707d2 | 2132 | } |
klauss | 64:5b011d5707d2 | 2133 | } |
klauss | 105:a930035b6556 | 2134 | |
klauss | 104:62646ef786a3 | 2135 | if( debug_uart3 && !( from_eth ) ) pc.printf("PROMPT VERSION: V%d\n\r", PVERSION); |
klauss | 105:a930035b6556 | 2136 | if( from_eth ) { |
klauss | 104:62646ef786a3 | 2137 | snprintf( debug_buf,__PROMPT_ETH_BUFFER_SIZE__, "PROMPT VERSION: V%d\n\r", PVERSION); |
klauss | 105:a930035b6556 | 2138 | if( tcp_session && !udp_query ) { |
klauss | 104:62646ef786a3 | 2139 | while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 105:a930035b6556 | 2140 | } else if( udp_query ) { |
klauss | 105:a930035b6556 | 2141 | udp_query_send_msg( debug_buf ); |
klauss | 104:62646ef786a3 | 2142 | } |
klauss | 104:62646ef786a3 | 2143 | } |
klauss | 104:62646ef786a3 | 2144 | //*------------ formatando a saida ----------------*// |
klauss | 105:a930035b6556 | 2145 | strcpy( last_cmd, tmp_cmd ); |
klauss | 105:a930035b6556 | 2146 | bufptr = 0; |
klauss | 105:a930035b6556 | 2147 | for( register int i = 0; i < DEBUGBUFSIZE; i++ ) debug_buf[ i ] = 0; |
klauss | 105:a930035b6556 | 2148 | |
klauss | 105:a930035b6556 | 2149 | if( from_eth ) { |
klauss | 105:a930035b6556 | 2150 | if( tcp_session && !udp_query ) { |
klauss | 105:a930035b6556 | 2151 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "> " ); |
klauss | 105:a930035b6556 | 2152 | if( tcp_session && !udp_query ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 105:a930035b6556 | 2153 | } else if( udp_query ) { |
klauss | 105:a930035b6556 | 2154 | udp_query_send_msg( "> " ); |
klauss | 104:62646ef786a3 | 2155 | } |
klauss | 104:62646ef786a3 | 2156 | } |
klauss | 105:a930035b6556 | 2157 | } |
klauss | 105:a930035b6556 | 2158 | |
klauss | 105:a930035b6556 | 2159 | else if( xmemmatch( (uint8_t*)debug_buf, (uint8_t*) "callme ", 7 )) { |
klauss | 105:a930035b6556 | 2160 | miss_match = false; |
klauss | 105:a930035b6556 | 2161 | int ext,port; |
klauss | 105:a930035b6556 | 2162 | char cmd[ 16 ]; |
klauss | 105:a930035b6556 | 2163 | |
klauss | 105:a930035b6556 | 2164 | ext = atoi( debug_buf + 7 ); |
klauss | 105:a930035b6556 | 2165 | port = convert_ext_to_port( ext ); |
klauss | 105:a930035b6556 | 2166 | |
klauss | 105:a930035b6556 | 2167 | strcpy( cmd, ( ext % 2 ) ? "call init B" : "call init A" ); |
klauss | 105:a930035b6556 | 2168 | |
klauss | 105:a930035b6556 | 2169 | if( ext % 2 ) ext--; |
klauss | 105:a930035b6556 | 2170 | |
klauss | 105:a930035b6556 | 2171 | promptcb_last_ext = ext; |
klauss | 105:a930035b6556 | 2172 | promptcb_last_port = port; |
klauss | 105:a930035b6556 | 2173 | |
klauss | 105:a930035b6556 | 2174 | int tmp = strlen( cmd ); |
klauss | 105:a930035b6556 | 2175 | cmd[ tmp ] = 0x0D; |
klauss | 105:a930035b6556 | 2176 | cmd[ tmp + 1 ] = 0x00; |
klauss | 105:a930035b6556 | 2177 | strcpy( promptcb_last_cmd, cmd ); |
klauss | 105:a930035b6556 | 2178 | |
klauss | 105:a930035b6556 | 2179 | if( debug_uart3 && !( from_eth ) ) pc.printf("\r\next=%d port=%d\r\ncmd=%s\r\n", ext, port, cmd ); |
klauss | 105:a930035b6556 | 2180 | |
klauss | 105:a930035b6556 | 2181 | if( debug_uart3 && !( from_eth ) ) pc.printf("\n\r--------------------------------------------------------\n\r"); |
klauss | 105:a930035b6556 | 2182 | for( uint16_t i = 0; i < strlen( cmd ) ; i++ ) if( debug_uart3 && !( from_eth ) ) pc.printf( "%02x ", cmd[ i ] ); |
klauss | 105:a930035b6556 | 2183 | |
klauss | 105:a930035b6556 | 2184 | send2callboxes( build_cb_package( ext, port, __PROMPT__, cmd, id_msg++, CB_BUFFER_SIZE - __VZ_HEADER_OFFSET__, write_buffer ) ); |
klauss | 105:a930035b6556 | 2185 | if( debug_uart3 && !( from_eth ) ) pc.printf("\n\r--------------------------------------------------------\n\r"); |
klauss | 105:a930035b6556 | 2186 | for( uint16_t i = 0; i < 300 ; i++ ) { |
klauss | 105:a930035b6556 | 2187 | if( debug_uart3 && !( from_eth ) ) pc.printf( "%02x ", write_buffer[ i ] ); |
klauss | 105:a930035b6556 | 2188 | if( i != 0 && !( ( i + 1 ) % 30 ) ) if( debug_uart3 && !( from_eth ) ) pc.printf("\n\r"); |
klauss | 105:a930035b6556 | 2189 | } |
klauss | 105:a930035b6556 | 2190 | |
klauss | 105:a930035b6556 | 2191 | |
klauss | 105:a930035b6556 | 2192 | if( debug_uart3 && !( from_eth ) ) pc.printf("\n\rComando enviado\n\r"); |
klauss | 105:a930035b6556 | 2193 | |
klauss | 105:a930035b6556 | 2194 | if( from_eth ) { |
klauss | 105:a930035b6556 | 2195 | char eth_msg[ 512 ]; |
klauss | 105:a930035b6556 | 2196 | snprintf( eth_msg, 512 - 1, "\r\next=%d port=%d\r\ncmd=%s\r\n\n\rComando enviado\n\r", ext, port, cmd ); |
klauss | 105:a930035b6556 | 2197 | if( tcp_session && !udp_query ) { |
klauss | 105:a930035b6556 | 2198 | tcp_client.send_all( eth_msg, strlen( eth_msg ) ); |
klauss | 105:a930035b6556 | 2199 | } else if( udp_query ) { |
klauss | 105:a930035b6556 | 2200 | udp_query_send_msg( eth_msg ); |
klauss | 105:a930035b6556 | 2201 | } |
klauss | 105:a930035b6556 | 2202 | } |
klauss | 105:a930035b6556 | 2203 | |
klauss | 105:a930035b6556 | 2204 | bufptr = 0; |
klauss | 105:a930035b6556 | 2205 | for( register int i = 0; i < DEBUGBUFSIZE; i++ ) debug_buf[ i ] = 0; |
klauss | 105:a930035b6556 | 2206 | } |
klauss | 105:a930035b6556 | 2207 | |
klauss | 105:a930035b6556 | 2208 | if( miss_match ) { |
klauss | 105:a930035b6556 | 2209 | if( debug_uart3 && !( from_eth ) ) pc.printf("\n\r> %s: command not found\n\r", debug_buf ); |
klauss | 105:a930035b6556 | 2210 | if( from_eth ) { |
klauss | 105:a930035b6556 | 2211 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "> %s: command not found\n ", debug_buf ); |
klauss | 105:a930035b6556 | 2212 | if( tcp_session && !udp_query ) { |
klauss | 105:a930035b6556 | 2213 | tcp_client.send_all( debug_buf, strlen( debug_buf ) ); |
klauss | 105:a930035b6556 | 2214 | } else if( udp_query ) { |
klauss | 105:a930035b6556 | 2215 | udp_query_send_msg( debug_buf ); |
klauss | 105:a930035b6556 | 2216 | } |
klauss | 105:a930035b6556 | 2217 | } |
klauss | 105:a930035b6556 | 2218 | } else { |
klauss | 105:a930035b6556 | 2219 | if( from_eth && strlen( debug_buf ) > 2 ) strcpy( last_cmd, tmp_cmd ); |
klauss | 105:a930035b6556 | 2220 | |
klauss | 105:a930035b6556 | 2221 | else if( strlen( debug_buf ) > 2 ) strcpy( last_cmd, tmp_cmd ); |
klauss | 105:a930035b6556 | 2222 | } |
klauss | 105:a930035b6556 | 2223 | } |
klauss | 105:a930035b6556 | 2224 | if( b == 0x0D || bufret == 1 || bufptr > DEBUGBUFSIZE ) { |
klauss | 105:a930035b6556 | 2225 | bufret = 0; |
klauss | 105:a930035b6556 | 2226 | |
klauss | 105:a930035b6556 | 2227 | if( debug_uart3 && !( from_eth ) ) pc.putc(0x0A); |
klauss | 105:a930035b6556 | 2228 | if( debug_uart3 && !( from_eth ) ) pc.putc(0x0D); |
klauss | 105:a930035b6556 | 2229 | if( debug_uart3 && !( from_eth ) ) pc.printf("> "); |
klauss | 105:a930035b6556 | 2230 | |
klauss | 105:a930035b6556 | 2231 | if( from_eth ) |
klauss | 105:a930035b6556 | 2232 | { |
klauss | 106:a34fcf9f0e02 | 2233 | if( strlen( debug_buf ) > 0 ) |
klauss | 105:a930035b6556 | 2234 | { |
klauss | 106:a34fcf9f0e02 | 2235 | |
klauss | 106:a34fcf9f0e02 | 2236 | if( debug_buf[ strlen( debug_buf ) - 1 ] == '\r' || debug_buf[ strlen( debug_buf ) - 1 ] == '\n' ) |
klauss | 106:a34fcf9f0e02 | 2237 | { |
klauss | 106:a34fcf9f0e02 | 2238 | //strcat( debug_buf, "> " ); |
klauss | 106:a34fcf9f0e02 | 2239 | strcpy( debug_buf, "> " ); |
klauss | 106:a34fcf9f0e02 | 2240 | } else { |
klauss | 106:a34fcf9f0e02 | 2241 | //strcat( debug_buf, "\n\r> " ); |
klauss | 106:a34fcf9f0e02 | 2242 | strcpy( debug_buf, "\n\r> " ); |
klauss | 106:a34fcf9f0e02 | 2243 | } |
klauss | 106:a34fcf9f0e02 | 2244 | }else{ |
klauss | 106:a34fcf9f0e02 | 2245 | |
klauss | 105:a930035b6556 | 2246 | } |
klauss | 104:62646ef786a3 | 2247 | |
klauss | 105:a930035b6556 | 2248 | if( tcp_session && !udp_query ) |
klauss | 105:a930035b6556 | 2249 | { |
klauss | 105:a930035b6556 | 2250 | tcp_client.send_all( debug_buf, strlen( debug_buf ) ); |
klauss | 105:a930035b6556 | 2251 | } else if( udp_query ) { |
klauss | 106:a34fcf9f0e02 | 2252 | |
klauss | 106:a34fcf9f0e02 | 2253 | udp_query_send_msg( debug_buf ); |
klauss | 106:a34fcf9f0e02 | 2254 | |
klauss | 105:a930035b6556 | 2255 | } |
klauss | 105:a930035b6556 | 2256 | for( register uint16_t i = 0; i < __PROMPT_ETH_BUFFER_SIZE__; i++ ) eth_buffer[ i ] = 0; |
klauss | 106:a34fcf9f0e02 | 2257 | |
klauss | 105:a930035b6556 | 2258 | debug_buf = __debug_buf__; |
klauss | 106:a34fcf9f0e02 | 2259 | |
klauss | 105:a930035b6556 | 2260 | bufptr = last_bufptr; |
klauss | 106:a34fcf9f0e02 | 2261 | |
klauss | 105:a930035b6556 | 2262 | } |
klauss | 105:a930035b6556 | 2263 | else |
klauss | 105:a930035b6556 | 2264 | { |
klauss | 104:62646ef786a3 | 2265 | bufptr = 0; |
klauss | 104:62646ef786a3 | 2266 | last_bufptr = 0; |
klauss | 104:62646ef786a3 | 2267 | for( register int i = 0; i < DEBUGBUFSIZE; i++ ) debug_buf[ i ] = 0; |
klauss | 27:98f824719d1c | 2268 | } |
klauss | 105:a930035b6556 | 2269 | } |
klauss | 105:a930035b6556 | 2270 | return( NULL ); |
klauss | 105:a930035b6556 | 2271 | }//fim prompt_process |
klauss | 105:a930035b6556 | 2272 | |
klauss | 105:a930035b6556 | 2273 | |
klauss | 105:a930035b6556 | 2274 | // operantion with the system config files |
klauss | 105:a930035b6556 | 2275 | void files( const char type ) |
klauss | 105:a930035b6556 | 2276 | { |
klauss | 105:a930035b6556 | 2277 | // show files |
klauss | 105:a930035b6556 | 2278 | if (type == 's' ) { |
klauss | 106:a34fcf9f0e02 | 2279 | |
klauss | 105:a930035b6556 | 2280 | if( debug_uart3 && !( from_eth ) ) pc.printf("Header IP " ); |
klauss | 105:a930035b6556 | 2281 | if( from_eth ) { |
klauss | 105:a930035b6556 | 2282 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Header IP " ); |
klauss | 105:a930035b6556 | 2283 | if( tcp_session && !udp_query ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 105:a930035b6556 | 2284 | |
klauss | 105:a930035b6556 | 2285 | else if( udp_query ) { |
klauss | 105:a930035b6556 | 2286 | udp_query_send_msg( debug_buf ); |
klauss | 105:a930035b6556 | 2287 | } |
klauss | 105:a930035b6556 | 2288 | } |
klauss | 105:a930035b6556 | 2289 | |
klauss | 105:a930035b6556 | 2290 | cat("/qspi/myip.txt"); |
klauss | 105:a930035b6556 | 2291 | |
klauss | 105:a930035b6556 | 2292 | if( debug_uart3 && !( from_eth ) ) pc.printf("Header ext "); |
klauss | 105:a930035b6556 | 2293 | if( from_eth ) { |
klauss | 105:a930035b6556 | 2294 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Header ext " ); |
klauss | 105:a930035b6556 | 2295 | if( tcp_session && !udp_query ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 105:a930035b6556 | 2296 | |
klauss | 105:a930035b6556 | 2297 | else if( udp_query ) { |
klauss | 105:a930035b6556 | 2298 | udp_query_send_msg( debug_buf ); |
klauss | 105:a930035b6556 | 2299 | } |
klauss | 105:a930035b6556 | 2300 | } |
klauss | 105:a930035b6556 | 2301 | |
klauss | 105:a930035b6556 | 2302 | cat("/qspi/myext.txt"); |
klauss | 105:a930035b6556 | 2303 | |
klauss | 105:a930035b6556 | 2304 | if( debug_uart3 && !( from_eth ) ) pc.printf("Header port "); |
klauss | 105:a930035b6556 | 2305 | if( from_eth ) { |
klauss | 105:a930035b6556 | 2306 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Header port " ); |
klauss | 105:a930035b6556 | 2307 | if( tcp_session && !udp_query ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 105:a930035b6556 | 2308 | |
klauss | 105:a930035b6556 | 2309 | else if( udp_query ) { |
klauss | 105:a930035b6556 | 2310 | udp_query_send_msg( debug_buf ); |
klauss | 105:a930035b6556 | 2311 | } |
klauss | 105:a930035b6556 | 2312 | } |
klauss | 105:a930035b6556 | 2313 | |
klauss | 105:a930035b6556 | 2314 | cat("/qspi/mysipport.txt"); |
klauss | 105:a930035b6556 | 2315 | |
klauss | 105:a930035b6556 | 2316 | if( debug_uart3 && !( from_eth ) ) pc.printf("Server IP "); |
klauss | 105:a930035b6556 | 2317 | if( from_eth ) { |
klauss | 105:a930035b6556 | 2318 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Server IP " ); |
klauss | 105:a930035b6556 | 2319 | if( tcp_session && !udp_query ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 105:a930035b6556 | 2320 | |
klauss | 105:a930035b6556 | 2321 | else if( udp_query ) { |
klauss | 105:a930035b6556 | 2322 | udp_query_send_msg( debug_buf ); |
klauss | 105:a930035b6556 | 2323 | } |
klauss | 105:a930035b6556 | 2324 | } |
klauss | 105:a930035b6556 | 2325 | |
klauss | 105:a930035b6556 | 2326 | cat("/qspi/serverip.txt"); |
klauss | 105:a930035b6556 | 2327 | |
klauss | 105:a930035b6556 | 2328 | if( debug_uart3 && !( from_eth ) ) pc.printf("Server ext "); |
klauss | 105:a930035b6556 | 2329 | if( from_eth ) { |
klauss | 105:a930035b6556 | 2330 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Server ext " ); |
klauss | 105:a930035b6556 | 2331 | if( tcp_session && !udp_query ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 105:a930035b6556 | 2332 | |
klauss | 105:a930035b6556 | 2333 | else if( udp_query ) { |
klauss | 105:a930035b6556 | 2334 | udp_query_send_msg( debug_buf ); |
klauss | 105:a930035b6556 | 2335 | } |
klauss | 105:a930035b6556 | 2336 | } |
klauss | 105:a930035b6556 | 2337 | |
klauss | 105:a930035b6556 | 2338 | cat("/qspi/peerext.txt"); |
klauss | 105:a930035b6556 | 2339 | |
klauss | 105:a930035b6556 | 2340 | if( debug_uart3 && !( from_eth ) ) pc.printf("Server port "); |
klauss | 105:a930035b6556 | 2341 | if( from_eth ) { |
klauss | 105:a930035b6556 | 2342 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Server port " ); |
klauss | 105:a930035b6556 | 2343 | if( tcp_session && !udp_query ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 105:a930035b6556 | 2344 | |
klauss | 105:a930035b6556 | 2345 | else if( udp_query ) { |
klauss | 105:a930035b6556 | 2346 | udp_query_send_msg( debug_buf ); |
klauss | 105:a930035b6556 | 2347 | } |
klauss | 105:a930035b6556 | 2348 | } |
klauss | 105:a930035b6556 | 2349 | cat("/qspi/serverport.txt"); |
klauss | 105:a930035b6556 | 2350 | |
klauss | 105:a930035b6556 | 2351 | if( debug_uart3 && !( from_eth ) ) pc.printf("Mascara de rede "); |
klauss | 105:a930035b6556 | 2352 | if( from_eth ) { |
klauss | 105:a930035b6556 | 2353 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Mascara de rede " ); |
klauss | 105:a930035b6556 | 2354 | if( tcp_session && !udp_query ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 105:a930035b6556 | 2355 | |
klauss | 105:a930035b6556 | 2356 | else if( udp_query ) { |
klauss | 105:a930035b6556 | 2357 | udp_query_send_msg( debug_buf ); |
klauss | 105:a930035b6556 | 2358 | } |
klauss | 105:a930035b6556 | 2359 | } |
klauss | 105:a930035b6556 | 2360 | cat("/qspi/mymask.txt"); |
klauss | 105:a930035b6556 | 2361 | |
klauss | 105:a930035b6556 | 2362 | if( debug_uart3 && !( from_eth ) ) pc.printf("Gateway IP "); |
klauss | 105:a930035b6556 | 2363 | if( from_eth ) { |
klauss | 105:a930035b6556 | 2364 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Gateway IP " ); |
klauss | 105:a930035b6556 | 2365 | if( tcp_session && !udp_query ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 105:a930035b6556 | 2366 | |
klauss | 105:a930035b6556 | 2367 | else if( udp_query ) { |
klauss | 105:a930035b6556 | 2368 | udp_query_send_msg( debug_buf ); |
klauss | 105:a930035b6556 | 2369 | } |
klauss | 105:a930035b6556 | 2370 | } |
klauss | 105:a930035b6556 | 2371 | cat("/qspi/mygateway.txt"); |
klauss | 105:a930035b6556 | 2372 | |
klauss | 105:a930035b6556 | 2373 | if( debug_uart3 && !( from_eth ) ) pc.printf("UDP Port "); |
klauss | 105:a930035b6556 | 2374 | if( from_eth ) { |
klauss | 105:a930035b6556 | 2375 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "UDP Port " ); |
klauss | 105:a930035b6556 | 2376 | if( tcp_session && !udp_query ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 105:a930035b6556 | 2377 | |
klauss | 105:a930035b6556 | 2378 | else if( udp_query ) { |
klauss | 105:a930035b6556 | 2379 | udp_query_send_msg( debug_buf ); |
klauss | 105:a930035b6556 | 2380 | } |
klauss | 105:a930035b6556 | 2381 | } |
klauss | 105:a930035b6556 | 2382 | |
klauss | 105:a930035b6556 | 2383 | cat("/qspi/udpport.txt"); |
klauss | 105:a930035b6556 | 2384 | |
klauss | 105:a930035b6556 | 2385 | if( debug_uart3 && !( from_eth ) ) pc.printf("TCP Port "); |
klauss | 105:a930035b6556 | 2386 | if( from_eth ) { |
klauss | 105:a930035b6556 | 2387 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "TCP Port " ); |
klauss | 105:a930035b6556 | 2388 | if( tcp_session && !udp_query ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 105:a930035b6556 | 2389 | |
klauss | 105:a930035b6556 | 2390 | else if( udp_query ) { |
klauss | 105:a930035b6556 | 2391 | udp_query_send_msg( debug_buf ); |
klauss | 105:a930035b6556 | 2392 | } |
klauss | 105:a930035b6556 | 2393 | } |
klauss | 105:a930035b6556 | 2394 | |
klauss | 105:a930035b6556 | 2395 | cat("/qspi/tcpport.txt"); |
klauss | 105:a930035b6556 | 2396 | |
klauss | 105:a930035b6556 | 2397 | if( debug_uart3 && !( from_eth ) ) pc.printf("FW Server IP "); |
klauss | 105:a930035b6556 | 2398 | if( from_eth ) { |
klauss | 105:a930035b6556 | 2399 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "FW Server IP " ); |
klauss | 105:a930035b6556 | 2400 | if( tcp_session && !udp_query ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 105:a930035b6556 | 2401 | |
klauss | 105:a930035b6556 | 2402 | else if( udp_query ) { |
klauss | 105:a930035b6556 | 2403 | udp_query_send_msg( debug_buf ); |
klauss | 105:a930035b6556 | 2404 | } |
klauss | 105:a930035b6556 | 2405 | } |
klauss | 105:a930035b6556 | 2406 | |
klauss | 105:a930035b6556 | 2407 | cat("/qspi/fw_ip.txt"); |
klauss | 105:a930035b6556 | 2408 | |
klauss | 105:a930035b6556 | 2409 | if( debug_uart3 && !( from_eth ) ) pc.printf("FW Server Port "); |
klauss | 105:a930035b6556 | 2410 | if( from_eth ) { |
klauss | 105:a930035b6556 | 2411 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "FW Server Port " ); |
klauss | 105:a930035b6556 | 2412 | if( tcp_session && !udp_query ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 105:a930035b6556 | 2413 | |
klauss | 105:a930035b6556 | 2414 | else if( udp_query ) { |
klauss | 105:a930035b6556 | 2415 | udp_query_send_msg( debug_buf ); |
klauss | 105:a930035b6556 | 2416 | } |
klauss | 105:a930035b6556 | 2417 | } |
klauss | 105:a930035b6556 | 2418 | |
klauss | 105:a930035b6556 | 2419 | cat("/qspi/fw_port.txt"); |
klauss | 105:a930035b6556 | 2420 | |
klauss | 105:a930035b6556 | 2421 | if( debug_uart3 && !( from_eth ) ) pc.printf("Max Ext "); |
klauss | 105:a930035b6556 | 2422 | if( from_eth ) { |
klauss | 105:a930035b6556 | 2423 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Max Ext " ); |
klauss | 105:a930035b6556 | 2424 | if( tcp_session && !udp_query ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 105:a930035b6556 | 2425 | |
klauss | 105:a930035b6556 | 2426 | else if( udp_query ) { |
klauss | 105:a930035b6556 | 2427 | udp_query_send_msg( debug_buf ); |
klauss | 105:a930035b6556 | 2428 | } |
klauss | 105:a930035b6556 | 2429 | } |
klauss | 105:a930035b6556 | 2430 | |
klauss | 105:a930035b6556 | 2431 | cat("/qspi/maxext.txt"); |
klauss | 105:a930035b6556 | 2432 | |
klauss | 105:a930035b6556 | 2433 | if( debug_uart3 && !( from_eth ) ) pc.printf("Min Ext "); |
klauss | 105:a930035b6556 | 2434 | if( from_eth ) { |
klauss | 105:a930035b6556 | 2435 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Min Ext " ); |
klauss | 105:a930035b6556 | 2436 | if( tcp_session && !udp_query ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 105:a930035b6556 | 2437 | |
klauss | 105:a930035b6556 | 2438 | else if( udp_query ) { |
klauss | 105:a930035b6556 | 2439 | udp_query_send_msg( debug_buf ); |
klauss | 105:a930035b6556 | 2440 | } |
klauss | 105:a930035b6556 | 2441 | } |
klauss | 105:a930035b6556 | 2442 | |
klauss | 105:a930035b6556 | 2443 | cat("/qspi/minext.txt"); |
klauss | 106:a34fcf9f0e02 | 2444 | |
klauss | 106:a34fcf9f0e02 | 2445 | if( debug_uart3 && !( from_eth ) ) pc.printf("Shift Port "); |
klauss | 106:a34fcf9f0e02 | 2446 | if( from_eth ) { |
klauss | 106:a34fcf9f0e02 | 2447 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Shift Port " ); |
klauss | 106:a34fcf9f0e02 | 2448 | if( tcp_session && !udp_query ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 105:a930035b6556 | 2449 | |
klauss | 106:a34fcf9f0e02 | 2450 | else if( udp_query ) { |
klauss | 106:a34fcf9f0e02 | 2451 | udp_query_send_msg( debug_buf ); |
klauss | 106:a34fcf9f0e02 | 2452 | } |
klauss | 106:a34fcf9f0e02 | 2453 | } |
klauss | 106:a34fcf9f0e02 | 2454 | |
klauss | 106:a34fcf9f0e02 | 2455 | cat("/qspi/shift_port.txt"); |
klauss | 106:a34fcf9f0e02 | 2456 | |
klauss | 106:a34fcf9f0e02 | 2457 | |
klauss | 105:a930035b6556 | 2458 | //*------------ formatando a saida ----------------*// |
klauss | 105:a930035b6556 | 2459 | strcpy( last_cmd, tmp_cmd ); |
klauss | 105:a930035b6556 | 2460 | bufptr = 0; |
klauss | 105:a930035b6556 | 2461 | for( register int i = 0; i < DEBUGBUFSIZE; i++ ) debug_buf[ i ] = 0; |
klauss | 105:a930035b6556 | 2462 | |
klauss | 105:a930035b6556 | 2463 | if( from_eth ) { |
klauss | 106:a34fcf9f0e02 | 2464 | |
klauss | 105:a930035b6556 | 2465 | if( tcp_session && !udp_query ) { |
klauss | 105:a930035b6556 | 2466 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "> " ); |
klauss | 105:a930035b6556 | 2467 | if( tcp_session && !udp_query ) while( !( tcp_client.send_all( debug_buf, strlen( debug_buf ) ) ) ); |
klauss | 105:a930035b6556 | 2468 | } else if( udp_query ) { |
klauss | 105:a930035b6556 | 2469 | udp_query_send_msg( "> " ); |
klauss | 106:a34fcf9f0e02 | 2470 | |
klauss | 105:a930035b6556 | 2471 | } |
klauss | 105:a930035b6556 | 2472 | } |
klauss | 105:a930035b6556 | 2473 | } |
klauss | 105:a930035b6556 | 2474 | |
klauss | 105:a930035b6556 | 2475 | if (type == 'c' ) { |
klauss | 105:a930035b6556 | 2476 | // close all files |
klauss | 105:a930035b6556 | 2477 | if( fip ) fclose( fip ); |
klauss | 105:a930035b6556 | 2478 | if( fmask ) fclose( fmask ); |
klauss | 105:a930035b6556 | 2479 | if( fgate ) fclose( fgate ); |
klauss | 105:a930035b6556 | 2480 | if( fport )fclose( fport ); |
klauss | 105:a930035b6556 | 2481 | if( fsip ) fclose( fsip ); |
klauss | 105:a930035b6556 | 2482 | if( fsport ) fclose( fsport ); |
klauss | 105:a930035b6556 | 2483 | if( fext ) fclose( fext ); |
klauss | 105:a930035b6556 | 2484 | if( fserext ) fclose( fserext ); |
klauss | 105:a930035b6556 | 2485 | if( fudpport ) fclose( fudpport ); |
klauss | 105:a930035b6556 | 2486 | if( ftcpport ) fclose( ftcpport ); |
klauss | 105:a930035b6556 | 2487 | if( fmax ) fclose( fmax ); |
klauss | 105:a930035b6556 | 2488 | if( fmin ) fclose( fmin ); |
klauss | 105:a930035b6556 | 2489 | if( ffwip ) fclose( ffwip ); |
klauss | 105:a930035b6556 | 2490 | if( ffwport) fclose( ffwport ); |
klauss | 106:a34fcf9f0e02 | 2491 | if( fshift_port ) fclose ( fshift_port ); |
klauss | 105:a930035b6556 | 2492 | } |
klauss | 105:a930035b6556 | 2493 | |
klauss | 105:a930035b6556 | 2494 | if (type == 'i' ) { |
klauss | 106:a34fcf9f0e02 | 2495 | |
klauss | 105:a930035b6556 | 2496 | // Check if files exist, if not create the files |
klauss | 105:a930035b6556 | 2497 | //fixme criar um bool pra cada file |
klauss | 105:a930035b6556 | 2498 | bool exists = true; |
klauss | 105:a930035b6556 | 2499 | |
klauss | 105:a930035b6556 | 2500 | fip = fopen("/qspi/myip.txt", "r"); |
klauss | 105:a930035b6556 | 2501 | if( fip == NULL) { |
klauss | 105:a930035b6556 | 2502 | set_ip( __MY_IP__ ); |
klauss | 105:a930035b6556 | 2503 | exists = false; |
klauss | 105:a930035b6556 | 2504 | } |
klauss | 105:a930035b6556 | 2505 | |
klauss | 105:a930035b6556 | 2506 | fserext = fopen("/qspi/myext.txt", "r"); |
klauss | 105:a930035b6556 | 2507 | if( fserext == NULL ) { |
klauss | 105:a930035b6556 | 2508 | set_header_ext( __MY_EXT__ ); |
klauss | 105:a930035b6556 | 2509 | exists = false; |
klauss | 105:a930035b6556 | 2510 | } |
klauss | 105:a930035b6556 | 2511 | |
klauss | 105:a930035b6556 | 2512 | fport = fopen("/qspi/mysipport.txt", "r"); |
klauss | 105:a930035b6556 | 2513 | if (fport == NULL) { |
klauss | 105:a930035b6556 | 2514 | set_header_sip_port( __MY_PORT__ ); |
klauss | 105:a930035b6556 | 2515 | exists = false; |
klauss | 105:a930035b6556 | 2516 | } |
klauss | 105:a930035b6556 | 2517 | |
klauss | 105:a930035b6556 | 2518 | fsip = fopen("/qspi/serverip.txt", "r"); |
klauss | 105:a930035b6556 | 2519 | if (fsip == NULL) { |
klauss | 105:a930035b6556 | 2520 | set_server_ip( __SERVER_IP__ ); |
klauss | 105:a930035b6556 | 2521 | exists = false; |
klauss | 105:a930035b6556 | 2522 | } |
klauss | 105:a930035b6556 | 2523 | |
klauss | 105:a930035b6556 | 2524 | fext = fopen("/qspi/peerext.txt", "r"); |
klauss | 105:a930035b6556 | 2525 | if ( fext == NULL ) { |
klauss | 105:a930035b6556 | 2526 | set_server_ext( __PEER_EXT__ ); |
klauss | 105:a930035b6556 | 2527 | exists = false; |
klauss | 105:a930035b6556 | 2528 | } |
klauss | 105:a930035b6556 | 2529 | |
klauss | 105:a930035b6556 | 2530 | fsport = fopen("/qspi/serverport.txt", "r"); |
klauss | 105:a930035b6556 | 2531 | if (fsport == NULL) { |
klauss | 105:a930035b6556 | 2532 | set_server_port( __SERVER_PORT__ ); |
klauss | 105:a930035b6556 | 2533 | exists = false; |
klauss | 105:a930035b6556 | 2534 | } |
klauss | 105:a930035b6556 | 2535 | |
klauss | 105:a930035b6556 | 2536 | fmask = fopen("/qspi/mymask.txt", "r"); |
klauss | 105:a930035b6556 | 2537 | if (fmask == NULL) { |
klauss | 105:a930035b6556 | 2538 | set_mask( __MY_MSK__ ); |
klauss | 105:a930035b6556 | 2539 | exists = false; |
klauss | 105:a930035b6556 | 2540 | } |
klauss | 105:a930035b6556 | 2541 | |
klauss | 105:a930035b6556 | 2542 | fgate = fopen("/qspi/mygateway.txt", "r"); |
klauss | 105:a930035b6556 | 2543 | if (fgate == NULL) { |
klauss | 105:a930035b6556 | 2544 | set_gateway( __MY_GTW__ ); |
klauss | 105:a930035b6556 | 2545 | exists = false; |
klauss | 105:a930035b6556 | 2546 | } |
klauss | 105:a930035b6556 | 2547 | |
klauss | 105:a930035b6556 | 2548 | fudpport = fopen("/qspi/udpport.txt", "r" ); |
klauss | 105:a930035b6556 | 2549 | if( fudpport == NULL ) { |
klauss | 105:a930035b6556 | 2550 | set_udp_port_listener( UDP_PORT_LISTENER ); |
klauss | 105:a930035b6556 | 2551 | exists = false; |
klauss | 105:a930035b6556 | 2552 | } |
klauss | 105:a930035b6556 | 2553 | |
klauss | 105:a930035b6556 | 2554 | ftcpport = fopen("/qspi/tcpport.txt", "r" ); |
klauss | 105:a930035b6556 | 2555 | if( ftcpport == NULL ) { |
klauss | 105:a930035b6556 | 2556 | set_tcp_port_listener( TCP_PORT_LISTENER ); |
klauss | 105:a930035b6556 | 2557 | exists = false; |
klauss | 105:a930035b6556 | 2558 | } |
klauss | 105:a930035b6556 | 2559 | |
klauss | 105:a930035b6556 | 2560 | ffwip = fopen("/qspi/fw_ip.txt", "r" ); |
klauss | 105:a930035b6556 | 2561 | if( ffwip == NULL ) { |
klauss | 105:a930035b6556 | 2562 | set_fw_ip( __FW_SERVER_IP__ ); |
klauss | 105:a930035b6556 | 2563 | exists = false; |
klauss | 105:a930035b6556 | 2564 | } |
klauss | 105:a930035b6556 | 2565 | |
klauss | 105:a930035b6556 | 2566 | ffwport = fopen("/qspi/fw_port.txt", "r" ); |
klauss | 105:a930035b6556 | 2567 | if( ffwport == NULL ) { |
klauss | 105:a930035b6556 | 2568 | set_fw_port( __FW_SERVER_PORT__ ); |
klauss | 105:a930035b6556 | 2569 | exists = false; |
klauss | 105:a930035b6556 | 2570 | } |
klauss | 105:a930035b6556 | 2571 | |
klauss | 105:a930035b6556 | 2572 | fmax = fopen("/qspi/maxext.txt", "r" ); |
klauss | 105:a930035b6556 | 2573 | if( fmax == NULL ) { |
klauss | 105:a930035b6556 | 2574 | set_max_ext( MAX_EXT ); |
klauss | 105:a930035b6556 | 2575 | exists = false; |
klauss | 105:a930035b6556 | 2576 | } |
klauss | 105:a930035b6556 | 2577 | |
klauss | 105:a930035b6556 | 2578 | fmin = fopen("/qspi/minext.txt", "r" ); |
klauss | 105:a930035b6556 | 2579 | if( fmin == NULL ) { |
klauss | 106:a34fcf9f0e02 | 2580 | if( debug_file ) debug_msg("Don't exist /qspi/minext.txt"); |
klauss | 105:a930035b6556 | 2581 | set_min_ext( MIN_EXT ); |
klauss | 105:a930035b6556 | 2582 | exists = false; |
klauss | 105:a930035b6556 | 2583 | } |
klauss | 106:a34fcf9f0e02 | 2584 | |
klauss | 106:a34fcf9f0e02 | 2585 | fshift_port = fopen("/qspi/shift_port.txt", "r" ); |
klauss | 106:a34fcf9f0e02 | 2586 | if( fshift_port == NULL ) |
klauss | 106:a34fcf9f0e02 | 2587 | { |
klauss | 106:a34fcf9f0e02 | 2588 | if( debug_file ) debug_msg("Don't exist /qspi/shift_port.txt"); |
klauss | 106:a34fcf9f0e02 | 2589 | set_shift_port( SHIFT_PORT ); |
klauss | 106:a34fcf9f0e02 | 2590 | exists = false; |
klauss | 106:a34fcf9f0e02 | 2591 | } |
klauss | 106:a34fcf9f0e02 | 2592 | |
klauss | 105:a930035b6556 | 2593 | if( !exists ) { |
klauss | 105:a930035b6556 | 2594 | if( debug_uart3 && !( from_eth ) ) pc.printf("\n\rDefault configurations set!\n\r"); |
klauss | 105:a930035b6556 | 2595 | if( from_eth ) { |
klauss | 105:a930035b6556 | 2596 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "Default configurations set!\n\r"); |
klauss | 105:a930035b6556 | 2597 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 105:a930035b6556 | 2598 | if( tcp_session && !udp_query ) { |
klauss | 105:a930035b6556 | 2599 | tcp_client.send_all( debug_buf, strlen( debug_buf ) ); |
klauss | 105:a930035b6556 | 2600 | bufptr = 0; |
klauss | 105:a930035b6556 | 2601 | for( register int i = 0; i < DEBUGBUFSIZE; i++ ) debug_buf[ i ] = 0; |
klauss | 62:07e5bdc9f8f7 | 2602 | } |
klauss | 19:ab2088e0dec6 | 2603 | } |
klauss | 105:a930035b6556 | 2604 | } |
klauss | 105:a930035b6556 | 2605 | reset_leds(); |
klauss | 105:a930035b6556 | 2606 | } |
klauss | 105:a930035b6556 | 2607 | |
klauss | 105:a930035b6556 | 2608 | if (type == 'r' ) { |
klauss | 105:a930035b6556 | 2609 | // Just open for read |
klauss | 106:a34fcf9f0e02 | 2610 | |
klauss | 105:a930035b6556 | 2611 | fip = fopen("/qspi/myip.txt", "r"); |
klauss | 105:a930035b6556 | 2612 | fmask = fopen("/qspi/mymask.txt", "r"); |
klauss | 105:a930035b6556 | 2613 | fgate = fopen("/qspi/mygateway.txt", "r"); |
klauss | 105:a930035b6556 | 2614 | fport = fopen("/qspi/mysipport.txt", "r"); |
klauss | 105:a930035b6556 | 2615 | fsip = fopen("/qspi/serverip.txt", "r"); |
klauss | 105:a930035b6556 | 2616 | fsport = fopen("/qspi/serverport.txt", "r"); |
klauss | 105:a930035b6556 | 2617 | fext = fopen( "/qspi/myext.txt", "r" ); |
klauss | 105:a930035b6556 | 2618 | fserext = fopen( "/qspi/peerext.txt", "r" ); |
klauss | 105:a930035b6556 | 2619 | fudpport = fopen( "/qspi/udpport.txt", "r" ); |
klauss | 105:a930035b6556 | 2620 | ftcpport = fopen( "/qspi/tcpport.txt", "r" ); |
klauss | 105:a930035b6556 | 2621 | ffwip = fopen("/qspi/fw_ip.txt", "r" ); |
klauss | 105:a930035b6556 | 2622 | ffwport = fopen("/qspi/fw_port.txt", "r" ); |
klauss | 105:a930035b6556 | 2623 | fmax = fopen("/qspi/maxext.txt", "r" ); |
klauss | 105:a930035b6556 | 2624 | fmin = fopen("/qspi/minext.txt", "r" ); |
klauss | 106:a34fcf9f0e02 | 2625 | fshift_port = fopen("/qspi/shift_port.txt", "r" ); |
klauss | 106:a34fcf9f0e02 | 2626 | |
klauss | 105:a930035b6556 | 2627 | } |
klauss | 105:a930035b6556 | 2628 | |
klauss | 105:a930035b6556 | 2629 | if( type == 'w') { |
klauss | 106:a34fcf9f0e02 | 2630 | |
klauss | 105:a930035b6556 | 2631 | // Create and write the default configs |
klauss | 105:a930035b6556 | 2632 | set_ip( __MY_IP__ ); |
klauss | 105:a930035b6556 | 2633 | |
klauss | 105:a930035b6556 | 2634 | set_header_sip_port( __MY_PORT__ ); |
klauss | 105:a930035b6556 | 2635 | |
klauss | 105:a930035b6556 | 2636 | set_header_ext( __MY_EXT__ ); |
klauss | 105:a930035b6556 | 2637 | |
klauss | 105:a930035b6556 | 2638 | set_server_ip( __SERVER_IP__ ); |
klauss | 105:a930035b6556 | 2639 | |
klauss | 105:a930035b6556 | 2640 | set_server_ext( __PEER_EXT__ ); |
klauss | 105:a930035b6556 | 2641 | |
klauss | 105:a930035b6556 | 2642 | set_server_port( __SERVER_PORT__ ); |
klauss | 105:a930035b6556 | 2643 | |
klauss | 105:a930035b6556 | 2644 | set_mask( __MY_MSK__ ); |
klauss | 105:a930035b6556 | 2645 | |
klauss | 105:a930035b6556 | 2646 | set_gateway( __MY_GTW__ ); |
klauss | 105:a930035b6556 | 2647 | |
klauss | 105:a930035b6556 | 2648 | set_udp_port_listener( UDP_PORT_LISTENER ); |
klauss | 105:a930035b6556 | 2649 | |
klauss | 105:a930035b6556 | 2650 | set_tcp_port_listener( TCP_PORT_LISTENER ); |
klauss | 105:a930035b6556 | 2651 | |
klauss | 105:a930035b6556 | 2652 | set_fw_ip( __FW_SERVER_IP__ ); |
klauss | 105:a930035b6556 | 2653 | |
klauss | 105:a930035b6556 | 2654 | set_fw_port( __FW_SERVER_PORT__ ); |
klauss | 105:a930035b6556 | 2655 | |
klauss | 105:a930035b6556 | 2656 | set_max_ext( MAX_EXT ); |
klauss | 105:a930035b6556 | 2657 | |
klauss | 105:a930035b6556 | 2658 | set_min_ext( MIN_EXT ); |
klauss | 106:a34fcf9f0e02 | 2659 | |
klauss | 106:a34fcf9f0e02 | 2660 | set_shift_port( SHIFT_PORT ); |
klauss | 105:a930035b6556 | 2661 | |
klauss | 105:a930035b6556 | 2662 | strcpy( last_cmd, tmp_cmd ); |
klauss | 105:a930035b6556 | 2663 | |
klauss | 105:a930035b6556 | 2664 | if( debug_uart3 && !( from_eth ) ) pc.printf("\n\rDefault configurations set!\n\r"); |
klauss | 105:a930035b6556 | 2665 | if( from_eth ) { |
klauss | 105:a930035b6556 | 2666 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "\n\rDefault configurations set!\n\r"); |
klauss | 105:a930035b6556 | 2667 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 105:a930035b6556 | 2668 | if( tcp_session && !udp_query ) { |
klauss | 105:a930035b6556 | 2669 | tcp_client.send_all( debug_buf, strlen( debug_buf ) ); |
klauss | 105:a930035b6556 | 2670 | } else if( udp_query ) { |
klauss | 105:a930035b6556 | 2671 | udp_query_send_msg( debug_buf ); |
klauss | 105:a930035b6556 | 2672 | } |
klauss | 54:448d57291be6 | 2673 | bufptr = 0; |
klauss | 104:62646ef786a3 | 2674 | for( register int i = 0; i < DEBUGBUFSIZE; i++ ) debug_buf[ i ] = 0; |
klauss | 45:c80574f24dc3 | 2675 | } |
klauss | 106:a34fcf9f0e02 | 2676 | |
klauss | 105:a930035b6556 | 2677 | } |
klauss | 105:a930035b6556 | 2678 | |
klauss | 106:a34fcf9f0e02 | 2679 | if (type == 'e') |
klauss | 106:a34fcf9f0e02 | 2680 | { |
klauss | 106:a34fcf9f0e02 | 2681 | //Erase configs |
klauss | 105:a930035b6556 | 2682 | fip = fopen("/qspi/myip.txt", "w"); |
klauss | 105:a930035b6556 | 2683 | fmask = fopen("/qspi/mymask.txt", "w"); |
klauss | 105:a930035b6556 | 2684 | fgate = fopen("/qspi/mygateway.txt", "w"); |
klauss | 105:a930035b6556 | 2685 | fport = fopen("/qspi/mysipport.txt", "w"); |
klauss | 105:a930035b6556 | 2686 | fsip = fopen("/qspi/serverip.txt", "w"); |
klauss | 105:a930035b6556 | 2687 | fsport = fopen("/qspi/serverport.txt", "w"); |
klauss | 105:a930035b6556 | 2688 | fext = fopen( "/qspi/myext.txt", "w" ); |
klauss | 105:a930035b6556 | 2689 | fserext = fopen( "/qspi/peerext.txt", "w" ); |
klauss | 105:a930035b6556 | 2690 | fudpport = fopen( "/qspi/udpport.txt", "w" ); |
klauss | 105:a930035b6556 | 2691 | ftcpport = fopen( "/qspi/tcpport.txt", "w" ); |
klauss | 105:a930035b6556 | 2692 | ffwip = fopen("/qspi/fw_ip.txt", "w" ); |
klauss | 105:a930035b6556 | 2693 | ffwport = fopen("/qspi/fw_port.txt", "w" ); |
klauss | 105:a930035b6556 | 2694 | fmax = fopen("/qspi/maxext.txt", "w" ); |
klauss | 105:a930035b6556 | 2695 | fmin = fopen("/qspi/minext.txt", "w" ); |
klauss | 106:a34fcf9f0e02 | 2696 | fshift_port = fopen("/qspi/shift_port.txt", "w" ); |
klauss | 105:a930035b6556 | 2697 | |
klauss | 106:a34fcf9f0e02 | 2698 | if( fip ) fprintf( fip, "%s\n\r", "" ); |
klauss | 106:a34fcf9f0e02 | 2699 | if( fport ) fprintf( fport, "%i\n\r", 0 ); |
klauss | 106:a34fcf9f0e02 | 2700 | if( fext ) fprintf( fext, "%i\n\r", 0 ); |
klauss | 105:a930035b6556 | 2701 | |
klauss | 106:a34fcf9f0e02 | 2702 | if( fsip ) fprintf( fsip, "%s\n\r", "" ); |
klauss | 106:a34fcf9f0e02 | 2703 | if( fserext ) fprintf( fserext, "%i\n\r", 0 ); |
klauss | 106:a34fcf9f0e02 | 2704 | if( fsport ) fprintf( fsport, "%i\n\r", 0 ); |
klauss | 105:a930035b6556 | 2705 | |
klauss | 106:a34fcf9f0e02 | 2706 | if( fmask ) fprintf( fmask, "%s\n\r","" ); |
klauss | 106:a34fcf9f0e02 | 2707 | if( fgate ) fprintf( fgate, "%s\n\r", "" ); |
klauss | 105:a930035b6556 | 2708 | |
klauss | 106:a34fcf9f0e02 | 2709 | if( fudpport ) fprintf( fudpport, "%i\n\r", 0 ); |
klauss | 106:a34fcf9f0e02 | 2710 | if( ftcpport ) fprintf( ftcpport, "%i\n\r", 0 ); |
klauss | 105:a930035b6556 | 2711 | |
klauss | 106:a34fcf9f0e02 | 2712 | if( ffwip ) fprintf( ffwip, "%s\n\r","" ); |
klauss | 106:a34fcf9f0e02 | 2713 | if( ffwport ) fprintf( ffwport, "%i\n\r",0 ); |
klauss | 105:a930035b6556 | 2714 | |
klauss | 106:a34fcf9f0e02 | 2715 | if( fmax ) fprintf( fmax, "%i\n\r", 0 ); |
klauss | 106:a34fcf9f0e02 | 2716 | if( fmin ) fprintf( fmin, "%i\n\r", 0 ); |
klauss | 106:a34fcf9f0e02 | 2717 | |
klauss | 106:a34fcf9f0e02 | 2718 | if( fshift_port ) fprintf( fshift_port, "%i\n\r", 0 ); |
klauss | 105:a930035b6556 | 2719 | |
klauss | 105:a930035b6556 | 2720 | files('c'); |
klauss | 105:a930035b6556 | 2721 | |
klauss | 105:a930035b6556 | 2722 | if( debug_uart3 && !( from_eth ) ) pc.printf("\n\rErased configurations set!\n\r"); |
klauss | 105:a930035b6556 | 2723 | if( from_eth ) { |
klauss | 105:a930035b6556 | 2724 | snprintf( debug_buf, __PROMPT_ETH_BUFFER_SIZE__, "\n\rErased configurations set!\n\r"); |
klauss | 105:a930035b6556 | 2725 | debug_buf[ strlen( debug_buf ) - 1 ] = '\0'; |
klauss | 105:a930035b6556 | 2726 | if( tcp_session && !udp_query ) { |
klauss | 105:a930035b6556 | 2727 | tcp_client.send_all( debug_buf, strlen( debug_buf ) ); |
klauss | 105:a930035b6556 | 2728 | } else if( udp_query ) { |
klauss | 105:a930035b6556 | 2729 | udp_query_send_msg( debug_buf ); |
klauss | 45:c80574f24dc3 | 2730 | } |
klauss | 42:480335bdde12 | 2731 | bufptr = 0; |
klauss | 104:62646ef786a3 | 2732 | for( register int i = 0; i < DEBUGBUFSIZE; i++ ) debug_buf[ i ] = 0; |
klauss | 45:c80574f24dc3 | 2733 | } |
klauss | 106:a34fcf9f0e02 | 2734 | |
klauss | 105:a930035b6556 | 2735 | } |
klauss | 105:a930035b6556 | 2736 | } |
klauss | 105:a930035b6556 | 2737 | |
klauss | 105:a930035b6556 | 2738 | void init_fsystem() |
klauss | 105:a930035b6556 | 2739 | { |
klauss | 105:a930035b6556 | 2740 | // init file system and check if files exist |
klauss | 105:a930035b6556 | 2741 | if (!qspifs.isformatted()) { |
klauss | 105:a930035b6556 | 2742 | qspifs.format(); |
klauss | 105:a930035b6556 | 2743 | if( debug_uart3 && !( from_eth ) ) pc.printf("\n\r******* File system configured!!******* \n\r"); |
klauss | 105:a930035b6556 | 2744 | } |
klauss | 105:a930035b6556 | 2745 | // check if the files are created |
klauss | 105:a930035b6556 | 2746 | files('i'); |
klauss | 105:a930035b6556 | 2747 | files('c'); |
klauss | 106:a34fcf9f0e02 | 2748 | pc.printf("\r\n******* File System Ready *******\r\n"); |
klauss | 106:a34fcf9f0e02 | 2749 | debug_file = false; |
klauss | 105:a930035b6556 | 2750 | } |
klauss | 105:a930035b6556 | 2751 | |
klauss | 105:a930035b6556 | 2752 | int str2uint ( char * s, unsigned int * val ) |
klauss | 105:a930035b6556 | 2753 | { |
klauss | 105:a930035b6556 | 2754 | int i = 0; |
klauss | 105:a930035b6556 | 2755 | unsigned int ret = 0; |
klauss | 105:a930035b6556 | 2756 | for (;;) { |
klauss | 105:a930035b6556 | 2757 | if (s[i] < '0') { |
klauss | 105:a930035b6556 | 2758 | *val = ret; |
klauss | 105:a930035b6556 | 2759 | return i; |
klauss | 105:a930035b6556 | 2760 | } |
klauss | 105:a930035b6556 | 2761 | ret *= 10; |
klauss | 105:a930035b6556 | 2762 | ret += s[i] - '0'; |
klauss | 105:a930035b6556 | 2763 | i++; |
klauss | 105:a930035b6556 | 2764 | } |
klauss | 54:448d57291be6 | 2765 | } |