National Instruments NI-488.2 Benutzerhandbuch

Seite von 135
Chapter 7
NI-488.2 Programming Techniques
7-4
www.natinst.com
Waiting for GPIB Conditions
You can use the 
ibwait
 function to obtain the current 
ibsta
 value or to 
suspend your application until a specified condition occurs on the GPIB. If 
you use 
ibwait
 with a parameter of zero, it immediately updates 
ibsta
 
and returns. If you want to use 
ibwait
 to wait for one or more events to 
occur, pass a wait mask to the function. The wait mask should always 
include the TIMO event; otherwise, your application is suspended 
indefinitely until one of the wait mask events occurs.
Asynchronous Event Notification in Win32 
NI-488.2 Applications
Win32 NI-488.2 applications can asynchronously receive event 
notifications using the 
ibnotify
 function. This function is useful if you 
want your application to be notified asynchronously about the occurrence 
of one or more GPIB events. For example, you might choose to use 
ibnotify
 if your application only needs to interact with your GPIB device 
when it is requesting service. After calling 
ibnotify
, your application 
does not need to check the status of your GPIB device. Then, when your 
GPIB device requests service, the NI-488.2 driver automatically notifies 
your application that the event has occurred by invoking a callback 
function. The callback function is registered with the NI-488.2 driver when 
the 
ibnotify
 call is made. 
Calling the ibnotify Function
ibnotify
 has the following function prototype:
ibnotify (
int ud,// unit descriptor
int mask,// bit mask of GPIB events
GpibNotifyCallback_t Callback,
// callback function    
void * RefData// user-defined reference data
)
Both board-level and device-level 
ibnotify
 calls are supported by the 
NI-488.2 driver. If you are using device-level calls, you call 
ibnotify
 
with a device handle for 
ud
 and a 
mask
 of RQS, CMPL, END, or TIMO. If 
you are using board-level calls, you call 
ibnotify
 with a board handle for 
ud
 and a 
mask
 of any values except RQS or ERR. The 
ibnotify
 mask bits 
are identical to the 
ibwait
 mask bits. In the example of waiting for your