Repository navigation
Conversation
…e AMS tray for it The MQTT loop matched tray tags against a spool list cached on first use and never refreshed, so a spool tagged in SpoolMan later was reported as unknown until the cache happened to reload. For an unknown tag it also sent ams_filament_setting with blank values on every status report, discarding the filament data the printer had read from the spool's RFID tag (drndos#95). - Refetch the spool list on a cache miss, at most once a minute. - For an unknown Bambu tag, clear only the SpoolMan assignment, once per tray and tag, as the web UI already does; never reset the tray on the printer. - Give fetchSpoolList a 10 s timeout, and leave a tray as is when SpoolMan can't be read instead of treating its tag as unknown. - Read the tray UUID before the lookup, so a Bambu spool counts as one even when SpoolMan has no spools yet.
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.
Should address #95.
The MQTT loop matches tray tags against
fetchSpools(cached=True), which is filled once and only refreshed when a web route runs. A spool tagged in SpoolMan after that is reported as "Not found. Update spool tag!", and for an unknown tag the loop sendsams_filament_settingwith blank values on every status report. That command discards the filament data the printer just read from the spool's RFID tag, which matches #95: a new Bambu spool is identified, then reverts to "?" until OpenSpoolMan knows its tag.Seen on an X1C (firmware 01.12.00.00, cloud mode, v0.3.0): spools were added through the SpoolMan API while OpenSpoolMan was running, the cache filled mid-import, and three tagged trays were reported as unknown, so their usage went untracked and each got the reset on every report (222 in 10 minutes). This printer refuses it in cloud mode (
mqtt message verify failed), so only tracking was affected here. Opening the web UI or restarting fixed the matching.spools_with_tag(): on a cache miss, refetch from SpoolMan, at most once per 60 s (TAG_REFETCH_INTERVAL_S).ams_filament_setting. The web UI's_augment_trayalready handles an unmapped tag this way.fetchSpoolList()gets a 10 s timeout (SPOOLMAN_TIMEOUT_S); without one, a SpoolMan that accepts but never answers stalls the MQTT thread, and the refetch adds a path into it. If the lookup fails, the tray is left as is for that report rather than treated as unknown, and the other trays in the report are still processed.Not tested on a printer that accepts the reset (LAN-only + Developer mode), so #95 is addressed by reasoning from the report, not reproduced.
Tests:
tests/test_tray_tag_matching.py(7 cases). On the old code, the stale-cache, no-reset, failed-refetch and timeout cases fail (no match; 5 resets for 5 reports; later trays skipped; no timeout); the interval case fails if the refetch only ever runs once. Full suite: 28 passed, 2 skipped; flake8 gate as in CI passes.