Chapter 4 GPIB/GPIB-488.2 Library
© National Instruments Corporation 4-19 LabWindows/CVI Standard Libraries
SRQI, RQS, and Auto Serial Polling
If you want to install a callback for the SRQI (board-level) event, Auto Serial Polling must be
disabled. You can disable Auto Serial Polling with the following function call:
ibconfig (boardIndex, IbcAUTOPOLL, 0);
If you want to install a callback for the RQS (device-level) event, Auto Serial Polling must be
enabled for the board. You can enable Auto Serial Polling with the following function call:
ibconfig (boardIndex, IbcAUTOPOLL, 1);
CallbackFunction
The callback function must have the following form.
void __stdcall CallbackFunctionName (int boardOrDevice, int sta, int err,
long cntl, void *callbackData);
The callbackData parameter is the same callbackData value passed to
ibInstallCallback. The sta, err, and cntl parameters contain the information that you
normally obtain using the ibsta, iberr, and ibcntl global variables or the
ThreadIbsta, ThreadIberr, and ThreadIbcntl functions. The global variables and
thread status functions return undefined values within the callback function. So you must use the
sta, err and cntl parameters instead.
The value that you return from the callback function is very important. It is the event mask that is
used to rearm the callback. If you return 0, the callback is disarmed (that is, it is not called again
until you make another call to ibnotify). If you return an event mask different than the one
you originally passed to ibnotify, the new event mask is used. Normally, you want to return
the same event mask that you originally passed to ibnotify.
If you return an invalid event mask or if there is an operating system error in rearming the
callback, the callback is called with the sta set to ERR , err set to EDVR, and cntl set to
IBNOTIFY_REARM_FAILED.
Warning: Because the callback can be called as the result of a rearming error, you should
always check the value of the sta parameter to make sure that one of the
requested events has in fact occurred.
If invoked because of an SRQI or RQS condition, the callback function should call the ibrsp
function to read the status byte. For an SRQI (board-level) condition, calling the ibrsp
function is necessary to cause to requesting device to turn off the SRQ line.
char statusByte;
ibrsp (device, &statusByte);