Skip to content

Commit 86a761c

Browse files
committed
Replace serialEvent() with custom function.
Because `serialEvent()` is not platform independent.
1 parent 267e0a2 commit 86a761c

3 files changed

Lines changed: 5 additions & 6 deletions

File tree

lib/3rd_party_adapters/Arduino/serial_port.cpp

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,7 @@ void setCallbackForLineReception(const StringHandler &callback)
4444

4545
} // namespace serial_port
4646

47-
/*
48-
SerialEvent occurs whenever a new data comes in the hardware serial RX. This
49-
routine is run between each time loop() runs, so using delay inside loop can
50-
delay response. Multiple bytes of data may be available.
51-
*/
52-
void serialEvent()
47+
void serial_port::readAndHandleInput()
5348
{
5449
while (Serial.available() > 0)
5550
{

lib/application_business_rules/serial_interface/serial_port.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ typedef std::function<void(const String &)> StringHandler;
5858
*/
5959
void setCallbackForLineReception(const StringHandler &callback);
6060

61+
void readAndHandleInput();
62+
6163
} // namespace serial_port
6264

6365
/**

src/main.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ void loop()
3232
static Presenter presenter(singleMenu, board::getStatusIndicators());
3333
static ProcessHmiInputs processHmiInputs(presenter, board::getKeypad());
3434

35+
serial_port::readAndHandleInput();
36+
3537
for (auto task : device::tasks)
3638
{
3739
serial_port::cout << task.second.getLabel() << " : " << std::boolalpha << task.second.isRunning()

0 commit comments

Comments
 (0)