Skip to content

Commit

Permalink
feat(uart): eliminates nonexistent functions (#10428)
Browse files Browse the repository at this point in the history
loop() calls Serial Events functions when those are declared. The way it was declared was forcing to alway call avalable() to then call an empty function. This commit fixes it.
  • Loading branch information
SuGlider authored Oct 7, 2024
1 parent 630377f commit 0d5d50e
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions cores/esp32/HardwareSerial.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,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 @@ -48,37 +45,35 @@ HardwareSerial Serial2(2);

#if HWCDC_SERIAL_IS_DEFINED == 1 // Hardware JTAG CDC Event
extern void HWCDCSerialEvent(void) __attribute__((weak));
void HWCDCSerialEvent(void) {}
#endif

#if USB_SERIAL_IS_DEFINED == 1 // Native USB CDC Event
// Used by Hardware Serial for USB CDC events
extern void USBSerialEvent(void) __attribute__((weak));
void USBSerialEvent(void) {}
#endif

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

0 comments on commit 0d5d50e

Please sign in to comment.