Skip to content

Fix parser synchronization across noise and chunk boundaries - #3153

Open
Solarboaters wants to merge 1 commit into
serialport:mainfrom
Solarboaters:fix/parser-framing-boundaries
Open

Solarboaters wants to merge 1 commit into
serialport:mainfrom
Solarboaters:fix/parser-framing-boundaries

Conversation

@Solarboaters

Copy link
Copy Markdown

Fixes #3152, using trackoor's reported framing examples (credited there to UCSB PLSE).

ReadyParser now preserves overlapping delimiter prefixes, PacketLengthParser discards the oldest byte while resynchronizing, and SpacePacketParser clears the previous payload when the next chunk ends exactly at a header. Valid input no longer disappears or produces a duplicate packet at these boundaries.

The three new regression tests fail on main 9fa6881 and pass with the fix. They exercise every two-chunk split of the example streams, including repeated delimiter prefixes and noise between packets. On Linux with Node 24.22.3: npm test passes (198 passing, one existing pending); lint, typecheck and build pass. These are production stream-parser tests; no serial hardware was used.

Prepared with ChatGPT assistance.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Ready, PacketLength (multi-byte delimiter) and SpacePacket parsers lose or duplicate packets

1 participant