Repository navigation
Conversation
IncreaseOffset() and SetOffset() mutate offset_steps before calling GoToTargetFlapIndex(), which returns early unless the module is NORMAL. A module in SENSOR_ERROR therefore accepts an offset change it never physically applies, and a subsequent SaveAllOffsets() writes that value to config.pb. Check state before mutating, matching the existing guard in GoToFlapIndex().
This branch has not been deployed
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.
Problem
IncreaseOffset()andSetOffset()infirmware/src/splitflap_module.hmutate
offset_stepsbefore callingGoToTargetFlapIndex(), and neitherchecks module state.
GoToTargetFlapIndex()returns early unless the moduleis
NORMAL.The result is that a module in
SENSOR_ERRORaccepts an offset change itnever physically applies. The stored offset and the hardware disagree, and
SaveAllOffsets()will then write that value toconfig.pb— so thecorruption survives a reboot.
SetOffset()is the more damaging of the two, sinceoffset_steps = current_stepadopts a step count that is only meaningful while the moduleis actually tracking its position.
Reproduction
On a Chainlink chain with an unpopulated (or otherwise faulted) module:
SENSOR_ERRORviarequest_state.INCREASE_OFFSET_TENTHto it. The module does not move — expected.offset_stepshas changed regardless.SAVE_ALL_OFFSETS. The bad value is now inconfig.pb.Observed on an ESP32 Chainlink Buddy driving a six-module chain.
Change
Check
state != NORMALand return before mutating, in both functions.This matches the guard
GoToFlapIndex()already performs a few functionsabove, which checks state before assigning
target_flap_index. No call sitechanges: the three callers in
splitflap_task.cpp(
QCMD_INCR_OFFSET_TENTH,QCMD_INCR_OFFSET_HALF,QCMD_SET_OFFSET)already ignore any result, and sit in the same switch as
GoToFlapIndex(),which guards internally.
I used strict
NORMALrather than also allowingLOOK_FOR_HOMEthe wayGoToFlapIndex()does, because homing is what establishes the referenceoffset_stepsis measured against — changing the offset partway throughseems like a race worth avoiding. Happy to relax it if you'd rather the two
be consistent.
Builds clean under
chainlink_ota.Known limitation
Rejection is silent, matching the existing style in this file. A user
nudging a faulted module gets no feedback — better than silent corruption,
but not good. Surfacing it in the protocol felt like a separate change and
a broader discussion, so I left it out.