I have a simple windows app that is sending the following text strings repeatedly with a carriage return after each string.
1I5ED
2I5ED
3I5ED
4I5ED
5I5ED
6I5ED
Monitoring what the Arduino is sending out, the first 340 times it's fine then it starts to miss characters. See below.
1I5ED
2I5ED
3I5ED
I5ED
5I5ED
6I5E
1I5ED
2I5ED
3IED
4I5ED
5I5ED
I5ED
Is it a buffer problem? Does anyone have any ideas on how best I should do this?
How fast are the characters generated that are sent to the Arduino ?
First thing I would try is to set the baudrate at 115200 or at least the highest speed the devices can handle, so the serial communication takes minimal time.
Thanks to those that have replied. I have a Windows program that I wrote using AutoIt that outputs the serial stream at 19200 directly to the Arduinos serial port through the USB connection. I then use Hyperterminal to read the output from the Arduino using my laptops serial port. All communications are at 19200 because I am using software to simulate the output of a custom board that uses a propellar chip.
Serial data transmission follows the USPS model. The USPS does not guarantee to deliver the mail on time. They guarantee to try.
Serial data does get lost/corrupted. Your sender and receiver need to implement some sort of protocol to deal with that fact. Send something like <5:1ISED>, instead of 1ISED. 5 is the number of characters in the packet, < and > are end of packet markers, and : is a separator.
If a < or > is lost, that fact is easy to determine (<5:1ISED<5:2ISED><5:3ISED> is missing a <; <5:1ISED><5:2ISED<5:3ISED> is missing a >). If a : is missing, that is easy to detect.
If the value before the : is missing, that is easy to detect.
If a character after the colon is missing, the number of characters in the payload will not match the number expected, so discard the whole packet.
I then use Hyperterminal to read the output from the Arduino using my laptops serial port
In my experience this is exactly what happens with Hyperterminal, I would try something else.
Having said that receiving and transmitting art the same rate is going to drop characters eventually because the two rates while at the same speed are not synchronised and so will drift with relation to each other. When this happens the buffer slowly fills up and you end up missing stuff. It is always better if the input data rate is slower than the output data rate.
And anyway you could achieve good results if you replaced the arduino with a wire. Or are you planning to do anything else to the data as it goes through?