Agilent Technologies E4406A VSA Programming Examples, Saving Binary Trace Data in an ASCII File

Models: E4406A VSA

1 406
Download 406 pages 63.49 Kb
Page 134
Image 134
Manual background

Programming Examples

Saving Binary Trace Data in an ASCII File

viPrintf(viVSA,"%s\n",vsaSetup);

/*print message to the standard output*/

printf("Getting the spectrum trace in binary format...\nPlease wait...\n\n");

/* get number of bytes in length of postceeding trace data and put this in sBuffer*/

viRead (viVSA,(ViBuf)sBuffer,2,&lBytesRetrieved);

/* Put the trace data into sBuffer */

viRead (viVSA,(ViBuf)sBuffer,sBuffer[1] - ’0’,&lBytesRetrieved);

/* append a null to sBuffer */ sBuffer[lBytesRetrieved] = 0;

/* convert sBuffer from ASCII to integer */ lNumberBytes = atoi(sBuffer);

/*calculate the number of points given the number of byte in the trace REAL 64 binary format means each number is represented by 8 bytes*/ lNumberPoints = lNumberBytes/sizeof(ViReal64);

/*get and save trace in data array */

viRead (viVSA,(ViBuf)adTraceArray,lNumberBytes,&lBytesRetrieved);

/* read the terminator character and discard */ viRead (viVSA,(ViBuf)sBuffer,1, &lLength);

/* 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’);

 

 

134

Chapter 3

Page 134
Image 134
Agilent Technologies E4406A VSA manual Programming Examples, Saving Binary Trace Data in an ASCII File