GPIB Programming Techniques
Chapter 6
NI-488.2M SRM for OS/2
6-6
© National Instruments Corp.
SRQ and Serial Polling with NI-488 Device Functions
You can use the device-level NI-488 function
ibrsp
to conduct a serial poll.
ibrsp
conducts a single serial poll and returns the serial poll response byte to
the application program. If automatic serial polling is enabled, the application
program can use
ibwait
to suspend program execution until RQS appears in
the status word,
ibsta
. The program can then call
ibrsp
to obtain the serial
poll response byte.
The following example illustrates the use of the
ibwait
and
ibrsp
functions
in a typical SRQ servicing situation when automatic serial polling is enabled.
#include “decl.h”
char GetSerialPollResponse ( int DeviceHandle )
{
char SerialPollResponse = 0;
ibwait ( DeviceHandle, TIMO | RQS );
if ( ibsta & RQS ) {
printf ( “Device asserted SRQ.\n” );
/* Use ibrsp to retrieve the serial poll
response. */
ibrsp
(
DeviceHandle,
&SerialPollResponse
);
}
return SerialPollResponse;
}
SRQ and Serial Polling with NI-488.2 Routines
The NI-488.2M software includes a set of NI-488.2 routines that you can use to
conduct SRQ servicing and serial polling. Routines pertinent to SRQ servicing
and serial polling are
AllSpoll
,
FindRQS
,
ReadStatusByte
,
TestSRQ
,
and
WaitSRQ
.
AllSpoll
can serial poll multiple devices with a single call. It places the
status bytes from each polled instrument into a predefined array, then you must
check the RQS bit of each status byte to determine whether that device
requested service.