While reading from serial port I am using
serialport.read(xyz,0,4)
where xyz is a byte array.
Question 1: while doing so, does the data which I have read gets deleted from the buffer of the serial port? Or is there a pointer which gets incremented?
Question 2:
private void moduleSerialPort_DataReceived(object sender,System.IO.Ports.SerialDataReceivedEventArgs e)
{
.
.
.
}
If new data is received when the code for previous data is executed, will the event of data received be triggered?
I found that when my system ran for few hours following thing was taking place:
When new data was transmitted, it was received on the serial port but the computer processed previously sent data. So I am doubting that the data stays in buffer and is executed on next datareceived event.
Can someone please help me out.
Appreciate your help.
thanks
Data stays in the buffer until you read it. Simply handling a
DataReceivedevent does not cause the data to be dequeued, you actually have to read it. If you read less than the entire buffer, then next time theDataReceivedevent occurs, you will read the old leftovers before the new data.