Return packet type processed in process() - #27
Open
madleech wants to merge 1 commit into
Open
Conversation
brocci
added a commit
to brocci/ArduinoCMRI
that referenced
this pull request
Aug 16, 2026
brocci
added a commit
to brocci/ArduinoCMRI
that referenced
this pull request
Sep 11, 2026
PR madleech#30 consumes the POLL body to ETX before replying to avoid RS-485 bus contention. But POSTAMBLE_IGNORE is also reached when ignoring frames addressed to other nodes, and it decided to reply by checking _rx_packet_type. Since that field is only refreshed in DECODE_CMD, a node that had recently been polled (type == 'P') spuriously transmitted a GET reply every time it finished ignoring another node's frame. On a multi-node bus this ping-ponged between nodes, colliding with the addressed node's response and JMRI's polls. Fix the regression without changing PR madleech#30's design: clear _rx_packet_type when entering IGNORE_CMD, so finishing an ignored (foreign) frame can never look like a pending poll. Also initialize _rx_packet_type in the constructor. Tests: regression tests for hearing another node's POLL/GET and still replying to one's own POLL, plus tests pinning process()'s returned packet type (PR madleech#27 semantics: POLL/SET reported, NOOP for ignored frames and INIT).
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.
The readme specifically says for
process():However in reality it's just returning
true/false. For some users, having it return the processed packet type is a useful enhancement. Lets update it to match the documentation.Note: although this is a behaviour change, anyone doing
if (cmri.process())will see unchanged behaviour, asfalseandNOOPare both0and so equivalent.