User`s guide

Programming with VISA 3
Agilent VISA User’s Guide 69
Sample: Enabling a Hardware Trigger Event
This sample illustrates enabling a hardware trigger event.
viInstallHandler(vi, VI_EVENT_TRIG,
my_handler,&addr);
viEnableEvent(vi, VI_EVENT_TRIG, VI_HNDLR,
VI_NULL);
The VI_HNDLR mechanism specifies that the handler
installed for VI_EVENT_TRIG will be called when a hardware
trigger occurs.
If you specify VI_ALL_ENABLE_EVENTS in the eventType
parameter, all events that have previously been enabled on
the specified session will be enabled for the mechanism
specified in this function call.
Use the viDisableEvent function to stop servicing the event
specified.
Sample: Trigger Callback
This sample program installs an event handler and enables
the trigger event. When the event occurs, the installed event
handler is called. 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.
mechanism The mechanism by which the event will be enabled. It can be
enabled in several different ways. You can use VI_HNDLR in
this parameter to specify that the installed handler will be
called when the event occurs. Use VI_SUSPEND_HNDLR in
this parameter, which puts the events in a queue and waits to
call the installed handlers until viEnableEvent is called with
VI_HNDLR specified in the mechanism parameter. When
viEnableEvent is called with VI_HNDLR specified, the handler
for each queued event will be called.
context Not used in VISA 1.0. Use VI_NULL.
Table 22 Description of Parameters Used to Install a Handler