Documentation / Interfaces / USB serial

USB serial protocol

USB CDC at 115200 baud. Commands and responses are UTF-8, newline-delimited records.

Commands

CommandRolesResponse
PINGI, RPONG
INFOI, RINFO, one or more DIAG lines, then PHY
RESET_STATSI, ROK RESET_STATS
CALIB <i32>ROK CALIB <i32>

Stream records

Distance

D <seq> <millimeters> <exchange_us> <rssi_tenths_dbm>
D 42 3046 16174 -748
seqUnsigned 8-bit exchange sequence, wrapping at 256.
millimetersCalibrated two-way range.
exchange_usElapsed exchange time reported by the responder.
rssi_tenths_dbmReceive 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)