diff --git a/src/octoprint/server/api/settings.py b/src/octoprint/server/api/settings.py index 76f7ab60e..752018d64 100644 --- a/src/octoprint/server/api/settings.py +++ b/src/octoprint/server/api/settings.py @@ -186,6 +186,7 @@ def getSettings(): "firmwareDetection": s.getBoolean(["serial", "firmwareDetection"]), "blockWhileDwelling": s.getBoolean(["serial", "blockWhileDwelling"]), "useParityWorkaround": s.get(["serial", "useParityWorkaround"]), + "sanityCheckTools": s.getBoolean(["serial", "sanityCheckTools"]), "sendM112OnError": s.getBoolean(["serial", "sendM112OnError"]), "disableSdPrintingDetection": s.getBoolean(["serial", "disableSdPrintingDetection"]), "ackMax": s.getInt(["serial", "ackMax"]), @@ -485,6 +486,7 @@ def _saveSettings(data): value = data["serial"]["useParityWorkaround"] if value in ("always", "detect", "never"): s.set(["serial", "useParityWorkaround"], value) + if "sanityCheckTools" in data["serial"]: s.setBoolean(["serial", "sanityCheckTools"], data["serial"]["sanityCheckTools"]) if "sendM112OnError" in data["serial"]: s.setBoolean(["serial", "sendM112OnError"], data["serial"]["sendM112OnError"]) if "disableSdPrintingDetection" in data["serial"]: s.setBoolean(["serial", "disableSdPrintingDetection"], data["serial"]["disableSdPrintingDetection"]) if "ackMax" in data["serial"]: s.setInt(["serial", "ackMax"], data["serial"]["ackMax"]) diff --git a/src/octoprint/settings.py b/src/octoprint/settings.py index 26459fc77..c8a96b97e 100644 --- a/src/octoprint/settings.py +++ b/src/octoprint/settings.py @@ -155,6 +155,7 @@ default_settings = { "sendM112OnError": True, "disableSdPrintingDetection": False, "ackMax": 1, + "sanityCheckTools": True, "capabilities": { "autoreport_temp": True, diff --git a/src/octoprint/static/js/app/viewmodels/settings.js b/src/octoprint/static/js/app/viewmodels/settings.js index 68d2ca354..dbf0fd79b 100644 --- a/src/octoprint/static/js/app/viewmodels/settings.js +++ b/src/octoprint/static/js/app/viewmodels/settings.js @@ -195,6 +195,7 @@ $(function() { self.serial_firmwareDetection = ko.observable(undefined); self.serial_blockWhileDwelling = ko.observable(undefined); self.serial_useParityWorkaround = ko.observable(undefined); + self.serial_sanityCheckTools = ko.observable(undefined); self.serial_supportResendsWithoutOk = ko.observable(undefined); self.serial_logPositionOnPause = ko.observable(undefined); self.serial_logPositionOnCancel = ko.observable(undefined); diff --git a/src/octoprint/templates/dialogs/settings/serialconnection.jinja2 b/src/octoprint/templates/dialogs/settings/serialconnection.jinja2 index 978fe2074..0a45dc0ae 100644 --- a/src/octoprint/templates/dialogs/settings/serialconnection.jinja2 +++ b/src/octoprint/templates/dialogs/settings/serialconnection.jinja2 @@ -466,6 +466,15 @@ +
diff --git a/src/octoprint/util/comm.py b/src/octoprint/util/comm.py index ec1c4ed2b..1efa3372c 100644 --- a/src/octoprint/util/comm.py +++ b/src/octoprint/util/comm.py @@ -533,6 +533,7 @@ class MachineCom(object): self._blocked_commands = settings().get(["serial", "blockedCommands"]) self._pausing_commands = settings().get(["serial", "pausingCommands"]) self._emergency_commands = settings().get(["serial", "emergencyCommands"]) + self._sanity_check_tools = settings().getBoolean(["serial", "sanityCheckTools"]) self._ack_max = settings().getInt(["serial", "ackMax"]) self._clear_to_send = CountedEvent(name="comm.clear_to_send", minimum=None, maximum=self._ack_max) @@ -2045,13 +2046,18 @@ class MachineCom(object): invalid_tool = self._currentTool - # log to terminal and remember as invalid - self._log("T{} reported as invalid, reverting to T{}".format(invalid_tool, fallback_tool)) - self._knownInvalidTools.add(invalid_tool) + if self._sanity_check_tools: + # log to terminal and remember as invalid + self._log("T{} reported as invalid, reverting to T{}".format(invalid_tool, fallback_tool)) + self._knownInvalidTools.add(invalid_tool) - # we actually do send a T command here instead of just settings self._currentTool just in case - # we had any scripts or plugins modify stuff due to the prior tool change - self.sendCommand("T{}".format(fallback_tool), tags={"trigger:revert_invalid_tool",}) + # we actually do send a T command here instead of just settings self._currentTool just in case + # we had any scripts or plugins modify stuff due to the prior tool change + self.sendCommand("T{}".format(fallback_tool), tags={"trigger:revert_invalid_tool",}) + else: + # just log to terminal, user disabled sanity check + self._log("T{} reported as invalid by the firmware, but you've " + "disabled tool sanity checking, ignoring".format(invalid_tool)) ##~~ SD Card handling elif 'SD init fail' in line or 'volume.init failed' in line or 'openRoot failed' in line: @@ -3847,7 +3853,9 @@ class MachineCom(object): return None, def _validate_tool(self, tool): - return tool < self._printerProfileManager.get_current_or_default()["extruder"]["count"] and not tool in self._knownInvalidTools + return not self._sanity_check_tools \ + or (tool < self._printerProfileManager.get_current_or_default()["extruder"]["count"] + and not tool in self._knownInvalidTools) def _reset_position_timers(self): if self._cancel_position_timer: