2424#endif
2525
2626void serialEvent (void ) __attribute__((weak));
27- void serialEvent (void ) {}
2827
2928#if SOC_UART_NUM > 1
3029void serialEvent1 (void ) __attribute__((weak));
31- void serialEvent1 (void ) {}
3230#endif /* SOC_UART_NUM > 1 */
3331
3432#if SOC_UART_NUM > 2
3533void serialEvent2 (void ) __attribute__((weak));
36- void serialEvent2 (void ) {}
3734#endif /* SOC_UART_NUM > 2 */
3835
3936#if !defined(NO_GLOBAL_INSTANCES) && !defined(NO_GLOBAL_SERIAL)
@@ -48,37 +45,35 @@ HardwareSerial Serial2(2);
4845
4946#if HWCDC_SERIAL_IS_DEFINED == 1 // Hardware JTAG CDC Event
5047extern void HWCDCSerialEvent (void ) __attribute__((weak));
51- void HWCDCSerialEvent (void ) {}
5248#endif
5349
5450#if USB_SERIAL_IS_DEFINED == 1 // Native USB CDC Event
5551// Used by Hardware Serial for USB CDC events
5652extern void USBSerialEvent (void ) __attribute__((weak));
57- void USBSerialEvent (void ) {}
5853#endif
5954
6055void serialEventRun (void ) {
6156#if HWCDC_SERIAL_IS_DEFINED == 1 // Hardware JTAG CDC Event
62- if (HWCDCSerial.available ()) {
57+ if (HWCDCSerialEvent && HWCDCSerial.available ()) {
6358 HWCDCSerialEvent ();
6459 }
6560#endif
6661#if USB_SERIAL_IS_DEFINED == 1 // Native USB CDC Event
67- if (USBSerial.available ()) {
62+ if (USBSerialEvent && USBSerial.available ()) {
6863 USBSerialEvent ();
6964 }
7065#endif
7166 // UART0 is default serialEvent()
72- if (Serial0.available ()) {
67+ if (serialEvent && Serial0.available ()) {
7368 serialEvent ();
7469 }
7570#if SOC_UART_NUM > 1
76- if (Serial1.available ()) {
71+ if (serialEvent1 && Serial1.available ()) {
7772 serialEvent1 ();
7873 }
7974#endif
8075#if SOC_UART_NUM > 2
81- if (Serial2.available ()) {
76+ if (serialEvent2 && Serial2.available ()) {
8277 serialEvent2 ();
8378 }
8479#endif
0 commit comments