Skip to content

Data Export Commands

Commands for exporting measurement data and screen captures.

Output measured S-parameter data.

data [channel]
ArrayDescription
0S11 (CH0) — measured or calibrated reflection
1S21 (CH1) — measured or calibrated transmission
2Calibration: Directivity (ED)
3Calibration: Source Match (ES)
4Calibration: Reflection Tracking (ER)
5Calibration: Transmission Tracking (ET)
6Calibration: Isolation (EX)

One line per sweep point, real and imaginary parts:

<real> <imaginary>
ch> data 0
0.998234 -0.023456
0.997234 -0.024567
0.996234 -0.025678
...
ch> data 1
0.012345 0.001234
0.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 with sweep)
import math
magnitude_dB = 20 * math.log10(math.sqrt(re**2 + im**2))
phase_deg = math.degrees(math.atan2(im, re))

Output frequency list for current sweep.

frequencies

One frequency per line in Hz:

1000000
2000000
3000000
...
ch> frequencies
1000000
1990099
2980198
...
  • Frequencies are the actual sweep points
  • Number of lines equals sweep_points
  • Use with data to get frequency-indexed measurements

Capture screen as binary data. Supports raw RGB565 and an RLE8 palette-compressed format.

capture [rle8]

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)

Each pixel is 2 bytes, little-endian RGB565:

Byte 0: GGGBBBBB (low byte)
Byte 1: RRRRRGGG (high byte)
import serial
from PIL import Image
ser = serial.Serial('/dev/ttyACM0', 115200)
ser.write(b'capture\r')
# For 320x240 display
data = ser.read(320 * 240 * 2)
# Convert to image
img = 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')

When rle8 is specified (requires __CAPTURE_RLE8__), the output uses palette-based RLE compression for significantly smaller transfers:

Header:

FieldTypeDescription
magicuint16_t0x4D42 (BMP signature)
widthuint16_tDisplay width
heightuint16_tDisplay height
bppuint8_t8 (bits per pixel)
compressionuint8_t1 (RLE8)

Palette block:

FieldTypeDescription
sizeuint16_tPalette data size in bytes
paletteuint16_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).

dump

Binary raw ADC samples from the TLV320AIC3204 codec.

For debugging audio codec and signal processing:

  1. Connect known signal
  2. Run dump command
  3. Capture binary output
  4. Analyze in external tool

Select the sample acquisition function used by the gamma command (requires ENABLE_SAMPLE_COMMAND).

sample <mode>
ModeFunctionDescription
gammacalculate_gammaCompute complex gamma from I/Q samples (default)
amplfetch_amplitudeRaw amplitude from measurement channel
reffetch_amplitude_refRaw amplitude from reference channel
ch> sample gamma
ch> sample ampl
ch> sample ref
  • Debug command for characterizing signal path behavior
  • Changes what the gamma command 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.

gamma

Two integer values representing the real and imaginary parts of gamma:

ch> gamma
12345 -6789
  • Pauses the sweep, acquires DSP samples, and computes gamma
  • The acquisition function can be changed with the sample command
  • Useful for real-time monitoring of a single frequency point
  • Values are integer-scaled (not the 0.0–1.0 float range of data)

Output measurement module results (requires __VNA_MEASURE_MODULE__).

measure [type]
TypeS-paramCompile FlagDescription
none(always)Disable measurement display
lcS11__USE_LC_MATCHING__L/C matching network values
lcshuntS21__S21_MEASURE__Shunt LC component extraction
lcseriesS21__S21_MEASURE__Series LC component extraction
xtalS21__S21_MEASURE__Crystal motional parameters
filterS21__S21_MEASURE__Filter characterization (BW, loss, ripple)
cableS11__S11_CABLE_MEASURE__Cable length and loss
resonanceS11__S11_RESONANCE_MEASURE__Resonance frequency and Q
ch> measure cable
Length: 1.234 m
Loss: 0.5 dB
ch> measure resonance
Frequency: 145.000000 MHz
Q: 125.3
ch> measure off

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

import serial
ser = serial.Serial('/dev/ttyACM0', 115200)
# Get frequencies
ser.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 data
ser.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 file
with 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')
import serial
import 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]])

Data export commands in main.c:

  • cmd_data: line 738 — array index 0–6 selects measured[] or cal_data[]
  • cmd_frequencies: line 2354
  • cmd_capture: line 789 — RLE8 variant at line 758
  • cmd_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__)