Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

Get number of bytes in GPIB read buffer with VISA

Is there is command to find out how many bytes are in the GPIB read buffer using VISA commands?  

status = viPrintf(instrH, command);
{  
     // Would like to poll the input buffer here to get the
     // number of bytes to read.
    numBytes = SomeCommandToGetBytesInBuffer()l

     status = viRead (instrH, Databuf, numBytes, &RtCount);
}

// This command returns the size of the buffer, not how
// bytes are in it.
status = viGetAttribute(instrH, VI_ATTR_RD_BUF_SIZE, &numBytes );   
 

0 Kudos
Message 1 of 2
(3,962 Views)
I think there is no such function, because GPIB read operation is not performed as in full-duplex.  This means there can not be any reading handshakes or any bytes that are already read, before you explicitly call viRead. The only thing you can use is VISA's buffering support, which still requires viScanf, but it is not your requesting.
 
More reasonable way for checking if there is any readable response is, perform Serial Polling then check if the MAV bit is asserted or not. (It requires the instrument is IEEE488.2 compliant.) This way, can not detect the actual byte count readable but just checks if there is one or more readable response bytes.
0 Kudos
Message 2 of 2
(3,956 Views)