I have a device on my Com1 port, that sends me every 20ms data package with 10 Bytes, starting with a ":" .
To get this data, I open a serial Port.
Then I have a thread (1 sec cycle time) running that reads one byte after the other.
data = serialPort.ReadByte();
When I receive a ":" (start commando) I read nine Bytes:
serialPort.Read(buffer, 0, 9);
Now my Problem:
My thread reads the data only every second, but the Com1 device sends data every 20 ms.. When I disconect the Com1 device, I still read data on the Com1 port (has still data in its buffer). That means also, that I don't read the latest sent data from the Com1 device.
Can I empty or reset this Com1 buffer?
Or how can I read the latest recived data on the Com1 port?
I have VS2010 and .Net4.0