User`s guide
Programming with VISA 3
Agilent VISA User’s Guide 65
Example: Wait on Event for SRQ This example shows how to
install a wait on event for service requests.
viEnableEvent(vi, VI_EVENT_SERVICE_REQ,
VI_QUEUE, VI_NULL);
viWaitOnEvent(vi, VI_EVENT_SERVICE_REQ,
VI_TMO_INFINITE, &eventType, &event);
.
.
viDisableEvent(vi, VI_EVENT_SERVICE_REQ,
VI_QUEUE);
Every time a wait on event is invoked, an event context object is
created. Specifying VI_TMO_INFINITE in the timeout parameter
indicates that the program execution will suspend indefinitely until the
event occurs. To clear the event queue for a specified event type, use the
viDiscardEvents function.
Example: Trigger Event Queuing This program enables the
trigger event in a queuing mode. When the viWaitOnEvent function is
called, the program will suspend operation until the trigger line is fired
or the timeout period is reached. Since the trigger lines were already
fired and the events were put into a queue, the function will return and
print the trigger line that fired.
This program is intended to show specific VISA functionality and does
not include error trapping. Error trapping, however, is good
programming practice and is recommended in your VISA applications.
See “Trapping Errors” in this chapter for more information.
This example program is installed on your system in the
ProgrammingSamples subdirectory. See the IO Libraries Suite
Online Help for locations of example programs.
/* evntqueu.c
This sample program illustrates enabling an
event queue using viWaitOnEvent. Note that you
must change the device address. */
#include <visa.h>
#include <stdio.h>