Home > OS >  In serialport communication, data is received multiple times
In serialport communication, data is received multiple times

Time:01-20

I made a loopback with TX and RX and tested it with one COM3 port.

serialport.DataReceived  = (sender, e) =>
{
  var data = serialport.ReadExisting();
  readRichTextBox.AppendText($"{data}\n"); // Cross-Thread Possibility
}

With \n you can see that the data is received multiple times.

ex) Input hello and hi

h
e
l
l
o
h
i

serialport is the default state.

Expects a result value like this:

hello
hi

CodePudding user response:

I'd say use serialPort.ReadLine() instead of ReadExisting().

  • Related