Selaa lähdekoodia

Add debug logging for GRBL response timeout investigation

- Remove time.sleep(0.01) to match main branch behavior
- Log unexpected GRBL responses (neither ok/error/alarm)
- Log waiting status every 30s during long waits

This helps diagnose why Pi 3B+ times out on feature branch but not main.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
tuanchris 1 viikko sitten
vanhempi
sitoutus
7e8284961a
1 muutettua tiedostoa jossa 6 lisäystä ja 2 poistoa
  1. 6 2
      modules/core/pattern_manager.py

+ 6 - 2
modules/core/pattern_manager.py

@@ -585,8 +585,12 @@ class MotionControlThread:
                             logger.error("Machine alarm triggered - stopping pattern")
                             state.stop_requested = True
                             return False
-                    # Small sleep to prevent CPU spin when readline() times out
-                    time.sleep(0.01)
+                        # Log unexpected responses that aren't ok/error/alarm
+                        logger.warning(f"Motion thread: Unexpected response (not ok/error/alarm): '{response}'")
+                    else:
+                        # Log periodically when waiting for response (every 30s)
+                        if int(elapsed) > 0 and int(elapsed) % 30 == 0 and elapsed - int(elapsed) < 0.1:
+                            logger.warning(f"Motion thread: Still waiting for 'ok' after {int(elapsed)}s for command: {gcode}")
 
             except Exception as e:
                 error_str = str(e)