Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

viRead Message completeness & how to use ViUInt32 cnt parameter.

I use VISA to handle socket and GPIB communication.
I recently updated the viRead code I use for VISA-socket communication. Now, I supply the exact 'cnt' or the exact length of characters i expect to be available on the buffer. I used to simply supply the max # of characters possible and rely on visa-timeout to terminate the function call.

My question is what does the 'cnt' parameter do on a viRead call with GPIB communication? With GPIB I had the impression that data read came as a packet. Am I correct?

Secondarily, if partial response strings are possible with GPIB VISA reads, do you have a suggestion on how to minimize or eliminate this scenario?

p.s. My problems with partial response strings from viRead(VISA-sockets), was the genesis for this question.
0 Kudos
Message 1 of 2
(3,306 Views)
The count input on the VISA read for GPIB communication works the same way as in other communication methods such as serial. The read function reads until it receives a termination character, until the number of bytes specified in "count" are obtained, or until the timeout value is reached. Here is an excerpt from the NI-488.2 Help for the ibrd function:

The operation terminates normally when count bytes have been received or END is received. The operation terminates with an error if the transfer could not complete within the timeout period. The actual number of bytes transferred is returned in the global variable ibcntl.

I am guessing that by "partial response strings" you are referring to obtaining some data that is not all the data you expected. The reasons for this would be if not enough bytes have been specified in "count," a termination character was received unexpectedly, or if the timeout occurred before all of the data had been transferred.

Hope this information is helpful!

john
0 Kudos
Message 2 of 2
(3,297 Views)