LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Read specified bytes at Serial port

Hi,

I would like to read data from my serial port using LabView 6. The length of the data(in bytes) that I receive at the serial port is variable. Is there a way to read only the latest data at the serial port?

For example, if I have 20 bytes at the serial port buffer during the first iteration, I would like to read all 20 bytes in my LabView front panel. During the next iteration, if I have 70 bytes, I should read all 70, but ignore the first 20.

The only way, I can think of doing this is to continously poll the serial buffer and use Bytes at serial port.Vi to read the information from the buffer.

Is there any other way?

Thanks in advance.
0 Kudos
Message 1 of 3
(2,895 Views)
That's the way that I do it. In the loop I append the text from the last read to what's been previously read by using a shift register. I terminate the loop when a termination character is detected.
0 Kudos
Message 2 of 3
(2,895 Views)
Can you control how the data is sent to the serial port? If so, first send two bytes that indicate how many bytes will follow. Do this for every chunk of data. When the two bytes = '00' then you know you have finished reading all the data.

Chris_Mitchell
Product Development Engineer
Certified LabVIEW Architect

0 Kudos
Message 3 of 3
(2,895 Views)