Skip to content

Commit ff952dc

Browse files
replace serialEvent() (#126)
Resolves #115
2 parents 56bf4c6 + 86a761c commit ff952dc

3 files changed

Lines changed: 7 additions & 8 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: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ void initialize();
3333
/**
3434
* Reads a line from serial port.
3535
*
36-
* Interprets the end of line as `\n`.
36+
* Expects the end of line to be `\n`.
3737
* It will wait for data for the duration of the timeout.
3838
* \returns an empty string in case no data is read
3939
*/
@@ -42,7 +42,7 @@ String readLine();
4242
/**
4343
* Gets a line from serial port.
4444
*
45-
* Interprets the end of line as `\n`.
45+
* Expects the end of line to be `\n`.
4646
* \returns an object that does not contain a value in case no data is already available.
4747
*/
4848
std::optional<String> getLine();
@@ -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)