From 96c3ca160e881dbeef8ccbe80f804572b9170d8c Mon Sep 17 00:00:00 2001 From: Kevin O'Connor Date: Sat, 6 Sep 2025 14:06:25 -0400 Subject: [PATCH] gcode: Fix out-of-order check for M112 when read from gcode pseudo-tty Make sure to check for an out-of-order M112 command on the gcode pseudo-tty even if there is no pending commands being processed from that gcode pseudo-tty. There could be long running commands pending from webhooks, virtual_sdcard, or similar. Signed-off-by: Kevin O'Connor --- klippy/gcode.py | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/klippy/gcode.py b/klippy/gcode.py index 975da792..1c50695d 100644 --- a/klippy/gcode.py +++ b/klippy/gcode.py @@ -430,18 +430,17 @@ class GCodeIO: self.gcode.request_restart('exit') pending_commands.append("") # Handle case where multiple commands pending - if self.is_processing_data or len(pending_commands) > 1: - if len(pending_commands) < 20: - # Check for M112 out-of-order - for line in lines: - if self.m112_r.match(line) is not None: - self.gcode.cmd_M112(None) - if self.is_processing_data: - if len(pending_commands) >= 20: - # Stop reading input - self.reactor.unregister_fd(self.fd_handle) - self.fd_handle = None - return + if len(pending_commands) < 20: + # Check for M112 out-of-order + for line in lines: + if self.m112_r.match(line) is not None: + self.gcode.cmd_M112(None) + if self.is_processing_data: + if len(pending_commands) >= 20: + # Stop reading input + self.reactor.unregister_fd(self.fd_handle) + self.fd_handle = None + return # Process commands self.is_processing_data = True while pending_commands: