Read streaming data from serial port and write to buffer

ejleiss

Active member
Joined
Oct 1, 2012
Messages
37
Programming Experience
1-3
Hello,

I am trying to read fast streaming data from a serial port and put it in a buffer. Then I would like to read from the buffer and display the data into a text box. The streaming data to the serial port is setup as a 16 byte frame, but it is constantly sending. How would I read this into a buffer and then display each 16 byte frame on a new line of a text box?

Thank you.
 
I'd probably use a ConcurrentQueue(Of Byte). You can write to it directly in the DataReceived event handler of the SerialPort and then read from it in 16-Byte blocks on the UI thread to get data to write to the TextBox. Call the AppendText method of the TextBox to add each line.
 
Back
Top