Auto-recover a hung preamp on persistent I2C write failures#1098
Open
stamateviorel wants to merge 1 commit into
Open
Auto-recover a hung preamp on persistent I2C write failures#1098stamateviorel wants to merge 1 commit into
stamateviorel wants to merge 1 commit into
Conversation
When the preamp microcontroller hangs it stops ACKing and every I2C write fails with OSError 121 (EREMOTEIO). The existing fallback only reopens the SMBus handle, which recovers a transient bus glitch but not a hung preamp - zone control stays dead until someone power-cycles the unit. Escalate: when the reopened-bus retry also fails, reset the preamps in place, re-assign I2C addresses, reopen the bus and re-flush all cached register values so zone state (mute/source/volume) survives, then retry the write. Rate-limited to once per 20s so a benign one-off glitch never resets audio. Observed live on our unit 2026-06-04 (zone control dead until manual reboot); with this patch the same wedge self-heals in under a second. Signed-off-by: Stamate Viorel <stamate.viorel@gmail.com> Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.
What does this change intend to accomplish?
When the preamp microcontroller hangs it stops ACKing and every I2C write fails with
OSError 121(EREMOTEIO). The existing fallback in_Preamps.write_byte_dataonly reopens the SMBus handle, which recovers a transient bus glitch but not a hung preamp — zone control stays dead until someone power-cycles the unit. This escalates the fallback: when the reopened-bus retry also fails, reset the preamps in place, re-assign I2C addresses, reopen the bus, re-flush all cached register values (so zone mute/source/volume state survives the reset), then retry the write. Rate-limited to once per 20 s so a benign one-off glitch never resets audio.We hit this live on 2026-06-04 (all zone control dead, reads OK / writes failing with Errno 121, only a reboot helped). With this patch deployed the same wedge self-heals in under a second.
Checklist
python -m py_compileclean; happy to fix anything CI flags)