From ca7e30aa05f0c8a645e15026cc5dc411e9df7c15 Mon Sep 17 00:00:00 2001 From: Henrik Muehe Date: Sun, 3 May 2026 13:13:29 +0200 Subject: [PATCH] Mach.home: end the homing cycle when external homing fails When ext.home() raised, Mach.home logged the error but never reset the cycle from 'homing' back to 'idle'. The AVR had not moved (the homing was external), so its state stayed at READY without a transition - meaning _update's normal 'state changed to READY -> exit cycle' path never fired and the UI was permanently locked out of every action that requires is_idle (jog buttons, the home button itself, run, etc). Wrap the external-homing block in try/except and force the cycle back to idle on any failure. The success path is unchanged - it still relies on the AVR's queued set_axis + G92 acks to bring the state back to READY. --- src/py/bbctrl/Mach.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/py/bbctrl/Mach.py b/src/py/bbctrl/Mach.py index 4628dc4..ef99ccf 100644 --- a/src/py/bbctrl/Mach.py +++ b/src/py/bbctrl/Mach.py @@ -359,8 +359,10 @@ class Mach(Comm): continue self.mlog.info('Homing external %s axis via auxcnc' % axis.upper()) + cycle_started = False try: self._begin_cycle('homing') + cycle_started = True ext.home() home_mm = ext.home_position_mm # 1) Update AVR: no motor steps, just position sync. @@ -377,6 +379,19 @@ class Mach(Comm): except Exception as e: self.mlog.error( 'External axis homing failed: %s' % e) + # Make sure we clean up the cycle so the UI does + # not stay locked out of jog/home/start. The AVR + # never moved during external homing, so its + # state never changes back to READY (which is + # what _update normally relies on to exit the + # cycle). Drop straight to idle. + if cycle_started and self._get_cycle() == 'homing': + try: + self._set_cycle('idle') + except Exception: + self.mlog.exception( + 'Failed to reset cycle to idle ' + 'after external homing error') continue # If this is not a request to home a specific axis and the