Hello;
I'm having a problem with receiving data from serial port. There's an eventhandler(datareceived) and I'm monitoring the answer from the serial port to a text box in the eventhandler. There's no problem till here. But also I want to use the incoming data to process it in some functions. But when I assign the incoming string(from the ReadExisting() function) to a local variable there are always lots of characters missing. How do I solve this problem? The code is below:
private void port_DataReceived_1(object sender, SerialDataReceivedEventArgs e)
{
InputData = port.ReadExisting();
OutputData = InputData;
Log(InputData);
}
private void Log(string msg)
{
rtfTerminal.Invoke(new EventHandler(delegate
{
rtfTerminal.SelectedText = string.Empty;
rtfTerminal.AppendText(msg);
rtfTerminal.ScrollToCaret();
}));
}
The problem continues if I write "OutputData = InputData;" in the invoke code.
I'm waiting for your help.