
60
Agilent VISA User’s Guide
3
Programming with VISA
Example: SRQ Callback
This program installs an event handler
and enables an SRQ event. When the event occurs, the installed event
handler is called. This sample 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 program is installed on your system in the
ProgrammingSamples
subdirectory. See the
IO Libraries Suite
Online Help
for locations of example 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 */
Summary of Contents for E2094S
Page 6: ...6 Agilent VISA User s Guide ...
Page 116: ...116 Agilent VISA User s Guide 4 Programming via GPIB and VXI ...
Page 126: ...126 Agilent VISA User s Guide 5 Programming via LAN ...
Page 143: ...Glossary Agilent VISA User s Guide 143 Windows notification area See notification area ...