From 74e4a744ce0bae127cd2eeac04e62c2bf45a9c93 Mon Sep 17 00:00:00 2001 From: Rodrigo Garcia Date: Fri, 25 Oct 2024 14:48:35 -0300 Subject: [PATCH] feat(uart): uart break example improvement (#10525) prints the HEXA and CHAR in order to allow the user to see why there is 1 extra char (0x00) when BREAK is received. --- .../OnReceiveError_BREAK_Demo/OnReceiveError_BREAK_Demo.ino | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/libraries/ESP32/examples/Serial/OnReceiveError_BREAK_Demo/OnReceiveError_BREAK_Demo.ino b/libraries/ESP32/examples/Serial/OnReceiveError_BREAK_Demo/OnReceiveError_BREAK_Demo.ino index fb7af04c5f5..209cf8922be 100644 --- a/libraries/ESP32/examples/Serial/OnReceiveError_BREAK_Demo/OnReceiveError_BREAK_Demo.ino +++ b/libraries/ESP32/examples/Serial/OnReceiveError_BREAK_Demo/OnReceiveError_BREAK_Demo.ino @@ -80,7 +80,11 @@ void onReceiveFunction() { received_bytes = received_bytes + available; Serial.printf("onReceive Callback:: There are %d bytes available: {", available); while (available--) { - Serial.print((char)Serial1.read()); + char c = Serial1.read(); + Serial.printf("0x%x='%c'", c, c); + if (available) { + Serial.print(" "); + } } Serial.println("}"); }