User`s guide

Programming with VISA 3
Agilent VISA User’s Guide 81
Sample: Printing Error Code
The following error handler prints a user- readable string
describing the error code passed to the function:
void err_handler(ViSession vi, ViStatus err){
char err_msg[1024]={0};
viStatusDesc (vi, err, err_msg);
printf ("ERROR = %s\n", err_msg);
return;
}
Sample: 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 sample 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);
}