From 171032b701ff525242ed7e8b15c527ad715efe2d Mon Sep 17 00:00:00 2001 From: copercini Date: Wed, 4 Oct 2017 00:12:21 -0300 Subject: [PATCH] Print an error when serial number is invalid (#691) * Print error when serial number is invalid * Move to the first check, change end by return --- cores/esp32/HardwareSerial.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cores/esp32/HardwareSerial.cpp b/cores/esp32/HardwareSerial.cpp index a053bf22..500bff46 100644 --- a/cores/esp32/HardwareSerial.cpp +++ b/cores/esp32/HardwareSerial.cpp @@ -11,6 +11,10 @@ HardwareSerial::HardwareSerial(int uart_nr) : _uart_nr(uart_nr), _uart(NULL) {} void HardwareSerial::begin(unsigned long baud, uint32_t config, int8_t rxPin, int8_t txPin) { + if(0 > _uart_nr || _uart_nr > 2) { + log_e("Serial number is invalid, please use 0, 1 or 2"); + return; + } if(_uart) { end(); }