
Programming with VISA
3
Agilent VISA User’s Guide
69
char err_msg[1024]={0};
viStatusDesc (vi, err, err_msg);
printf ("ERROR = %s\n", err_msg);
return;
}
Example: Checking Instrument Errors
When programming
instruments, it is good practice to check the instrument to ensure there
are no instrument errors after each instrument function. This example
uses a SCPI command to check a specific instrument for errors.
void system_err(){
ViStatus err;
char buf[1024]={0};
int err_no;
err=viPrintf(vi, "SYSTEM:ERR?\n");
if (err < VI_SUCCESS) err_handler (vi, err);
err=viScanf (vi, "%d%t", &err_no, &buf);
if (err < VI_SUCCESS) err_handler (vi, err);
while (err_no >0){
printf ("Error Found: %d,%s\n", err_no,
buf);
err=viScanf (vi, "%d%t", &err_no, &buf);
}
err=viFlush(vi, VI_READ_BUF);
if (err < VI_SUCCESS) err_handler (vi, err);
err=viFlush(vi, VI_WRITE_BUF);
if (err < VI_SUCCESS) err_handler (vi, err);
}
Exception Events
An alternative to trapping VISA errors by checking the return status
after each VISA call is to use the VISA
exception event
. On sessions
where an exception event handler is installed and
VI_EVENT_EXCEPTION is enabled, the exception event handler is
called whenever an error occurs while executing an operation.
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 ...