From c996036e6159dd23f7725e3c843c199a46fddf6f Mon Sep 17 00:00:00 2001 From: Rodrigo Garcia Date: Tue, 26 Jul 2022 10:41:04 -0300 Subject: [PATCH] Adds an error message to HardwareSerial::setPins() (#7040) * 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 acc1bd2c8..87a190ba1 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); }