-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for saving the active configuration to flash #862
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we're hitting the limits of the design here.
What if we drop the AppSettings
in serial settings, as well as the backing copy in the Miniconf MQTT client, as well as this active_settings
. The original requirement for multiple settings copies (IIRC only) arose because serialization/deserialization could take a while and locking the settings for that time would have starved the low latency process task. Maybe that doesn't scale.
If we can split that into only two settings structs, we might cover all bases. One active low latency that has very short lock durations, and a single "slower" backing one for serialization/deserialization/update tasks in (but not owned by) miniconf and serial settings/flash. The latter would be passed into the slow poll calls as &mut
and flipped onto the low latency active.
For serial settings that would mean the operations actually operate on the single backing buffer (and implicitly on the low latency one). We'd have to make save
explicit. It would also remove lots of docs and explanations around what which op actually affects.
For the mqtt client, a wrinkle would be around wanting to republish a setting when changed via USB. Or foregoing that for now and instead documenting the behavior. It would affect the miniconf
crate as well.
In general passing &mut Settings
into the different "frontends" does sound better than having them each own theirs.
There is also an uncertainty around handled_update
in miniconf-mqtt. I wonder if we actually use that feature (validating/aborting an update) anywhere. Alternatively we can validate in the app after the change and then on failure copy back from the low latency settings. That would only prevent nack-ing the update (on validation failure) through the frontend.
@@ -153,6 +153,8 @@ pub struct SerialSettingsPlatform<C, const Y: usize> { | |||
/// The storage mechanism used to persist settings to between boots. | |||
pub storage: Flash, | |||
|
|||
pub active_settings: C, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Meh. There are at least four places where we keep the setting now...
I'd rather have the poll call into serial settings return some sort of flag that the app then uses to push the settings. Or save that flag in the platform.
One key detail is to mention that the We likely don't want them to be the same thing either, or it may not be clear to the operator what is actually used during initialization. |
It makes sense to say:
This is exactly the cisco behavior AFAICT. In our case there are two sets of settings active in memory (i.e. in RAM): the low-latency settings for I think we can do this. It clears up a lot of potential confusion, simplifies the docs, and removes at least two copies of the settings. |
@jordens We previously decided against allowing the user to modify the currently-operating settings via USB because of complications with MQTT (see #822 (comment)), specifically around behavior with retained settings. I think any change in this direction requires a bit more design and analysis before we opt to go that route - I'm happy to look into it if you'd be interested in that behavior, but we should definitely flesh it out before jumping into an implementation. |
All ack! Let's have a look. |
You are right. I'm flip-flopping on this. I think the previous analysis was too strict and limiting and we can design something more feature-rich, more consistent, and imprive user experience. To tear apart the post that you quote:
Solved nicely by your design with the struct encapsulation/
I'd say no republishing. Does need explicit docs though. Setting individual settings over USB will likely be the use case when there is no network/MQTT connection. Copying active to initial settings is something that I can see others wanting to do as well. And precisely in this case there is no need to republish as they are the same.
Not applicable.
This is the case already now. We need to be clear that flash settings are initial settings and that In the spec above we probably would also decide that there is no way to access initial settings other than through copying active to initial. Offering a dump ( |
The rust ownership model complicates this approach.
As a result, there are the following problems we need to solve:
Given these problems, what likely makes the most sense is moving the |
Exactly. That was proposed in #862 (review) |
in support and exploration of quartiq/stabilizer#862
The above design discussion is implemented in #872 |
Closing this in favor of #872 |
This PR fixes #859 by adding a platform command to save the active running settings to flash.
Below is output during testing. CH0 is configured as a PID with Kp=2 via MQTT and then the
save-active
command was used to update the flash-based settings.