USB serial protocol
USB CDC at 115200 baud. Commands and responses are UTF-8, newline-delimited records.
Commands
| Command | Roles | Response |
|---|---|---|
PING | I, R | PONG |
INFO | I, R | INFO, one or more DIAG lines, then PHY |
RESET_STATS | I, R | OK RESET_STATS |
CALIB <i32> | R | OK CALIB <i32> |
Stream records
Distance
D <seq> <millimeters> <exchange_us> <rssi_tenths_dbm>
D 42 3046 16174 -748
seq | Unsigned 8-bit exchange sequence, wrapping at 256. |
|---|---|
millimeters | Calibrated two-way range. |
exchange_us | Elapsed exchange time reported by the responder. |
rssi_tenths_dbm | Receive power in tenths of dBm; divide by 10. |
Miss
MISS <seq> <reason>
MISS 193 no-final
Known reasons include no-final, bad-final-id, final-seq-N, and compute-fail.
INFO response
INFO mode=R calib=12255 fw=twr_resp-5 id=... target_hz=40 drops=0
DIAG polls=2602 no_final=1 bad_final=4 seq_final=0
DIAG rx_err=0 resp_tx_err=0
PHY br=850 pre=128 sfd=ieee ch=9
CALIB is volatile.The command changes the active responder offset in RAM. Reapply it after reconnecting, use the host scripts' saved calibration, or let the browser console restore its saved value.
Minimal Python reader
import serial
with serial.Serial("/dev/tty.usbmodem1201", 115200, timeout=1) as tag:
tag.write(b"INFO\n")
while True:
line = tag.readline().decode(errors="replace").strip()
if line:
print(line)