fix(ld2451): fix FrameParser return semantics, skip config frames, document direction byte#2
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
FrameParser::pop()return value on tail mismatch — previously returnedtrue(implying a frame was produced) when the tail bytes didn't match and only 1 byte was advanced. Now returnsfalse, consistent with the API contract thattruemeans a complete frame was consumed.extract_frame_()frame_producedtracking — theloop()drain loop was settingparsed_frame = trueeven for sync-error retries (tail mismatch advances), silently suppressing the RX-activity diagnostic log. Refactored to separate "should keep draining" (return value) from "did a real frame get parsed" (newbool &frame_producedreference param).F4 F3 F2 F1header) and config/ACK (FD FC FB FAheader). Previously a config ACK would be consumed byte-by-byte as the parser searched for the data header, causing spurious log noise and delaying the next real frame. BothFrameParser::pop()andLD2451Component::extract_frame_()now detect the config header, read the 2-byte LE length, and erase the complete config frame in one operation.types.hconfirming0x00 = Approaching, 0x01 = Moving away.Test plan
frame_parser_test.cpp: config frame followed by data frame parses correctly; tail mismatch returnsfalsebash components/ld2451/tests_host/run_host_tests.sh)Note
I used Claude Code for some of these changes