I previously have been reading NMEA data from a GPS via a serial port using C#. Now I'm doing something similar, but instead of GPS from a serial. I'm attempting to read a KISS Statement from a TNC. I'm using this event handler.
comport.DataReceived += new SerialDataReceivedEventHandler(port_DataReceived);
Here is port_DataReceived.
private void port_DataReceived(object sender, SerialDataReceivedEventArgs e)
{
string data = comport.ReadExisting();
sBuffer = data;
try
{
this.Invoke(new EventHandler(delegate { ProcessBuffer(sBuffer); }));
}
catch { }
}
The problem I'm having is that the method is being called several times per statement. So the ProcessBuffer method is being called with only a partial statment. How can I read the whole statement?