-
Notifications
You must be signed in to change notification settings - Fork 3
Description
There is a somewhat nasty problem related to the
if (SerialEpcos.available() > 0)
loop, This is the loop that processes incoming serial data.
It's a long loop, but is is efficiently using the switch case statements.
Serial communications between Arduino and EPOS4 run at 9600 baud = 9600 bit per sec. Start+8data+1stop bit take 10/9600 of a second, roughly one millisec.
Problem: One can imagine this loop completes within one millisec, especially on the more powerful Arduino models. If at that time the next byte is still coming in through the serial port, SerialEpcos.available will be zero and read will fail.
Proposed solution1: Quick & dirty solution would be to add delay(1); somewhere inside the loop. That fixes the problem at 9600 bps, assuming the EPOS4 is sending characters one immediately after the other.
Alternative workaround would be to increase the baudrate in communications between Arduino & EPOS4.
Proposed solution2: Add an additional timeout per character, dependent on baudrate.