Skip to content

Commit c996036

Browse files
authored
Adds an error message to HardwareSerial::setPins() (espressif#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()
1 parent 03e2ad9 commit c996036

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

cores/esp32/HardwareSerial.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -491,6 +491,10 @@ void HardwareSerial::setRxInvert(bool invert)
491491
// negative Pin value will keep it unmodified
492492
void HardwareSerial::setPins(int8_t rxPin, int8_t txPin, int8_t ctsPin, int8_t rtsPin)
493493
{
494+
if(_uart == NULL) {
495+
log_e("setPins() shall be called after begin() - nothing done");
496+
return;
497+
}
494498
uartSetPins(_uart, rxPin, txPin, ctsPin, rtsPin);
495499
}
496500

0 commit comments

Comments
 (0)