
58
Agilent VISA User’s Guide
3
Programming with VISA
Example: 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.
This sample program is installed on your system in the
ProgrammingSamples
subdirectory. See the
IO Libraries Suite
Online Help
for locations of example programs.
/* evnthdlr.c
This example program illustrates installing an
event handler to be called when a trigger
interrupt occurs. Note that you may need to
change the address. */
#include <visa.h>
#include <stdio.h>
/* trigger event handler */
ViStatus _VI_FUNCH myHdlr(ViSession vi,
ViEventType eventType, ViEvent ctx, ViAddr
userHdlr){
ViInt16 trigId;
/* make sure it is a trigger event */
if(eventType!=VI_EVENT_TRIG){
/* Stray event, so ignore */
return VI_SUCCESS;
}
/* print the event information */
printf("Trigger Event Occurred!\n");
printf("...Original Device Session = %ld\n",
vi);
/* get the trigger that fired */
viGetAttribute(ctx, VI_ATTR_RECV_TRIG_ID,
&trigId);
printf("Trigger that fired: ");
switch(trigId){
case VI_TRIG_TTL0:
Содержание E2094S
Страница 6: ...6 Agilent VISA User s Guide ...
Страница 116: ...116 Agilent VISA User s Guide 4 Programming via GPIB and VXI ...
Страница 126: ...126 Agilent VISA User s Guide 5 Programming via LAN ...
Страница 143: ...Glossary Agilent VISA User s Guide 143 Windows notification area See notification area ...
Страница 144: ...144 Agilent VISA User s Guide Glossary ...