♻️ Make emergency codes configurable

This commit is contained in:
Gina Häußge committed 2019-05-07 15:09:41 +02:00
1 parent e1e521300b
commit 1c9ff91bae
5 files changed
+18 -6

No files matched your search

+2
View File
@@ -152,6 +152,7 @@ def getSettings():
"checksumRequiringCommands": s.get(["serial", "checksumRequiringCommands"]),
"blockedCommands": s.get(["serial", "blockedCommands"]),
"pausingCommands": s.get(["serial", "pausingCommands"]),
"emergencyCommands": s.get(["serial", "emergencyCommands"]),
"helloCommand": s.get(["serial", "helloCommand"]),
"ignoreErrorsFromFirmware": s.getBoolean(["serial", "ignoreErrorsFromFirmware"]),
"disconnectOnErrors": s.getBoolean(["serial", "disconnectOnErrors"]),
@@ -438,6 +439,7 @@ def _saveSettings(data):
if "checksumRequiringCommands" in data["serial"] and isinstance(data["serial"]["checksumRequiringCommands"], (list, tuple)): s.set(["serial", "checksumRequiringCommands"], data["serial"]["checksumRequiringCommands"])
if "blockedCommands" in data["serial"] and isinstance(data["serial"]["blockedCommands"], (list, tuple)): s.set(["serial", "blockedCommands"], data["serial"]["blockedCommands"])
if "pausingCommands" in data["serial"] and isinstance(data["serial"]["pausingCommands"], (list, tuple)): s.set(["serial", "pausingCommands"], data["serial"]["pausingCommands"])
if "emergencyCommands" in data["serial"] and isinstance(data["serial"]["emergencyCommands"], (list, tuple)): s.set(["serial", "emergencyCommands"], data["serial"]["emergencyCommands"])
if "helloCommand" in data["serial"]: s.set(["serial", "helloCommand"], data["serial"]["helloCommand"])
if "ignoreErrorsFromFirmware" in data["serial"]: s.setBoolean(["serial", "ignoreErrorsFromFirmware"], data["serial"]["ignoreErrorsFromFirmware"])
if "disconnectOnErrors" in data["serial"]: s.setBoolean(["serial", "disconnectOnErrors"], data["serial"]["disconnectOnErrors"])
+1
View File
@@ -116,6 +116,7 @@ default_settings = {
"longRunningCommands": ["G4", "G28", "G29", "G30", "G32", "M400", "M226", "M600"],
"blockedCommands": ["M0", "M1"],
"pausingCommands": ["M0", "M1", "M25"],
"emergencyCommands": ["M112", "M108", "M410"],
"checksumRequiringCommands": ["M110"],
"helloCommand": "M110 N0",
"disconnectOnErrors": True,
@@ -171,6 +171,7 @@ $(function() {
self.serial_checksumRequiringCommands = ko.observable(undefined);
self.serial_blockedCommands = ko.observable(undefined);
self.serial_pausingCommands = ko.observable(undefined);
self.serial_emergencyCommands = ko.observable(undefined);
self.serial_helloCommand = ko.observable(undefined);
self.serial_serialErrorBehaviour = ko.observable("cancel");
self.serial_triggerOkForM29 = ko.observable(undefined);
@@ -781,6 +782,7 @@ $(function() {
checksumRequiringCommands: function() { return splitTextToArray(self.serial_checksumRequiringCommands(), ",", true) },
blockedCommands: function() { return splitTextToArray(self.serial_blockedCommands(), ",", true) },
pausingCommands: function() { return splitTextToArray(self.serial_pausingCommands(), ",", true) },
emergencyCommands: function() {return splitTextToArray(self.serial_emergencyCommands(), ",", true) },
externalHeatupDetection: function() { return !self.serial_disableExternalHeatupDetection()},
alwaysSendChecksum: function() { return self.serial_sendChecksum() === "always"},
neverSendChecksum: function() { return self.serial_sendChecksum() === "never"},
@@ -920,6 +922,7 @@ $(function() {
checksumRequiringCommands: function(value) { self.serial_checksumRequiringCommands(value.join(", "))},
blockedCommands: function(value) { self.serial_blockedCommands(value.join(", "))},
pausingCommands: function(value) { self.serial_pausingCommands(value.join(", "))},
emergencyCommands: function(value) { self.serial_emergencyCommands(value.join(", "))},
externalHeatupDetection: function(value) { self.serial_disableExternalHeatupDetection(!value) },
alwaysSendChecksum: function(value) { if (value) { self.serial_sendChecksum("always")}},
neverSendChecksum: function(value) { if (value) { self.serial_sendChecksum("never")}},
@@ -352,6 +352,12 @@
<span class="help-inline">{{ _('Use this to specify commands on which OctoPrint should pause the print job. Just the G or M code, comma separated. Defaults to <code>M0</code>, <code>M1</code> and <code>M25</code>.') }}</span>
</div>
</div>
<div class="control-group">
<label class="control-label" for="settings-serialEmergencyCommands">{{ _('Emergency commands') }}</label>
<div class="controls">
<input type="text" class="input-block-level" id="settings-serialEmergencyCommands" data-bind="value: serial_emergencyCommands">
<span class="help-inline">{{ _('Use this to specify emergency commands which should jump any queues and - if supported by the firmware - be force sent. Just the G or M code, comma separated. Defaults to <code>M112</code>, <code>M118</code> and <code>M410</code>.') }}</span> </div>
</div>
<div>
<div><small><a href="#" class="muted" data-bind="toggleContent: { class: 'fa-caret-right fa-caret-down', container: '#settings_serial_protocol_finetuning .hide' }"><i class="fa fa-caret-right"></i> {{ _('Advanced options') }}</a></small></div>
<div class="hide">
+6 -6
View File
@@ -503,6 +503,7 @@ class MachineCom(object):
self._checksum_requiring_commands = settings().get(["serial", "checksumRequiringCommands"])
self._blocked_commands = settings().get(["serial", "blockedCommands"])
self._pausing_commands = settings().get(["serial", "pausingCommands"])
self._emergency_commands = settings().get(["serial", "emergencyCommands"])
self._clear_to_send = CountedEvent(name="comm.clear_to_send", minimum=None)
self._send_queue = SendQueue()
@@ -3660,12 +3661,6 @@ class MachineCom(object):
# I hope it got it the first time because as far as I can tell, there is no way to know
return None,
def _gcode_M108_queuing(self, cmd, gcode=None, *args, **kwargs):
return self._emergency_force_send(cmd, u"Force-sending M108 to the printer", gcode=gcode, *args, **kwargs)
def _gcode_M410_queuing(self, cmd, gcode=None, *args, **kwargs):
return self._emergency_force_send(cmd, u"Force-sending M410 to the printer", gcode=gcode, *args, **kwargs)
def _gcode_M114_queued(self, *args, **kwargs):
self._reset_position_timers()
_gcode_M114_sent = _gcode_M114_queued
@@ -3732,6 +3727,11 @@ class MachineCom(object):
def _command_phase_queuing(self, cmd, cmd_type=None, gcode=None, subcode=None, *args, **kwargs):
if gcode is not None:
if gcode in self._emergency_commands and gcode != "M112":
msg = u"Force-sending {} to the printer".format(gcode)
self._logger.info(msg)
return self._emergency_force_send(cmd, msg, gcode=gcode, *args, **kwargs)
if self.isPrinting() and gcode in self._pausing_commands:
self._logger.info("Pausing print job due to command {}".format(gcode))
self.setPause(True)