Fix partial status updates breaking state info - #180
Open
Aptimex wants to merge 1 commit into
Open
Conversation
Author
|
Fixes #181 |
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.
Description
After any command that changes AMS state (e.g.
set_filament_printer),ams_hub()stops returning AMS data and never recovers on its own. On an A1 the hub becomes unavailable ~2.5s after a write and was still unavailable 30s later. The write itself succeeds, only the library's view of the printer breaks. This is caused by incrementalpush_statusupdates (that the printer publishes) being handled like full updates, causing some state data to be lost in the cache.This PR fixes that by deeply merging most of the info from status updates over the cached data, rather than replacing top-level keys. This is only done for dict objects, so it's not a perfect solution, but is significantly better. Other objects like lists can't be trivially merged correctly and are still just overwritten if a new one is present.
Also added two tests to verify the corrected behavior.
Printer
(probably applies to all printers with an AMS, but only tested on A1+AMS Lite)
Firmware Version
A1 v01.04.00.00
AMS Lite v00.00.07.94
Type of change