From 61dcade807d356349982cf4825199735e9a87010 Mon Sep 17 00:00:00 2001 From: krzychb Date: Thu, 19 Oct 2017 21:45:58 +0200 Subject: [PATCH] Print out in hex format in case non printable data are received --- examples/peripherals/uart_async_rxtxtasks/README.md | 10 ++++++++++ .../main/uart_async_rxtxtasks_main.c | 1 + 2 files changed, 11 insertions(+) diff --git a/examples/peripherals/uart_async_rxtxtasks/README.md b/examples/peripherals/uart_async_rxtxtasks/README.md index 6647a00e4..839d86bff 100644 --- a/examples/peripherals/uart_async_rxtxtasks/README.md +++ b/examples/peripherals/uart_async_rxtxtasks/README.md @@ -9,3 +9,13 @@ If you'd like to see your ESP32 receive something, simply short TXD_PIN and RXD_PIN. By doing this data transmitted on TXD_PIN will be received on RXD_PIN. See the definitions of TXD_PIN and RXD_PIN in ./main/uart_async_rxtxtasks_main.c. + +The output for such configuration will look as follows: + +``` +I (3261) TX_TASK: Wrote 11 bytes +I (4261) RX_TASK: Read 11 bytes: 'Hello world' +I (4261) RX_TASK: 0x3ffb821c 48 65 6c 6c 6f 20 77 6f 72 6c 64 |Hello world| +... +``` +The third line above prints received data in hex format, that comes handy to display non printable data bytes. \ No newline at end of file diff --git a/examples/peripherals/uart_async_rxtxtasks/main/uart_async_rxtxtasks_main.c b/examples/peripherals/uart_async_rxtxtasks/main/uart_async_rxtxtasks_main.c index 044faafd4..b3129f0ef 100644 --- a/examples/peripherals/uart_async_rxtxtasks/main/uart_async_rxtxtasks_main.c +++ b/examples/peripherals/uart_async_rxtxtasks/main/uart_async_rxtxtasks_main.c @@ -61,6 +61,7 @@ static void rx_task() if (rxBytes > 0) { data[rxBytes] = 0; ESP_LOGI(RX_TASK_TAG, "Read %d bytes: '%s'", rxBytes, data); + ESP_LOG_BUFFER_HEXDUMP(RX_TASK_TAG, data, rxBytes, ESP_LOG_INFO); } } free(data);