Specifications

296 Chapter 18
PSA Programming Examples
Using C to Make a Power Calibration Measurement for a GSM Mobile
Handset
PSA Programming Examples
/* read the terminator character and discard */
viRead (viVSA,(ViBuf)sBuffer,1, &lthrowaway);
/*print message to the standard output*/
printf("Querying instrument to see if any errors in Queue.\n");
/* loop until all errors read */
do
{
viPrintf (viVSA,"SYST:ERR?\n"); /* check for errors */
viRead (viVSA,(ViBuf)sBuffer,80,&lLength);/* read back last error message */
sBuffer[lLength] = 0; /* append a null to byte count */
printf("%s\n",sBuffer); /* print error buffer to display */
} while (sBuffer[1] != 0);
/* Turn the Display of the instrument back on */
viPrintf(viVSA,"DISP:ENAB 1\n");
/*save result data to an ASCII file*/
fDataFile=fopen("powercal.txt","w");
fprintf(fDataFile,"powercal.exe Output\nAgilent Technologies 2003\n\n");
fprintf(fDataFile,"Power of %d GSM/EDGE bursts:\n",lNumberPoints);
fprintf(fDataFile,"(%d burst(s) per frame):\n\n",lbursts);
for (i=0;i<lNumberPoints;i++)
{
fprintf(fDataFile,"\tPower of burst[%d] = %.2lf dBm\n",i+1,adDataArray[i]);
}
fclose(fDataFile);
/*print message to the standard output*/
printf("The %d burst powers were saved to powercal.txt
file.\n\n",lNumberPoints);
viClose (viVSA);
viClose (defaultRM);
}