From e15956883a5839c3895b5a561c75bb90b6677458 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Fri, 14 Oct 2016 18:19:08 +0200 Subject: [PATCH] Add support for R parameter in M109/M190 --- src/octoprint/util/comm.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/octoprint/util/comm.py b/src/octoprint/util/comm.py index e5ccd98f..9f3b123e 100644 --- a/src/octoprint/util/comm.py +++ b/src/octoprint/util/comm.py @@ -48,6 +48,7 @@ regex_float = re.compile(regex_float_pattern) regexes_parameters = dict( floatP=re.compile("(^|[^A-Za-z])[Pp](?P%s)" % regex_float_pattern), + floatR=re.compile("(^|[^A-Za-z])[Ss](?P%s)" % regex_float_pattern), floatS=re.compile("(^|[^A-Za-z])[Ss](?P%s)" % regex_float_pattern), floatZ=re.compile("(^|[^A-Za-z])[Zz](?P%s)" % regex_float_pattern), intN=re.compile("(^|[^A-Za-z])[Nn](?P%s)" % regex_int_pattern), @@ -2121,7 +2122,7 @@ class MachineCom(object): return None, # Don't send bed commands if we don't have a heated bed _gcode_M190_queuing = _gcode_M140_queuing - def _gcode_M104_sent(self, cmd, cmd_type=None, wait=False): + def _gcode_M104_sent(self, cmd, cmd_type=None, wait=False, support_r=False): toolNum = self._currentTool toolMatch = regexes_parameters["intT"].search(cmd) @@ -2133,6 +2134,9 @@ class MachineCom(object): self._currentTool = toolNum match = regexes_parameters["floatS"].search(cmd) + if not match and support_r: + match = regexes_parameters["floatR"].search(cmd) + if match: try: target = float(match.group("value")) @@ -2145,8 +2149,11 @@ class MachineCom(object): except ValueError: pass - def _gcode_M140_sent(self, cmd, cmd_type=None, wait=False): + def _gcode_M140_sent(self, cmd, cmd_type=None, wait=False, support_r=False): match = regexes_parameters["floatS"].search(cmd) + if not match and support_r: + match = regexes_parameters["floatR"].search(cmd) + if match: try: target = float(match.group("value")) @@ -2163,13 +2170,13 @@ class MachineCom(object): self._heatupWaitStartTime = time.time() self._long_running_command = True self._heating = True - self._gcode_M104_sent(cmd, cmd_type, wait=True) + self._gcode_M104_sent(cmd, cmd_type, wait=True, support_r=True) def _gcode_M190_sent(self, cmd, cmd_type=None): self._heatupWaitStartTime = time.time() self._long_running_command = True self._heating = True - self._gcode_M140_sent(cmd, cmd_type, wait=True) + self._gcode_M140_sent(cmd, cmd_type, wait=True, support_r=True) def _gcode_M110_sending(self, cmd, cmd_type=None): newLineNumber = None