LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how to get the latest data from serial port

I try to read data, several bytes, from PC serial port with 'serial port read.vi' in an interval of about 1 minute, and the data is sent to serial port continuously. I want to read the latest data from the port. But the data i got is not always the latest data, sometime i got an old data which is sent to serial port before, i have no way to overcome the issue. I guess that the vi read data from some memory, not from the serial port directly. How should i do to get the lates data? Thanks.
0 Kudos
Message 1 of 2
(2,762 Views)
Usually it is a good habit for the serial port to keep all the data that is sent to it. That is "buffered serial port". If you only want some bytes and recent, then you have to take the responsibility of reading every 5 seconds and throwing away the bytes you read and don't want, and keeping only the last. You can have an independent while loop that reads continually and keeps the last n bytes in a shift register. You can also refresh a timestamp every time you read some new bytes to keep a record of how recent the data is.
0 Kudos
Message 2 of 2
(2,762 Views)