aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2024-11-26 19:17:59 -0500
committerKevin O'Connor <kevin@koconnor.net>2024-12-01 14:16:13 -0500
commit03068b48fedf460768a9d117cff90e0e39470687 (patch)
treee7fecb69540f9c3d2481e9f44da8ae7b1eaa9ec2
parentd45b9c92d8711592aeca5af65ff50a2fcfe55f2b (diff)
downloadkutter-03068b48fedf460768a9d117cff90e0e39470687.tar.gz
kutter-03068b48fedf460768a9d117cff90e0e39470687.tar.xz
kutter-03068b48fedf460768a9d117cff90e0e39470687.zip
gcode: Fixup M117/M118 command identification in cmd_default()
Alter gcmd._command in cmd_default if the special M117/M118 handling is detected. This avoids having to recheck for this condition in get_raw_command_parameters(). Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
-rw-r--r--klippy/gcode.py16
1 files changed, 9 insertions, 7 deletions
diff --git a/klippy/gcode.py b/klippy/gcode.py
index dc110261..748e0ebf 100644
--- a/klippy/gcode.py
+++ b/klippy/gcode.py
@@ -28,11 +28,10 @@ class GCodeCommand:
return self._params
def get_raw_command_parameters(self):
command = self._command
- if command.startswith("M117 ") or command.startswith("M118 "):
- command = command[:4]
rawparams = self._commandline
urawparams = rawparams.upper()
if not urawparams.startswith(command):
+ # Skip any gcode line-number and ignore any trailing checksum
rawparams = rawparams[urawparams.find(command):]
end = rawparams.rfind('*')
if end >= 0:
@@ -287,12 +286,15 @@ class GCodeDispatch:
if cmdline:
logging.debug(cmdline)
return
- if cmd.startswith("M117 ") or cmd.startswith("M118 "):
+ if ' ' in cmd:
# Handle M117/M118 gcode with numeric and special characters
- handler = self.gcode_handlers.get(cmd[:4], None)
- if handler is not None:
- handler(gcmd)
- return
+ realcmd = cmd.split()[0]
+ if realcmd in ["M117", "M118"]:
+ handler = self.gcode_handlers.get(realcmd, None)
+ if handler is not None:
+ gcmd._command = realcmd
+ handler(gcmd)
+ return
elif cmd in ['M140', 'M104'] and not gcmd.get_float('S', 0.):
# Don't warn about requests to turn off heaters when not present
return