Skip to content

SerialEvent1() and SerialEvent2() are broken, here is a fix #3733

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

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
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
7 changes: 7 additions & 0 deletions cores/esp32/HardwareSerial.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,13 @@ void HardwareSerial::flush(bool txOnly)
{
uartFlushTxOnly(_uart, txOnly);
}
void serialEventRun(void)
{
if (Serial1.available()) serialEvent1();
if (Serial2.available()) serialEvent2();
}
void serialEvent1() { }
void serialEvent2() { }

size_t HardwareSerial::write(uint8_t c)
{
Expand Down
4 changes: 3 additions & 1 deletion cores/esp32/HardwareSerial.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,9 @@ class HardwareSerial: public Stream
uart_t* _uart;
};

extern void serialEventRun(void) __attribute__((weak));
void serialEventRun(void) __attribute__((weak));
extern void serialEvent1() __attribute__((weak));
extern void serialEvent2() __attribute__((weak));

#if !defined(NO_GLOBAL_INSTANCES) && !defined(NO_GLOBAL_SERIAL)
extern HardwareSerial Serial;
Expand Down