National Instruments NI-488.2 ユーザーズマニュアル

ページ / 134
Chapter 8
NI-488.2 Programming Techniques
© National Instruments Corporation
8-15
SRQ and Serial Polling with Device-Level Traditional NI-488.2 Calls
You can use the device-level traditional NI-488.2 call 
ibrsp
 to conduct 
a serial poll. 
ibrsp
 conducts a single serial poll and returns the serial poll 
response byte to the application. If automatic serial polling is enabled, the 
application 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 shows you how to use the 
ibwait
 and 
ibrsp
 
functions in a typical SRQ servicing situation when automatic serial polling 
is enabled:
#include "ni488.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 Multi-Device NI-488.2 Calls
The NI-488.2 software includes a set of multi-device NI-488.2 calls that 
you can use to conduct SRQ servicing and serial polling. Calls pertinent 
to SRQ servicing and serial polling are 
AllSpoll
ReadStatusByte
FindRQS
TestSRQ
, and 
WaitSRQ
. Following are descriptions of each of 
the calls:
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 (bit 6 or hex 40) of each status byte 
to determine whether that device requested service.
ReadStatusByte
 is similar to 
AllSpoll
, except that it only serial 
polls a single device. It is similar to the device-level NI-488.2 
ibrsp
 
function.