134
Chapter 3
Programming Examples
Saving ASCII Trace Data in an ASCII File
Example:
#include <stdio.h>
#include <stdlib.h>
#include <memory.h>
#include "visa.h"
void main ()
{
/*program variable*/
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);
}
/* 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 instrument to 50MHz*/
viPrintf(viVSA, "SENS:FREQ:CENT 50E6\n");
/*print message to the standard output*/
printf(viVSA, "Getting the spectrum trace in ASCII
format...\nPlease wait...\n\n");
/*set the instrument in single mode*/
viPrintf(viVSA, "INIT:CONT 0\n");
/*trigger a spectrum measurement*/
viPrintf(viVSA, "MEAS:SPEC1?;*OPC?\n");
/*poll the operation complete query*/
while (!lComplete)
viScanf (viVSA,"%d",&lComplete);
Summary of Contents for E4406A VSA Series
Page 4: ...4 ...
Page 59: ...59 2 Programming Fundamentals ...
Page 124: ...124 Chapter2 Programming Fundamentals Using the LAN to Control the Analyzer ...
Page 125: ...125 3 Programming Examples ...
Page 164: ...164 Chapter3 Programming Examples Using Java Programming Over Socket LAN ...
Page 165: ...165 4 Programming Command Cross References ...
Page 379: ...379 6 Error Messages ...
Page 412: ...412 Chapter6 Error Messages Error Message Descriptions ...