Skip to content

Commit

Permalink
feat(uart): only enable on_receive task if necessary
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
SuGlider authored Oct 5, 2024
1 parent 8ce5f77 commit 5e472cb
Showing 1 changed file with 0 additions and 5 deletions.
5 changes: 0 additions & 5 deletions cores/esp32/HardwareSerial.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 5e472cb

Please sign in to comment.