From 6fe0751e6a8ac64931da219a5e333236cf4af47d Mon Sep 17 00:00:00 2001 From: Rodrigo Garcia Date: Tue, 26 Jul 2022 10:18:57 -0300 Subject: [PATCH 1/2] Adds an error message to HardwareSerial::setPins() In order to avoid problems if the user tries to `setPins()` before initializing the Serial port with begin() --- cores/esp32/HardwareSerial.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cores/esp32/HardwareSerial.cpp b/cores/esp32/HardwareSerial.cpp index acc1bd2c88b..8efc43abac6 100644 --- a/cores/esp32/HardwareSerial.cpp +++ b/cores/esp32/HardwareSerial.cpp @@ -491,6 +491,10 @@ void HardwareSerial::setRxInvert(bool invert) // negative Pin value will keep it unmodified void HardwareSerial::setPins(int8_t rxPin, int8_t txPin, int8_t ctsPin, int8_t rtsPin) { + if(uart == NULL) { + log_e("setPins() shall be called after begin() - nothing done"); + return; + } uartSetPins(_uart, rxPin, txPin, ctsPin, rtsPin); } From 3b12699be58cc31f44941320c1277a2140c91c61 Mon Sep 17 00:00:00 2001 From: Rodrigo Garcia Date: Tue, 26 Jul 2022 10:25:50 -0300 Subject: [PATCH 2/2] error fix --- cores/esp32/HardwareSerial.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cores/esp32/HardwareSerial.cpp b/cores/esp32/HardwareSerial.cpp index 8efc43abac6..87a190ba18c 100644 --- a/cores/esp32/HardwareSerial.cpp +++ b/cores/esp32/HardwareSerial.cpp @@ -491,7 +491,7 @@ void HardwareSerial::setRxInvert(bool invert) // negative Pin value will keep it unmodified void HardwareSerial::setPins(int8_t rxPin, int8_t txPin, int8_t ctsPin, int8_t rtsPin) { - if(uart == NULL) { + if(_uart == NULL) { log_e("setPins() shall be called after begin() - nothing done"); return; }