Data Export Commands
Commands for exporting measurement data and screen captures.
Output measured S-parameter data.
Syntax
Section titled “Syntax”data [channel]Parameters
Section titled “Parameters”| Array | Description |
|---|---|
0 | S11 (CH0) — measured or calibrated reflection |
1 | S21 (CH1) — measured or calibrated transmission |
2 | Calibration: Directivity (ED) |
3 | Calibration: Source Match (ES) |
4 | Calibration: Reflection Tracking (ER) |
5 | Calibration: Transmission Tracking (ET) |
6 | Calibration: Isolation (EX) |
Output Format
Section titled “Output Format”One line per sweep point, real and imaginary parts:
<real> <imaginary>Examples
Section titled “Examples”ch> data 00.998234 -0.0234560.997234 -0.0245670.996234 -0.025678...
ch> data 10.012345 0.0012340.012456 0.001345...- Values are linear complex pairs (not dB)
- Arrays 0–1 reflect current calibration state (corrected if
cal on) - Arrays 2–6 contain raw calibration error terms — useful for custom post-processing
- For uncalibrated measurement data, disable cal first:
cal off - Number of lines equals
sweep_points(query withsweep)
Converting to dB
Section titled “Converting to dB”import mathmagnitude_dB = 20 * math.log10(math.sqrt(re**2 + im**2))phase_deg = math.degrees(math.atan2(im, re))frequencies
Section titled “frequencies”Output frequency list for current sweep.
Syntax
Section titled “Syntax”frequenciesOutput Format
Section titled “Output Format”One frequency per line in Hz:
100000020000003000000...Example
Section titled “Example”ch> frequencies100000019900992980198...- Frequencies are the actual sweep points
- Number of lines equals
sweep_points - Use with
datato get frequency-indexed measurements
capture
Section titled “capture”Capture screen as binary data. Supports raw RGB565 and an RLE8 palette-compressed format.
Syntax
Section titled “Syntax”capture [rle8]Output Format
Section titled “Output Format”Binary RGB565 pixel data, row by row from top-left:
- 320x240 display: 153,600 bytes (320 * 240 * 2)
- 480x320 display: 307,200 bytes (480 * 320 * 2)
RGB565 Byte Order
Section titled “RGB565 Byte Order”Each pixel is 2 bytes, little-endian RGB565:
Byte 0: GGGBBBBB (low byte)Byte 1: RRRRRGGG (high byte)Example Usage (Python)
Section titled “Example Usage (Python)”import serialfrom PIL import Image
ser = serial.Serial('/dev/ttyACM0', 115200)ser.write(b'capture\r')
# For 320x240 displaydata = ser.read(320 * 240 * 2)
# Convert to imageimg = Image.new('RGB', (320, 240))pixels = []for i in range(0, len(data), 2): rgb565 = data[i] | (data[i+1] << 8) r = ((rgb565 >> 11) & 0x1F) << 3 g = ((rgb565 >> 5) & 0x3F) << 2 b = (rgb565 & 0x1F) << 3 pixels.append((r, g, b))img.putdata(pixels)img.save('capture.png')RLE8 Compressed Format
Section titled “RLE8 Compressed Format”When rle8 is specified (requires __CAPTURE_RLE8__), the output uses palette-based RLE compression for significantly smaller transfers:
Header:
| Field | Type | Description |
|---|---|---|
magic | uint16_t | 0x4D42 (BMP signature) |
width | uint16_t | Display width |
height | uint16_t | Display height |
bpp | uint8_t | 8 (bits per pixel) |
compression | uint8_t | 1 (RLE8) |
Palette block:
| Field | Type | Description |
|---|---|---|
size | uint16_t | Palette data size in bytes |
palette | uint16_t[] | RGB565 color palette entries |
Row data: Each row is PackBits-compressed with a uint16_t length prefix followed by the compressed bytes.
Dump raw ADC sample data (requires ENABLED_DUMP_COMMAND).
Syntax
Section titled “Syntax”dumpOutput Format
Section titled “Output Format”Binary raw ADC samples from the TLV320AIC3204 codec.
For debugging audio codec and signal processing:
- Connect known signal
- Run
dumpcommand - Capture binary output
- Analyze in external tool
sample
Section titled “sample”Select the sample acquisition function used by the gamma command (requires ENABLE_SAMPLE_COMMAND).
Syntax
Section titled “Syntax”sample <mode>| Mode | Function | Description |
|---|---|---|
gamma | calculate_gamma | Compute complex gamma from I/Q samples (default) |
ampl | fetch_amplitude | Raw amplitude from measurement channel |
ref | fetch_amplitude_ref | Raw amplitude from reference channel |
Examples
Section titled “Examples”ch> sample gammach> sample amplch> sample ref- Debug command for characterizing signal path behavior
- Changes what the
gammacommand returns - Default mode is
gamma(complex reflection coefficient calculation)
Take a single-point measurement and return the raw gamma (reflection coefficient) value. Requires ENABLE_SAMPLE_COMMAND.
Syntax
Section titled “Syntax”gammaOutput
Section titled “Output”Two integer values representing the real and imaginary parts of gamma:
ch> gamma12345 -6789- Pauses the sweep, acquires DSP samples, and computes gamma
- The acquisition function can be changed with the
samplecommand - Useful for real-time monitoring of a single frequency point
- Values are integer-scaled (not the
0.0–1.0float range ofdata)
measure
Section titled “measure”Output measurement module results (requires __VNA_MEASURE_MODULE__).
Syntax
Section titled “Syntax”measure [type]Measurement Types
Section titled “Measurement Types”| Type | S-param | Compile Flag | Description |
|---|---|---|---|
none | — | (always) | Disable measurement display |
lc | S11 | __USE_LC_MATCHING__ | L/C matching network values |
lcshunt | S21 | __S21_MEASURE__ | Shunt LC component extraction |
lcseries | S21 | __S21_MEASURE__ | Series LC component extraction |
xtal | S21 | __S21_MEASURE__ | Crystal motional parameters |
filter | S21 | __S21_MEASURE__ | Filter characterization (BW, loss, ripple) |
cable | S11 | __S11_CABLE_MEASURE__ | Cable length and loss |
resonance | S11 | __S11_RESONANCE_MEASURE__ | Resonance frequency and Q |
Examples
Section titled “Examples”ch> measure cableLength: 1.234 mLoss: 0.5 dB
ch> measure resonanceFrequency: 145.000000 MHzQ: 125.3
ch> measure offOutput Fields
Section titled “Output Fields”Depends on measurement type:
Cable:
- Length in meters
- Loss in dB
Resonance:
- Frequency
- Q factor
- Bandwidth
LC Components:
- Inductance (H)
- Capacitance (F)
- Quality factor
Crystal:
- Series resonance
- Parallel resonance
- Motional parameters
Filter:
- Passband ripple
- 3dB bandwidth
- Insertion loss
Data Processing Examples
Section titled “Data Processing Examples”Export to Touchstone S1P
Section titled “Export to Touchstone S1P”import serial
ser = serial.Serial('/dev/ttyACM0', 115200)
# Get frequenciesser.write(b'frequencies\r')freqs = []while True: line = ser.readline().decode().strip() if not line or line.startswith('ch>'): break freqs.append(float(line))
# Get S11 dataser.write(b'data 0\r')s11 = []while True: line = ser.readline().decode().strip() if not line or line.startswith('ch>'): break re, im = map(float, line.split()) s11.append((re, im))
# Write S1P filewith open('output.s1p', 'w') as f: f.write('# Hz S RI R 50\n') for freq, (re, im) in zip(freqs, s11): f.write(f'{freq:.0f} {re:.9f} {im:.9f}\n')Export to CSV
Section titled “Export to CSV”import serialimport csv
ser = serial.Serial('/dev/ttyACM0', 115200)
# Collect data (similar to above)# ...
with open('output.csv', 'w', newline='') as f: writer = csv.writer(f) writer.writerow(['Frequency (Hz)', 'S11 Real', 'S11 Imag', 'S21 Real', 'S21 Imag']) for i, freq in enumerate(freqs): writer.writerow([freq, s11[i][0], s11[i][1], s21[i][0], s21[i][1]])Source Code Reference
Section titled “Source Code Reference”Data export commands in main.c:
cmd_data: line 738 — array index 0–6 selectsmeasured[]orcal_data[]cmd_frequencies: line 2354cmd_capture: line 789 — RLE8 variant at line 758cmd_dump: line 1238 (conditional:ENABLED_DUMP_COMMAND)cmd_sample: line 828 (conditional:ENABLE_SAMPLE_COMMAND)cmd_gamma: line 810 (conditional:ENABLE_SAMPLE_COMMAND)cmd_measure: line 582 (conditional:__VNA_MEASURE_MODULE__)