Jelajahi Sumber

catch table not connected error

Tuan Nguyen 11 bulan lalu
induk
melakukan
6f4792a4dc
1 mengubah file dengan 8 tambahan dan 5 penghapusan
  1. 8 5
      modules/connection/connection_manager.py

+ 8 - 5
modules/connection/connection_manager.py

@@ -357,12 +357,15 @@ def get_machine_position(timeout=5):
     logger.warning("Timeout reached waiting for machine position")
     return None, None
 
-def update_machine_position():     
+def update_machine_position():
     if (state.conn.is_connected() if state.conn else False):
-        logger.info('Saving machine position')
-        state.machine_x, state.machine_y = get_machine_position()
-        state.save()
-        logger.info(f'Machine position saved: {state.machine_x}, {state.machine_y}')
+        try:
+            logger.info('Saving machine position')
+            state.machine_x, state.machine_y = get_machine_position()
+            state.save()
+            logger.info(f'Machine position saved: {state.machine_x}, {state.machine_y}')
+        except Exception as e:
+            logger.error(f"Error updating machine position: {e}")
     
 def restart_connection(homing=False):
     """