добавлена проверка - не превышает ли номер вывода из аргумента функции общее кол-во выводов

This commit is contained in:
klassents committed 2025-02-21 15:43:13 +07:00
1 parent 5b2e2eb1d5
commit fbaa4b931a
11 files changed
+171 -96

No files matched your search

@@ -228,6 +228,18 @@ void SoftwareSerial::begin(long speed)
// delays are empirical values here
_rx_delay_centering = _rx_delay_intrabit = _rx_delay_stopbit = _tx_delay = 0;
// if pins exceeds the total number of pins, return with zero delays - it blocks further library work
if ((_transmitPin >= pinCommonQty()))
{
ErrorMsgHandler("SoftwareSerial.begin(): Tx pin number exceeds the total number of pins");
return;
}
if ((_receivePin >= pinCommonQty()))
{
ErrorMsgHandler("SoftwareSerial.begin(): Rx pin number exceeds the total number of pins");
return;
}
// limit speed
if (speed > MAX_SOFT_SERIAL_SPEED) speed = MAX_SOFT_SERIAL_SPEED;
if (speed < MIN_SOFT_SERIAL_SPEED) speed = MIN_SOFT_SERIAL_SPEED;