Repository navigation
fix: keep examples from persisting parameter changes - #14
Merged
Merged
Conversation
added 2 commits
October 26, 2026 18:57
05_ff_tune.cpp called save_params() after writing FF parameters, which persists them to flash irreversibly. Remove the call and state in the docstring, output and README that the example only writes RAM.
07_vel_jitter_trace wrote ff_mask for the A/B run and only printed a hint to restore it by hand. A RAM parameter change left behind changes the next session's feedforward. Restore the original mask on scope exit, including exceptions and early returns.
yd-sl
self-requested a review
October 26, 2026 11:25
cao-xiao-hao
approved these changes
Oct 28, 2026
cao-xiao-hao
left a comment
There was a problem hiding this comment.
Approved. Built and ran the suite on the PR head (207bc49):
$ cmake -S . -B /tmp/litearm-cpp-pr14 -DCMAKE_BUILD_TYPE=Release
$ cmake --build /tmp/litearm-cpp-pr14 -j4
$ ctest --test-dir /tmp/litearm-cpp-pr14 --output-on-failure
100% tests passed out of 29
1 skipped: test_protocol_sync (needs LITEARM_FW_DIR)Checked:
05_ff_tuneno longer callssave_params().grep -nE 'save_params|reset_factory|save_tool'overexamples/matches only the comments that explain why the example stays in RAM.FfMaskRestore::remember()is called beforeset_ff_mask(), so a write that throws after the frame has already gone out is still restored. The destructor swallows restore failures, so it cannot mask the primary exception, and it runs on both earlyreturnand stack unwinding.- The guard is constructed after
cart_supported()and beforeenable(), so every path that can write the mask is covered. get_ff_mask()returnsint(include/litearm/arm.hpp:417); thestatic_cast<uint32_t>is valid and the mask is not sign-extended.examples/README.mdnow states the RAM-only behavior, matching the code.
The restore behavior has no regression test — there is no existing harness that runs the example scripts, only test_example_args for _common.cpp. Not blocking, but worth covering if such a harness is added.
|
🎉 This PR is included in version 0.3.1 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
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
Keeps the examples from persisting or leaving behind parameter changes.
05_ff_tuneno longer callssave_params();07_vel_jitter_tracerestores theff_maskit changes for the A/B run.Changes
examples/05_ff_tune.cpp: removesave_params(); write FF parameters to RAM only. Update the docstring, output andexamples/README.md.examples/07_vel_jitter_trace.cpp: restore the originalff_maskon scope exit, including exceptions and early returns; update the docstring.No other example calls a persistence API.
Testing
$ cmake -S . -B /tmp/litearm-cpp-full -DCMAKE_BUILD_TYPE=Release $ cmake --build /tmp/litearm-cpp-full -j2 $ ctest --test-dir /tmp/litearm-cpp-full --output-on-failure 100% tests passed, 0 tests failed out of 29 1 skipped: test_protocol_sync (needs LITEARM_FW_DIR)grep -rnE 'save_params|reset_factory|save_tool|model\(\)\.commit|CMD_PARAM_SAVE' examples/returns only comments in05_ff_tune.cpp; no calls.Issues
None.