Przeglądaj źródła

Update machine position after homing completes

The async position update in check_idle() was silently failing because
the event loop was already closed. Now uses synchronous get_machine_position()
to query hardware and save state after successful homing.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
tuanchris 3 tygodni temu
rodzic
commit
314360968e
1 zmienionych plików z 13 dodań i 0 usunięć
  1. 13 0
      modules/connection/connection_manager.py

+ 13 - 0
modules/connection/connection_manager.py

@@ -743,6 +743,19 @@ def home(timeout=90):
 
                 logger.info("Crash homing completed - theta=0, rho=0")
 
+            # Update machine position from hardware after homing
+            logger.info("Updating machine position after homing...")
+            try:
+                pos = get_machine_position()
+                if pos and pos[0] is not None and pos[1] is not None:
+                    state.machine_x, state.machine_y = pos
+                    state.save()
+                    logger.info(f"Machine position updated after homing: X={state.machine_x}, Y={state.machine_y}")
+                else:
+                    logger.warning("Could not get machine position after homing")
+            except Exception as e:
+                logger.error(f"Error updating machine position after homing: {e}")
+
             homing_success = True
             homing_complete.set()