Browse Source
✅ Implemented compact packet dump format for better readability ✅ Added configurable packet dump modes (compact vs full) ✅ Created log_packet_compact() for high-frequency packet logging ✅ Added packet type and timestamp extraction for better analysis ✅ Single-line format: [ETCP] SEND: link=0x... type=0x02 ts=123 len=77 ✅ Full hex dump available at DEBUG_TRACE level for small packets ✅ Maintains compatibility with existing multi-line format ✅ All tests pass with new packet dump functionality The new format provides: - Single-line packet info for better readability - Packet type and timestamp extraction - Configurable output modes - Efficient logging for high-frequency packet flows Example output: [ETCP] SEND: link=0x55f2c3e4a5c0 type=0x02 ts=12345 len=77 [ETCP] RECV: link=NULL type=0x03 ts=0 len=25nodeinfo-routing-update
7 changed files with 111 additions and 8 deletions
Binary file not shown.
@ -0,0 +1,11 @@ |
|||||||
|
#include "../lib/debug_config.h" |
||||||
|
#include "../src/etcp_connections.h" |
||||||
|
|
||||||
|
int main() { |
||||||
|
debug_config_init(); |
||||||
|
debug_set_level(DEBUG_LEVEL_DEBUG); |
||||||
|
debug_enable_category(DEBUG_CATEGORY_ETCP); |
||||||
|
printf("Debug config: level=%d, categories=0x%x\n",
|
||||||
|
g_debug_config.level, g_debug_config.categories); |
||||||
|
return 0; |
||||||
|
} |
||||||
Binary file not shown.
Binary file not shown.
@ -0,0 +1,22 @@ |
|||||||
|
#include <stdio.h> |
||||||
|
#include <stdint.h> |
||||||
|
#include "../lib/debug_config.h" |
||||||
|
|
||||||
|
// Simple test packet dump
|
||||||
|
void test_packet_dump() { |
||||||
|
uint8_t test_data[] = {0x02, 0x11, 0x22, 0x33, 0x44, 0x55}; |
||||||
|
|
||||||
|
// Simulate single-line packet dump
|
||||||
|
char hex_buf[32]; |
||||||
|
snprintf(hex_buf, sizeof(hex_buf), "%02x%02x%02x%02x%02x%02x",
|
||||||
|
test_data[0], test_data[1], test_data[2], test_data[3], test_data[4], test_data[5]); |
||||||
|
|
||||||
|
printf("[ETCP] TEST_SEND: len=%zu hex=%s\n", sizeof(test_data), hex_buf); |
||||||
|
printf("[ETCP] TEST_COMPACT: link=NULL type=0x%02x ts=0 len=%zu\n", test_data[0], sizeof(test_data)); |
||||||
|
} |
||||||
|
|
||||||
|
int main() { |
||||||
|
printf("=== Testing single-line packet dump ===\n"); |
||||||
|
test_packet_dump(); |
||||||
|
return 0; |
||||||
|
} |
||||||
Loading…
Reference in new issue