Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

visa - bytes at port for USB

I'm writting a driver for a Rigol oscilloscope using VISA with the USB port (scope firmware supports VISA).

How can you determine how many bytes are waiting to be read?

With the Visa-serial I can use "Number of bytes at serial port" but I can't find the equivalent for "plain" VISA.

 

I'm using a very high byte count with the VISA read vi to make sure I'm getting the full response but this seems a bit of a kludge.

So far the only way I can find is to catch the timeout error when no data is available.

0 Kudos
Message 1 of 4
(5,485 Views)
There is no method to determine how many bytes are available. Setting a high byte count is not a kludge at all. The USBTMC emulates a GPIB instrument and just like GPIB, a read stops when the termination character is detected. Using a Bytes at Serial Port is the real kludge. The better designed serial instruments also append a termination character so you simply do a read without any off that other silliness.
0 Kudos
Message 2 of 4
(5,481 Views)

As has been said, using the Termination Character to end the VISA read is by far the best way to go.  But if you are dealing with binary data, this can cause a hichup if the termination character just happens to match a byte in the raw data.



There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 3 of 4
(5,475 Views)
With the rewrite of so many of the shipping examples, I wish that NI had gotten rid of the byte count in the basic serial example. It just teaches bad habits.
Message 4 of 4
(5,470 Views)