User`s guide

72 Agilent VISA User’s Guide
3 Programming with VISA
This program is installed on your system in the
ProgrammingSamples subdirectory. See the IO Libraries
Suite Online Help for locations of sample programs.
/* srqhdlr.c
This example program illustrates installing an
event handler to be called when an SRQ interrupt
occurs. Note that you may need to change the
address. */
#include <visa.h>
#include <stdio.h>
#if defined (_WIN32)
#include <windows.h> /* for Sleep() */
#define YIELD Sleep( 10 )
#elif defined (_WINDOWS)
#include <io.h> /* for _wyield */
#define YIELD _wyield()
#else
#include <unistd.h>
#define YIELD sleep (1)
#endif
int srqOccurred;
/* trigger event handler */
ViStatus _VI_FUNCH mySrqHdlr(ViSession vi,
ViEventType
eventType, ViEvent ctx, ViAddr userHdlr){
ViUInt16 statusByte;
/* make sure it is an SRQ event */
if(eventType!=VI_EVENT_SERVICE_REQ){
/* Stray event, so ignore */
printf( "\nStray event of type 0x%lx\n",
eventType );
return VI_SUCCESS;
}