Skip to content

Decode the binary wire protocol in the logger - #2

Merged
ShivtejG236 merged 1 commit into
mainfrom
feat/binary-wire-protocol
Nov 14, 2026
Merged

ShivtejG236 merged 1 commit into
mainfrom
feat/binary-wire-protocol

Conversation

@ShivtejG236

Copy link
Copy Markdown
Member

Host side of step 2. Pairs with firmware PR #2 (binary wire protocol v1).

What changes

  • pipeline/wire.py: frame decoder (COBS, CRC-16/CCITT-FALSE) and a StreamDecoder that works out whether the board runs the binary firmware or the CSV debug build and produces the same events for both.
  • logger.py reads raw bytes through the decoder. raw.csv has the same 22 columns as before, so trim, diagnose, calibrate and plot are untouched.
  • raw/firmware.json stores what the firmware reported (board, version, git revision, sensors); metadata.json includes it.
  • The end-of-run summary shows frames lost on the wire (sequence gaps), CRC errors and the firmware's ring-buffer drops.
  • Firmware with a newer protocol version is refused with a clear message.
  • A CSV header reprinted after a reboot is skipped, not written as a row.

Testing

  • 41 tests pass locally. The new ones decode tests/fixtures/wire_golden_v1.bin, which is the output of the firmware's own encoder (firmware/tools/host/wire_dump.cpp), so encoder and decoder are checked against each other.
  • Covered: byte-at-a-time delivery, a corrupted frame, attaching mid-frame, boot noise, unknown frame types, CSV detection, rows before the hello.
  • Not tested against a real board.

Old CSV firmware keeps working with this logger, so this PR is safe to merge before the firmware one.


Generated by Claude Code

- pipeline/wire.py: COBS/CRC-16 frame decoder and a StreamDecoder that
  detects binary vs CSV firmware and yields the same events for both
- logger writes the same raw.csv either way, records the firmware's
  identity in raw/firmware.json, and reports lost frames and CRC errors
- refuse firmware with an unknown protocol version
- tests against a golden stream generated by the firmware's encoder
@ShivtejG236
ShivtejG236 merged commit 2f2429a into main Nov 14, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant