Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(uart) 2.0.x Core: fixes serialEventRun() to avoid calling available() if serialEvent() is not declared #10429

Merged
merged 2 commits into from
Oct 7, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 3 additions & 12 deletions cores/esp32/HardwareSerial.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,13 @@
#endif

void serialEvent(void) __attribute__((weak));
void serialEvent(void) {}

#if SOC_UART_NUM > 1
void serialEvent1(void) __attribute__((weak));
void serialEvent1(void) {}
#endif /* SOC_UART_NUM > 1 */

#if SOC_UART_NUM > 2
void serialEvent2(void) __attribute__((weak));
void serialEvent2(void) {}
#endif /* SOC_UART_NUM > 2 */

#if !defined(NO_GLOBAL_INSTANCES) && !defined(NO_GLOBAL_SERIAL)
Expand All @@ -50,19 +47,13 @@ HardwareSerial Serial2(2);

void serialEventRun(void)
{
#if HWCDC_SERIAL_IS_DEFINED == 1 // Hardware JTAG CDC Event
if(HWCDCSerial.available()) HWCDCSerialEvent();
#endif
#if USB_SERIAL_IS_DEFINED == 1 // Native USB CDC Event
if(USBSerial.available()) USBSerialEvent();
#endif
// UART0 is default serialEvent()
if(Serial.available()) serialEvent();
if(serialEvent && Serial.available()) serialEvent();
#if SOC_UART_NUM > 1
if(Serial1.available()) serialEvent1();
if(serialEvent1 && Serial1.available()) serialEvent1();
#endif
#if SOC_UART_NUM > 2
if(Serial2.available()) serialEvent2();
if(serialEvent2 && Serial2.available()) serialEvent2();
#endif
}
#endif
Expand Down
Loading