Repository navigation
feat(mcu): support Kalico non-critical MCU reconnection - #474
Merged
Merged
Conversation
Jomik
force-pushed
the
feat/idempotent-initialize
branch
2 times, most recently
from
April 25, 2026 19:54
43c09a0 to
a264bd8
Compare
Jomik
force-pushed
the
feat/idempotent-initialize
branch
from
April 25, 2026 20:03
a264bd8 to
fe4827d
Compare
Klippy log with minimal logging:
|
When the Cartographer MCU is configured as is_non_critical=true on Kalico and is currently disconnected, sending any cartographer_* command raised klippy.serialhdl.error, which klippy treats as an internal error and shuts down the printer. Pre-check mcu.non_critical_disconnected before each command send and raise RuntimeError instead. The integrator's _catch_macro_errors wrapper converts RuntimeError to gcmd.error, producing a clean user-facing message without shutdown. The check is a no-op on stock Klipper (attribute does not exist; getattr default is False).
Jomik
force-pushed
the
feat/idempotent-initialize
branch
from
April 26, 2026 09:30
b18833d to
63752c8
Compare
|
i've also updated the code in KalicoCrew/kalico#870
Also did 2 regular prints after the reconnect which were fine too |
Move the non_critical_disconnected check from KlipperCartographerCommands into the KlipperCartographerMcu.commands property getter. Single guard site at the property boundary; every command access naturally short- circuits without per-call _check_connected() calls. Rename 'Mcu not initialized' to 'Cartographer MCU not initialized' for consistency with the disconnect message and to identify which MCU is affected when multiple are configured.
|
Today I got "Unhandled exception during run" when my Cartographer disconnected mid-print, with plugin version 1.8.0. Seems like the issue is still present. |
your issue is likely not the plugin but Kalico itself. |
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
Adds support for Kalico's non-critical MCU reconnection lifecycle. When a Cartographer MCU configured as
is_non_criticaldisconnects and reconnects at runtime, the plugin now re-initializes firmware constants, re-lookups commands, and re-validates/reloads models — without leaking resources or accumulating stale callbacks.This builds on #472 (graceful startup when disconnected) to complete the reconnection story.
Fixes #473
Decisions & callouts
_initializeis now idempotent:KlipperCartographerConstantsandKlipperCartographerCommandsare constructed once (guarded byis None), but theirinitialize()methods are called on every_initializeto re-read firmware values and re-lookup commands.getattrdetection forget_non_critical_reconnect_event_name/get_non_critical_disconnect_event_name. Both must be present for handlers to register — this matches Kalico's API where both are always provided together.try/exceptto prevent a failing callback from breaking Kalico's reconnection flow._register_data_response()is called on every_initialize. This is safe because Klipper'sregister_serial_responsereplaces existing handlers rather than accumulating them.Testing
Install this branch for testing:
is_non_critical = true, disconnect and reconnect the Cartographer MCU — plugin should re-initialize and resume normal operationKnown issue
If the Cartographer MCU is disconnected, Klipper firmware is restarted, and then the MCU is plugged back in, Kalico's reactor crashes with
Failed automated reset of MCU 'cartographer'raised fromnon_critical_recon_event. This is a Kalico-side bug — the timer callback atklippy/mcu.py::non_critical_recon_eventdoes not catch theerrorraised byrecon_mcu()/_connect(), so it escapes toprinter.runand shuts klippy down. Tracked upstream as KalicoCrew/kalico#870.The reverse order (disconnect → reconnect, no FW restart in between) works correctly with this PR.