☔ Send M112 on disconnect due to error (configurable)
Try to disable heaters and such. Might fail, but worth a try at least. Only do that if we are not SD printing though.
This commit is contained in:
1 parent
81342acccc
commit
68ee7030f1
5 files changed
+18
-3
No files matched your search
@@ -174,6 +174,7 @@ def getSettings():
|
||||
"firmwareDetection": s.getBoolean(["serial", "firmwareDetection"]),
|
||||
"blockWhileDwelling": s.getBoolean(["serial", "blockWhileDwelling"]),
|
||||
"useParityWorkaround": s.get(["serial", "useParityWorkaround"]),
|
||||
"sendM112OnError": s.getBoolean(["serial", "sendM112OnError"]),
|
||||
"maxTimeoutsIdle": s.getInt(["serial", "maxCommunicationTimeouts", "idle"]),
|
||||
"maxTimeoutsPrinting": s.getInt(["serial", "maxCommunicationTimeouts", "printing"]),
|
||||
"maxTimeoutsLong": s.getInt(["serial", "maxCommunicationTimeouts", "long"]),
|
||||
@@ -466,6 +467,7 @@ def _saveSettings(data):
|
||||
value = data["serial"]["useParityWorkaround"]
|
||||
if value in ("always", "detect", "never"):
|
||||
s.set(["serial", "useParityWorkaround"], value)
|
||||
if "sendM112OnError" in data["serial"]: s.setBoolean(["serial", "sendM112OnError"], data["serial"]["sendM112OnError"])
|
||||
if "logPositionOnPause" in data["serial"]: s.setBoolean(["serial", "logPositionOnPause"], data["serial"]["logPositionOnPause"])
|
||||
if "logPositionOnCancel" in data["serial"]: s.setBoolean(["serial", "logPositionOnCancel"], data["serial"]["logPositionOnCancel"])
|
||||
if "abortHeatupOnCancel" in data["serial"]: s.setBoolean(["serial", "abortHeatupOnCancel"], data["serial"]["abortHeatupOnCancel"])
|
||||
|
||||
@@ -146,6 +146,7 @@ default_settings = {
|
||||
"blockWhileDwelling": False,
|
||||
"useParityWorkaround": "detect",
|
||||
"maxConsecutiveResends": 10,
|
||||
"sendM112OnError": True,
|
||||
|
||||
"capabilities": {
|
||||
"autoreport_temp": True,
|
||||
|
||||
@@ -198,6 +198,7 @@ $(function() {
|
||||
self.serial_capAutoreportSdStatus = ko.observable(undefined);
|
||||
self.serial_capBusyProtocol = ko.observable(undefined);
|
||||
self.serial_capEmergencyParser = ko.observable(undefined);
|
||||
self.serial_sendM112OnError = ko.observable(undefined);
|
||||
|
||||
self.folder_uploads = ko.observable(undefined);
|
||||
self.folder_timelapse = ko.observable(undefined);
|
||||
|
||||
@@ -421,6 +421,12 @@
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="controls">
|
||||
<label class="checkbox">
|
||||
<input type="checkbox" data-bind="checked: serial_sendM112OnError" id="settings-serialSendM112OnError"> {{ _('Send <code>M112</code> on disconnect due to error') }}
|
||||
<span class="help-block">{{ _('If this is checked, OctoPrint will try to send an <code>M112</code> prior to a disconnect due to a (fatal) error in order to disable heaters and motors.') }}</span>
|
||||
</label>
|
||||
</div>
|
||||
</fieldset>
|
||||
<fieldset>
|
||||
<legend>{{ _('Pausing') }}</legend>
|
||||
|
||||
@@ -2768,6 +2768,8 @@ class MachineCom(object):
|
||||
self._changeState(self.STATE_ERROR)
|
||||
eventManager().fire(Events.ERROR, {"error": self.getErrorString(), "reason": reason})
|
||||
if close:
|
||||
if settings().getBoolean(["serial", "sendM112OnError"]) and not self.isSdPrinting():
|
||||
self._gcode_M112_queuing("M112", close=False)
|
||||
self.close(is_error=True)
|
||||
|
||||
def _readline(self):
|
||||
@@ -3718,9 +3720,12 @@ class MachineCom(object):
|
||||
self._do_increment_and_send_with_checksum("M140 S0")
|
||||
|
||||
# close to reset host state
|
||||
self._errorValue = "Closing serial port due to emergency stop M112."
|
||||
self._log(self._errorValue)
|
||||
self.close(is_error=True)
|
||||
error_text = "Closing serial port due to emergency stop M112."
|
||||
self._log(error_text)
|
||||
|
||||
if kwargs.get("close", True):
|
||||
self._errorValue = error_text
|
||||
self.close(is_error=True)
|
||||
|
||||
# fire the M112 event since we sent it and we're going to prevent the caller from seeing it
|
||||
gcode = "M112"
|
||||
|
||||
Reference in new issue
Block a user