From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

Read arbitrary number of byte from GPIB

Hi
I am trying to read a text file stored in an oscilloscope to a computer thru GPIB.  I can do that fine with MAX (using Query), now I want to program LabVIEW to do that for me. I want to program LabVIEW to read any file that I select. I was gonna use the VISA read function, but I have to specify the max. number of byte to read, which I can't because the file size can vary. So I wonder how I should do to be able to read arbitrary number of byte?
Thank you
0 Kudos
Message 1 of 4
(3,119 Views)
The byte count you specify can be much larger than what the file size is since the read will terminate whenever it senses EOI and the talker will assert EOI at the end of the message. I don't know how the utility in MAX does it. It's possible that it reads in smaller chunks and if EOI is not detected, it does another read.
0 Kudos
Message 2 of 4
(3,108 Views)
Part of it is logic. Dennis is correct that the GPIB will terminate the transmission with an EOI, which will in turn cause your VISA Read to return the status VI_SUCCESS (or in LabVIEW, the error number will be 0 coming out of the error cluster). If the data is not terminated by EOI, the VISA Read should return a warning about the maximum size that was requested was returned. If you don't know how big the file is, you will just loop on the VISA read until you get en error or success. For each read, you would concatonate the new response to the old response to make the complete response.

Does this make sense?

The best thing, like Dennis said, is to read much more than you anticipate and you will only have to read once and you can skip all of this logic.

0 Kudos
Message 3 of 4
(3,098 Views)
Thank you so much. That makes sense. I'll try that out
0 Kudos
Message 4 of 4
(3,094 Views)