If the message transmitted by your sensor is always terminated by a
specific character, e.g. CR or LF, just enable that as the VISA
termination character for serial reads and set a timeout that is a bit
longer than the sensor interval, e.g. 2-3 times as long. Use a VISA
Read function and wire a large value to 'bytes to read' (larger than
the maximum expected message length). VISA Read will wait until a
complete message is received and then return it.

If the message doesn't have a termination character, read one byte at
a time in a while loop and assemble the bytes into a string or array
using a shift register. Use appropriate code to detect when a complete
message has been assembled.

Either of these methods will return the sensor response to your LV
program as soon as possible after the sensor has sent it, which is
what I assume you mean by 'on time'.

There are two possible problems to bear in mind when you have a device
that sends data continuously, rather than in response to a request:
first, that readings may build up in the serial buffer before your
program starts reading them, and second, that the first response you
read may have the beginning chopped off, if you opened the port while
the device was half-way through sending something. Make sure you've
considered both of these. (Using the 'flush' function can help, but
remember you might flush the buffer while the device is half-way
through sending!)

Reply via email to