Skip to content

HDLC and OverAscii: test against the firmware's framing vectors, and match it - #35

Merged
robdobsn merged 1 commit into
mainfrom
feature/comms-framing-vectors
Nov 14, 2026
Merged

robdobsn merged 1 commit into
mainfrom
feature/comms-framing-vectors

Conversation

@robdobsn

Copy link
Copy Markdown
Owner

Tests raftjs's HDLC and OverAscii framing against the shared vectors that RaftCore makes from the firmware's own MiniHDLC and ProtocolOverAscii (robdobsn/RaftCore#54), and fixes what they found.

Fixes

  • Escape before a flag: an escape byte just before a flag carried over into the next frame and corrupted its first byte, so that frame was lost. A flag now ends the escape, as in the firmware.
  • Encoder buffer size: the buffer (2n+4) was too small when every payload byte and both CRC bytes are escaped (2n+6), so Uint8Array.set threw.
  • Empty-payload frames: a frame with an empty payload (only the 2 CRC bytes) was ignored; the firmware delivers it (RaftMsgHandler counts it as too short).
  • WebSerial console text: only the first complete console text line in a received chunk was logged.

Tests

src/RaftCommsFramingVectors.test.ts runs the vectors in testdata/hdlc_vectors.json and testdata/overascii_vectors.json. These are copies of RaftCore's scripts/tests/ files and are identical to the ones now on RaftCore main. After an intended framing change, regenerate them in RaftCore with ./test_comms_framing_vectors --write and copy them here.

🤖 Generated with Claude Code

…match it

Tested against RaftCore's shared hdlc_vectors.json and overascii_vectors.json (made
from the firmware's MiniHDLC and ProtocolOverAscii), which found:
- An escape just before a flag carried over into the next frame, corrupting its first
  byte so that frame was lost. A flag now ends the escape, as in the firmware.
- The encoder's buffer (2n+4) was too small when every payload byte and both CRC bytes
  are escaped (2n+6), so Uint8Array.set threw.
- A frame whose payload is empty (2 CRC bytes) was ignored; the firmware delivers it
  (RaftMsgHandler counts it as too short).
- WebSerial logged only the first complete console text line in a received chunk.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@robdobsn
robdobsn merged commit 9ccccc8 into main Nov 14, 2026
1 check passed
@robdobsn
robdobsn deleted the feature/comms-framing-vectors branch November 14, 2026 22:09
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