diff --git a/src/py/bbctrl/AuxAxis.py b/src/py/bbctrl/AuxAxis.py index e3f8269..89dbcca 100644 --- a/src/py/bbctrl/AuxAxis.py +++ b/src/py/bbctrl/AuxAxis.py @@ -409,11 +409,28 @@ class AuxAxis(object): self._pos_steps = int(r.strip()) except Exception: pass + # Force the host to start unhomed regardless of what the ESP + # remembers from a prior session. The ESP's homed flag survives + # bbctrl restarts (since the ESP itself wasn't power-cycled), + # but the host's planner offsets and DRO position get reset to + # zero on bbctrl boot. Trusting the ESP's homed flag would mean + # the user thinks A is homed at the wrong work-coord origin + # (offset_a=0 but ESP physically at home_position_mm). Sending + # UNHOME forces the user to re-home explicitly, which sets up + # the offset and gplan state correctly via the homing path in + # Mach.home. try: - r = self._rpc('HOMED?', topic='homed', timeout=2.0) - self._homed = (r.strip() == '1') + self._rpc('UNHOME', topic='ok', timeout=2.0) + self._homed = False except Exception: - pass + # Fall back to whatever HOMED? says - but treat any + # missing UNHOME support as "trust ESP's flag" so we + # don't break older firmware. + try: + r = self._rpc('HOMED?', topic='homed', timeout=2.0) + self._homed = (r.strip() == '1') + except Exception: + pass self._publish_state() def _reader_loop(self): diff --git a/src/py/bbctrl/State.py b/src/py/bbctrl/State.py index 60be854..5fdcfbf 100644 --- a/src/py/bbctrl/State.py +++ b/src/py/bbctrl/State.py @@ -107,8 +107,14 @@ class State(object): def reset(self): - # Unhome all motors - for i in range(4): self.set('%dhomed' % i, False) + # Unhome all motors (real AVR motors 0..3 and the synthetic + # external-axis motor at index 4 used by ExternalAxis). + # Both homed and h are cleared - they're set + # by different code paths (gplan emits homed via __homed + # set blocks, AVR reports h directly). + for i in range(5): + self.set('%dhomed' % i, False) + self.set('%dh' % i, 0) # Zero offsets and positions for axis in 'xyzabc':