diff --git a/octoprint_SMuFF/__init__.py b/octoprint_SMuFF/__init__.py index 2aad0b9..ddc5abd 100644 --- a/octoprint_SMuFF/__init__.py +++ b/octoprint_SMuFF/__init__.py @@ -23,6 +23,7 @@ import octoprint.plugin import logging +import re LOGGER = "octoprint.plugins.SMuFF" DEFAULT_BAUD = 115200 @@ -485,7 +486,7 @@ def extend_tool_sending(self, comm_instance, phase, cmd, cmd_type, gcode, subcod # @SMuFF FORCERESUME if action and action == FORCERESUME: if self._printer.is_pausing(): - self._log.debug("SMuFF load-state: {0}").format(instance.loadState) + self._log.debug("SMuFF load-state: {0}".format(instance.loadState)) instance.stop_tc_timer() # send the default OctoPrint "After Tool Change" script to the printer self._printer.script("afterToolChange") @@ -580,6 +581,10 @@ def extend_tool_sending(self, comm_instance, phase, cmd, cmd_type, gcode, subcod autoload = self._settings.get_boolean(["autoload"]) # send a tool change command to SMuFF res = instance.send_SMuFF_and_wait(str(instance.pendingTool) + (smuff_core.AUTOLOAD if autoload else "")) + # make sure there's no garbage in the received string - filter for 'Tx' only, ignore the rest + match = re.search(r'^T\d+', res) + if match != None: + res = match[0] # do we have the tool requested now? if str(res) == str(instance.pendingTool): instance.set_tool() diff --git a/octoprint_SMuFF/smuff_core.py b/octoprint_SMuFF/smuff_core.py index f63b236..2335e24 100644 --- a/octoprint_SMuFF/smuff_core.py +++ b/octoprint_SMuFF/smuff_core.py @@ -944,7 +944,17 @@ def _parse_serial_data(self, data): # don't process any general debug messages index = len(R_ECHO)+1 if data[index:].startswith(R_DEBUG): - self._log.debug("SMuFF has sent a debug response: [{0}]".format(data.rstrip())) + err = "SMuFF has sent a debug response: [{0}]".format(data.rstrip()) + self._log.debug(err) + # filter out ESC sequences + match = re.sub(r'\033\[\d+m', '', err) + if match != None: + err = match + if self._isKlipper: + self.gcode.respond_info(err) + else: + if not self._responseCB == None: + self._responseCB(err) # but do process the tool/endstop states elif data[index:].startswith(R_STATES): self._parse_states(data.rstrip()) diff --git a/setup.py b/setup.py index 5aa5858..ed0115c 100644 --- a/setup.py +++ b/setup.py @@ -14,7 +14,7 @@ plugin_name = "SMuFF Plugin" # The plugin's version. Can be overwritten within OctoPrint's internal data via __plugin_version__ in the plugin module -plugin_version = "1.2.3" +plugin_version = "1.2.4" # The plugin's description. Can be overwritten within OctoPrint's internal data via __plugin_description__ in the plugin # module