160 Chapter 3
ProgrammingExamples
Determine if an Error has Occurred
viPrintf(viESA,"INIT:CONT 1 \n");
/*Manually couple sweeptime to 5ms . reduce resolution BW to 30 KHz.
"Meas Uncal" should be displayed o n the screen, and an interrupt sho uld
be generated.*/
viPrintf(viESA,"SENS:SWE:TIME 5 ms \n");
viPrintf(viESA,"SENS:BAND:RES 30 K HZ \n");
/*Wait for SRQ*/
WaitForSRQ();
/*Pause for 5 seconds to observe " Meas Uncal" message on ESA display */
Sleep(5000);
/* Set the service request mask to assert SRQ when either a measurem ent
is completed or an error messag e has occurred.*/
viPrintf(viESA,"*SRE 96\n");
viPrintf(viESA,"*ESE 35\n");
/*Send an undefined command to the device*/
viPrintf(viESA,"IDN\n");
/*Wait for SRQ*/
WaitForSRQ();
/*Disable and uninstall the interr upt handler*/
viDisableEvent (viESA, VI_EVENT_S ERVICE_REQ,VI_HNDLR);
viUninstallHandler(viESA, VI_EVENT _SERVICE_REQ, sSrqHdlr,ViAddr(10)) ;
/*Clear the instrument status regi ster*/
viPrintf(viESA,"*SRE 0 \n");
viPrintf(viESA,"*ESE 0 \n");
viPrintf(viESA,"STAT:QUES:ENAB 0\n");
viPrintf(viESA,"STAT:QUES:INT:EN AB 0\n");
/*Clear the status byte of the ins trument*/
viPrintf(viESA,"*CLS\n");
/*Close the session*/
viClose(viESA);
viClose(defaultRM);
}