Skip to content

Commit

Permalink
fix(uart) 2.0.x Core: fixes serialEventRun() to avoid calling availab…
Browse files Browse the repository at this point in the history
…le() if serialEvent() is not declared (#10429)

* fix(uart): applies #10428 to 2.0.x core

* fix(uart): there is no usb serial event in 2.0.x
  • Loading branch information
SuGlider authored Oct 7, 2024
1 parent 8ff2da7 commit 4301639
Showing 1 changed file with 3 additions and 12 deletions.
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

0 comments on commit 4301639

Please sign in to comment.