LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Serial communication using VISA

Hello everybody,

I need to communicate with a device connected to my COM1 port. I want to use VISA and the data returned by device isn't always the same size but I know what the maximum number of bytes of the data. If I put the maximum number of bytes in byte count (from the VISA read.vi) will it read the data even if it has a smaller size??

Thx!!


Eric Paulin
0 Kudos
Message 1 of 7
(3,681 Views)
Use VISA property node set to Serial Settings >> Number of Bytes at Serial port. Wire this value into the VISA read to determine how much to read.
0 Kudos
Message 2 of 7
(3,681 Views)
You may also want to set up a read till end of line character with timeout that will read a variable number of characters until a CR or LF comes in.
Stu
0 Kudos
Message 3 of 7
(3,681 Views)
Hi Eric
If a device does not send a known number of bytes, it almost always uses an endcharacter.
The only problem with visa is that you have to supply the end caharcter for reading in a property node and inather property node also enable the endcharacter. You need message based settings:termination character and termination character enabled.
Ask for the maximum and the read should stop after the endcharacter.
greetings from the Netherlands
0 Kudos
Message 4 of 7
(3,681 Views)
Additionally you can read byte by byte in a loop until got the all message you are waiting for.
E.g. I had a stupid device at some time, which was not send any end characters, so I had to wait for the checksum from that device calculating it after each byte received from the device and compare it with last byte 😞
Sergey
0 Kudos
Message 5 of 7
(3,681 Views)
Hello Sergey,

That's exactly what I have to do :).

Thx!

Eric
0 Kudos
Message 6 of 7
(3,681 Views)
I use for such cases a while loop, executing every 200 ms (for ex.) and
the functions "bytes at serial port" and "read from port" until the
numbers of bytes is zero.

Niko

Eric Paulin schrieb:

> Hello everybody,
>
> I need to communicate with a device connected to my COM1 port. I want
> to use VISA and the data returned by device isn't always the same size
> but I know what the maximum number of bytes of the data. If I put the
> maximum number of bytes in byte count (from the VISA read.vi) will it
> read the data even if it has a smaller size??
>
> Thx!!
>
> Eric Paulin
0 Kudos
Message 7 of 7
(3,681 Views)