aboutsummaryrefslogtreecommitdiffstats
path: root/klippy
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2022-01-18 11:21:53 -0500
committerKevin O'Connor <kevin@koconnor.net>2022-01-18 11:34:40 -0500
commitf97fd7c6e392e376bd1552afdd39a2150d3e21d0 (patch)
tree23094c9cdfdf58d4faef21a5916d69c101e14310 /klippy
parent02d5f9754fc7f9e493c8bc5a6418e2a9ea9d7ae1 (diff)
downloadkutter-f97fd7c6e392e376bd1552afdd39a2150d3e21d0.tar.gz
kutter-f97fd7c6e392e376bd1552afdd39a2150d3e21d0.tar.xz
kutter-f97fd7c6e392e376bd1552afdd39a2150d3e21d0.zip
gcode: Handle M117 and M118 commands that start with a special character
Commit 7ef7bf60 broke the special handling for M117 commands that start with a number or special character. Fix that support and extend to M118 as well. Also improve handling of commands not separated by a space (eg, "M117HELLO"). Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Diffstat (limited to 'klippy')
-rw-r--r--klippy/gcode.py21
1 files changed, 10 insertions, 11 deletions
diff --git a/klippy/gcode.py b/klippy/gcode.py
index abd431d5..07e312f9 100644
--- a/klippy/gcode.py
+++ b/klippy/gcode.py
@@ -27,20 +27,19 @@ class GCodeCommand:
def get_command_parameters(self):
return self._params
def get_raw_command_parameters(self):
- rawparams = self._commandline
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):
- start = urawparams.find(command)
+ rawparams = rawparams[urawparams.find(command):]
end = rawparams.rfind('*')
if end >= 0:
rawparams = rawparams[:end]
- rawparams = rawparams[start:]
- commandlen = len(command) + 1
- if len(rawparams) > commandlen:
- rawparams = rawparams[commandlen:]
- else:
- rawparams = ''
+ rawparams = rawparams[len(command):]
+ if rawparams.startswith(' '):
+ rawparams = rawparams[1:]
return rawparams
def ack(self, msg=None):
if not self._need_ack:
@@ -277,9 +276,9 @@ class GCodeDispatch:
if cmdline:
logging.debug(cmdline)
return
- if cmd.startswith("M117 "):
- # Handle M117 gcode with numeric and special characters
- handler = self.gcode_handlers.get("M117", None)
+ if cmd.startswith("M117 ") or cmd.startswith("M118 "):
+ # 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