User`s guide
72 Agilent VISA User’s Guide
3 Programming with VISA
handler must be installed and exception events
enabled on all sessions where the exception
handler is used.*/
#include <stdio.h>
#include <visa.h>
ViStatus __stdcall myExceptionHandler (
ViSession vi,
ViEventType eventType,
ViEvent context,
ViAddr usrHandle
) {
ViStatus exceptionErrNbr;
char nameBuffer[256];
ViString functionName = nameBuffer;
char errStrBuffer[256];
/* Get the error value from the exception
context */
viGetAttribute( context, VI_ATTR_STATUS,
&exceptionErrNbr );
/* Get the function name from the exception
context */
viGetAttribute( context, VI_ATTR_OPER_NAME,
functionName );
errStrBuffer[0] = 0;
viStatusDesc( vi, exceptionErrNbr,
errStrBuffer );
printf("ERROR: Exception Handler reports\n"
"(%s)\n","VISA function '%s' failed with
error 0x%lx\n", "functionName,
exceptionErrNbr, errStrBuffer );
return VI_SUCCESS;
}
void main(){
ViStatus status;
ViSession drm;
ViSession vi;
ViAddr myUserHandle = 0;