From 9299cb54a4830367e10e4ef5a04b2479aaacde5e 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. (cherry picked from commit 5406b2b) --- 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 c1999167..8a67f87c 100644 --- a/src/octoprint/util/comm.py +++ b/src/octoprint/util/comm.py @@ -1766,7 +1766,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."