From 5e472cbd9a1256f96cdfa213664ca1c0939f05a4 Mon Sep 17 00:00:00 2001 From: Rodrigo Garcia Date: Sat, 5 Oct 2024 10:21:11 -0300 Subject: [PATCH] feat(uart): only enable on_receive task if necessary The onReceive Task was created by default when Serial.begin() is executed. This creates a additonal Task that degrades the performance of the whole arduino sketch. This will be done now only if onReceive() is called. --- cores/esp32/HardwareSerial.cpp | 5 ----- 1 file changed, 5 deletions(-) diff --git a/cores/esp32/HardwareSerial.cpp b/cores/esp32/HardwareSerial.cpp index 2e1f2701e9a..d0b938374e9 100644 --- a/cores/esp32/HardwareSerial.cpp +++ b/cores/esp32/HardwareSerial.cpp @@ -368,11 +368,6 @@ void HardwareSerial::begin(unsigned long baud, uint32_t config, int8_t rxPin, in _uart = NULL; } } - // create a task to deal with Serial Events when, for example, calling begin() twice to change the baudrate, - // or when setting the callback before calling begin() - if (_uart != NULL && (_onReceiveCB != NULL || _onReceiveErrorCB != NULL) && _eventTask == NULL) { - _createEventTask(this); - } // Set UART RX timeout uartSetRxTimeout(_uart, _rxTimeout);