HP ESA-E Series Programmer's Manual page 102

Esa spectrum analyzers
Table of Contents

Advertisement

Programming Examples
Reading Trace Data Using 32-bit Real Format (RS-232)
/* Specify dB per division of each vertical division &
Units */
viPrintf(viESA,"DISP:WIND:TRAC:Y:SCAL:PDIV 10dB; \n");
viPrintf(viESA,"UNIT:POW DBM; \n");
/*Set analyzer trace data format to 32-bit Real */
viPrintf(viESA,"FORM:DATA REAL,32; \n");
/*Set the binary byte order to SWAP */
viPrintf(viESA, "FORM:BORD SWAP;\n");
/*Trigger a sweep */
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);
}
/*Get trace and header data, in this case we know its
1701 bytes */
viPrintf(viESA,"TRAC:DATA? TRACE1\n");
viRead (viESA,(ViBuf)cResult,1701,&lRetCount);
/*Extract the number of bytes from the trace header */
memcpy(cBufferInfo,cResult+2,4);
lNumberBytes = atoi(cBufferInfo);
iSize = lNumberBytes +6+1;
/*Get trace header data and trace data */
viRead (viESA,(ViBuf)cResult,iSize,&lRetCount);
/*Extract the trace data*/
memcpy(dTraceArray,cResult+6,(size_t)lNumberBytes);
/*Save trace data to an ASCII file*/
fTraceFile=fopen("C:\\temp\\ReadTrace32RS232.txt","w");
fprintf(fTraceFile,"ReadTrace32RS232.exe
Output\nHewlett-Packard 1999\n\n");
fprintf(fTraceFile,"The %d trace data points of the
spectrum:\n\n",(lNumberBytes/4));
3-38
Chapter 3

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents