From 5406b2bab17b6904502b7a224f6bdda1c911d923 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Thu, 27 Aug 2015 16:27:26 +0200 Subject: [PATCH] Improved M112 handling Use new synchronized sending method and also make sure that heaters will get disabled in case M112 is NOT understood by the firmware before disconnecting. That's about all we can do for now. --- src/octoprint/util/comm.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/octoprint/util/comm.py b/src/octoprint/util/comm.py index ed62acab..0ed8a471 100644 --- a/src/octoprint/util/comm.py +++ b/src/octoprint/util/comm.py @@ -1840,7 +1840,16 @@ class MachineCom(object): def _gcode_M112_queuing(self, cmd, cmd_type=None): # emergency stop, jump the queue with the M112 self._doSendWithoutChecksum("M112") - self._doSendWithChecksum("M112", self._currentLine) + self._doIncrementAndSendWithChecksum("M112") + + # No idea if the printer is still listening or if M112 won. Just in case + # we'll now try to also manually make sure all heaters are shut off - better + # safe than sorry. We do this ignoring the queue since at this point it + # is irrelevant whether the printer has sent enough ack's or not, we + # are going to shutdown the connection in a second anyhow. + for tool in range(self._printerProfileManager.get_current_or_default()["extruder"]["count"]): + self._doIncrementAndSendWithChecksum("M104 T{tool} S0".format(tool=tool)) + self._doIncrementAndSendWithChecksum("M140 S0") # close to reset host state self._errorValue = "Closing serial port due to emergency stop M112."