Programmer’s Guide 6-5
Trace Data Transfers
Querying the Measurement Trace Using SICL
Querying the Measurement Trace Using
SICL
This section includes a complete SICL C program that shows how to read
the measurement trace from the analyzer.
/**************************************************************************
* This program takes a sweep, reads the trace, and prints it.
* It uses SICL (Standard Instrument Control Library) to talk
* to the analyzer over HP-IB.
*
* On HP-UX, compile using: cc -Aa -o query_trace query_trace.c -lsicl
**************************************************************************/
#include <sicl.h> /* For iopen(), iprintf(), iscanf(), INST, ... */
#include <stdio.h> /* For printf() */
int main(void) {
INST analyzer; /* Handle used to talk to analyzer */
float data_buf[1601]; /* measurement trace. 32-bit floats */
int num_trace_bytes;
int pt;
num_trace_bytes = sizeof(data_buf); /* Set to max allowable bytes */
/* Open the network analyzer at address 16 */
analyzer = iopen("hpib,16");
/* Clear the bus */
iclear(analyzer);
/* Abort current sweep and put analyzer sweep in hold */
iprintf(analyzer, "ABORT\n");
iprintf(analyzer, "INIT:CONT OFF\n");
/* Take one sweep, wait until done */
iprintf(analyzer, "INIT1\n");
iprintf(analyzer, "*OPC?\n");
iscanf(analyzer, "%*s");
/* Request the trace data in 32-bit floating point format */
iprintf(analyzer, "FORM:BORD NORM\n");
iprintf(analyzer, "FORM:DATA REAL,32\n");
/* Query the trace, read into data_buf[]. */
iprintf(analyzer, "TRAC? CH1FDATA\n");
iscanf(analyzer, "%#b%*c", &num_trace_bytes, &data_buf[0]);
/* Print the trace values. */
for (pt = 0; pt < num_trace_bytes/sizeof(float); pt++) {
printf("%4d %g\n", pt, data_buf[pt]);
}
/* Close analyzer and exit. */
iclose(analyzer);
return 0;
}