Agilent Technologies E4406A VSA Satellite Radio User Manual


 
Chapter 3 137
Programming Examples
Saving ASCII Trace Data in an ASCII File
ViSession defaultRM, viVSA;
ViStatus viStatus= 0;
char sTraceInfo [256]= {0};
char sTraceBuffer[1024*100]= {0};
FILE *fTraceFile;
long lComplete= 0;
unsigned long lBytesRetrieved;
/*open session to GPIB device at address 18 */
viStatus=viOpenDefaultRM (&defaultRM);
viStatus=viOpen (defaultRM, "GPIB0::18::INSTR", VI_NULL,VI_NULL, &viVSA);
/*check opening session sucess*/
if(viStatus)
{
printf("Could not open a session to GPIB device at address 18!\n");
exit(0);
}
/* Set the instrument to basic mode */
viPrintf(viVSA, "INST BASIC\n");
/* Reset device */
viPrintf(viVSA, "*RST\n");
/*set the input port to the internal 50MHz reference source*/
viPrintf(viVSA, "SENS:FEED AREF\n");
/*zoom the spectrum display*/
viPrintf(viVSA, "DISP:FORM:ZOOM1\n");
/*tune the analyzer to 50MHz*/
viPrintf(viVSA, "SENS:FREQ:CENT 50E6\n");
/*print message to the standard output*/
printf("Getting the spectrum trace in ASCII format...\nPlease wait...\n\n");
/*set the analyzer in single mode*/
viPrintf(viVSA, "INIT:CONT 0\n");
/*trigger a spectrum measurement and wait for it to complete*/
viPrintf(viVSA, "INIT:IMM;*WAI\n");
/*query the spectrum trace information*/
viPrintf(viVSA, "FETCH:SPEC1?\n");
/*save the info trace to buffer*/
viRead (viVSA,(ViBuf)sTraceInfo,256,&lBytesRetrieved);