Agilent Technologies Model A.08.xx Water Dispenser User Manual


 
128 Chapter 3
Programming Examples
Reading Trace Data Using ASCII Format (RS-232)
/*set the analyzer to single sweep mode*/
viPrintf(viESA,"INIT:CONT 0 \n");
/*Trigger a spectrum measurement*/
viPrintf(viESA,"INIT:IMM \n");
/*Read the operation complete query*/
viQueryf(viESA, "*OPC?\n", "%d", &lOpc);
if (!lOpc)
{
printf("Program Abort! error ocurred: last command was not completed!\n");
exit(0);
}
/*Specify units in dBm*/
viPrintf(viESA,"UNIT:POW DBM \n");
/*Set analyzer trace data format to ASCII Format*/
viPrintf(viESA,"FORM:DATA ASC \n");
/*Trigger a spectrum measurement*/
viPrintf(viESA,"INIT:IMM \n");
/*Read the operation complete query */
viQueryf(viESA, "*OPC?\n", "%d", &lOpc);
if (!lOpc)
{
printf("Program Abort! error ocurred: last command was not completed!\n");
exit(0);
}
/*Query the Trace Data using ASCII Format */
viQueryf(viESA,"%s\n", "%#t","TRAC:DATA? TRACE1" , &iNum , cResult);
/*Remove the "," from the ASCII trace data for analyzing data*/
cToken = strtok(cResult,",");
/*Save trace data to an ASCII to a file, by removing the "," token*/
fTraceFile=fopen("C:\\temp\\ReadAscRS232.txt","w");
fprintf(fTraceFile,"ReadAscRS232.exe Output\nHewlett-Packard 1999\n\n");
fprintf(fTraceFile,"\tAmplitude of point[%d] = %s dBm\n",lCount+1,cToken);
while (cToken != NULL)
{
lCount++;
cToken =strtok(NULL,",");
if (lCount != iSwpPnts)
fprintf(fTraceFile,"\tAmplitude of point[%d] = %s