Specifications

Chapter 16 181
ESA/PSA Programming Examples
Using C to Serial Poll the Analyzer to Determine when an Auto-alignment is
Complete
ESA/PSA Programming Examples
printf("Performing self-alignment.\n");
/* Serial pole the instrument for operation complete */
while(1)
{
viQueryf(viPSA,"*ESR?\n","%ld",&esr);
printf(".");
if (esr & 1) break;//look for operation complete bit
Sleep (1000);// wait 1000ms before polling again
}
/* Query the Status Questionable Condition Register */
viQueryf(viPSA,":STAT:QUES:CAL:COND?\n","%ld",&stat);
/*Determine if alignment was successful*/
if (stat)
printf("\nAlignment not successful\n\n");
else
printf("\nAlignment successful\n\n");
/*reset timeout to 5 sec*/
viSetAttribute(viPSA,VI_ATTR_TMO_VALUE,5000);
/*print message to the standard output*/
printf("Press Return to exit program \n\n");
scanf("%c",&cEnter);
/* Close session */
viClose (viPSA);
viClose (defaultRM);
}