LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Serial communication whith LABView 7.0

I'm writing a Vi that send bytes to a serial port. The instrument connected then will answer, but i can't predict how much bytes it will sent back, and it is also possible that it send more than one CR/LF in his response.
Is it a way to wait until no more byte arrived at serial port and then read them all ?

Thanks in advance.
Jean-Luc
0 Kudos
Message 1 of 3
(3,065 Views)
Hi Jean-Luc

First you have to set Enable Termination character to FALSE which will ignore incoming LFs.

Second set up a read with a number to read which will be much more than ever expected, like 10000. Set a timeout with a time when you know that the instrument is ready sending. The read will terminate with a timeout but all received bytes until the timeout will be given back. As an alternative you can use a while loop and the "bytes at serial port" property node to meassure the time between the bytes and end the loop when a certain amount of time passed after receiving the last byte. Give this number to the VISA Read function.

Waldemar
Waldemar

Using 7.1.1, 8.5.1, 8.6.1, 2009 on XP and RT
Don't forget to give Kudos to good answers and/or questions
0 Kudos
Message 2 of 3
(3,065 Views)
Good suggestion Waldermar.

I prefer this one:

"As an alternative you can use a while loop and the "bytes at serial port" property node to measure the time between the bytes and end the loop when a certain amount of time passed after receiving the last byte. Give this number to the VISA Read function."

Another trick is to placew the VISA Read function inside the while loop and feed the outcoming serial data stream to a shift register. You can even parse the data. The output of the while loop can feed whatever your vi does.

-JLV-
0 Kudos
Message 3 of 3
(3,065 Views)