Skip to content

Commit 171032b

Browse files
copercinime-no-dev
authored andcommitted
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
1 parent 17a1a24 commit 171032b

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

Diff for: cores/esp32/HardwareSerial.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ HardwareSerial::HardwareSerial(int uart_nr) : _uart_nr(uart_nr), _uart(NULL) {}
1111

1212
void HardwareSerial::begin(unsigned long baud, uint32_t config, int8_t rxPin, int8_t txPin)
1313
{
14+
if(0 > _uart_nr || _uart_nr > 2) {
15+
log_e("Serial number is invalid, please use 0, 1 or 2");
16+
return;
17+
}
1418
if(_uart) {
1519
end();
1620
}

0 commit comments

Comments
 (0)