Skip to content

Commit

Permalink
gcode: Fixup M117/M118 command identification in cmd_default()
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
KevinOConnor committed Dec 1, 2024
1 parent d45b9c9 commit 03068b4
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions klippy/gcode.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,10 @@ def get_command_parameters(self):
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:
Expand Down Expand Up @@ -287,12 +286,15 @@ def cmd_default(self, gcmd):
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
Expand Down

0 comments on commit 03068b4

Please sign in to comment.