C# SerialPort DataReceived problem when when attached strings

后端 未结 1 764
轻奢々
轻奢々 2020-12-22 12:04

I have a DataReceived method being trigger a data is send from a RS232 device. Things run smoothly with the following code

byte[] data = new Byte[serialPort.         


        
相关标签:
1条回答
  • 2020-12-22 12:40

    The DataReceived method will be triggered when the serial port feels like triggering it, which is NOT necessarily when you receive a full string from the device. See this SO answer for a great discussion of the details. If you have a known terminator character, you can work around this problem by setting the NewLine property of the SerialPort, and then using ReadLine().

    0 讨论(0)
提交回复
热议问题