User`s guide
70 Agilent VISA User’s Guide
3 Programming with VISA
This sample program is installed on your system in the
ProgrammingSamples subdirectory. See the IO Libraries
Suite Online Help for locations of sample 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:
printf("TTL0");
break;
default:
printf("<other 0x%x>", trigId);
break;
}
printf("\n");