Added setting to only cancel ongoing print on firmware error
Also added error popup in such a case so the error will be known even if the terminal tab scrolled past it.
This commit is contained in:
parent
0e817d43cc
commit
6583691e85
6 changed files with 44 additions and 8 deletions
|
|
@ -86,7 +86,8 @@ def getSettings():
|
|||
"log": s.getBoolean(["serial", "log"]),
|
||||
"additionalPorts": s.get(["serial", "additionalPorts"]),
|
||||
"longRunningCommands": s.get(["serial", "longRunningCommands"]),
|
||||
"ignoreErrorsFromFirmware": s.getBoolean(["serial", "ignoreErrorsFromFirmware"])
|
||||
"ignoreErrorsFromFirmware": s.getBoolean(["serial", "ignoreErrorsFromFirmware"]),
|
||||
"disconnectOnErrors": s.getBoolean(["serial", "disconnectOnErrors"]),
|
||||
},
|
||||
"folder": {
|
||||
"uploads": s.getBaseFolder("uploads"),
|
||||
|
|
@ -228,6 +229,7 @@ def setSettings():
|
|||
if "additionalPorts" in data["serial"] and isinstance(data["serial"]["additionalPorts"], (list, tuple)): s.set(["serial", "additionalPorts"], data["serial"]["additionalPorts"])
|
||||
if "longRunningCommands" in data["serial"] and isinstance(data["serial"]["longRunningCommands"], (list, tuple)): s.set(["serial", "longRunningCommands"], data["serial"]["longRunningCommands"])
|
||||
if "ignoreErrorsFromFirmware" in data["serial"]: s.setBoolean(["serial", "ignoreErrorsFromFirmware"], data["serial"]["ignoreErrorsFromFirmware"])
|
||||
if "disconnectOnErrors" in data["serial"]: s.setBoolean(["serial", "disconnectOnErrors"], data["serial"]["disconnectOnErrors"])
|
||||
|
||||
oldLog = s.getBoolean(["serial", "log"])
|
||||
if "log" in data["serial"].keys(): s.setBoolean(["serial", "log"], data["serial"]["log"])
|
||||
|
|
|
|||
|
|
@ -86,6 +86,7 @@ default_settings = {
|
|||
},
|
||||
"additionalPorts": [],
|
||||
"longRunningCommands": ["G4", "G28", "G29", "G30", "G32"],
|
||||
"disconnectOnErrors": True,
|
||||
"ignoreErrorsFromFirmware": False
|
||||
},
|
||||
"server": {
|
||||
|
|
|
|||
|
|
@ -289,6 +289,22 @@ function DataUpdater(allViewModels) {
|
|||
text: _.sprintf(gettext("Streamed %(local)s to %(remote)s on SD, took %(time).2f seconds"), payload),
|
||||
type: "success"
|
||||
});
|
||||
} else if (type == "PrintCancelled") {
|
||||
if (payload.firmwareError) {
|
||||
new PNotify({
|
||||
title: gettext("Unhandled firmware error"),
|
||||
text: _.sprintf(gettext("The firmware reported an unhandled error. Due to that the ongoing print job was cancelled. Error: %(firmwareError)s"), payload),
|
||||
type: "error",
|
||||
hide: false
|
||||
});
|
||||
}
|
||||
} else if (type == "Error") {
|
||||
new PNotify({
|
||||
title: gettext("Unhandled firmware error"),
|
||||
text: _.sprintf(gettext("The firmware reported an unhandled error. Due to that OctoPrint disconnected. Error: %(error)s"), payload),
|
||||
type: "error",
|
||||
hide: false
|
||||
});
|
||||
}
|
||||
|
||||
var legacyEventHandlers = {
|
||||
|
|
|
|||
|
|
@ -137,6 +137,7 @@ $(function() {
|
|||
self.serial_additionalPorts = ko.observable(undefined);
|
||||
self.serial_longRunningCommands = ko.observable(undefined);
|
||||
self.serial_ignoreErrorsFromFirmware = ko.observable(undefined);
|
||||
self.serial_disconnectOnErrors = ko.observable(undefined);
|
||||
|
||||
self.folder_uploads = ko.observable(undefined);
|
||||
self.folder_timelapse = ko.observable(undefined);
|
||||
|
|
@ -452,6 +453,7 @@ $(function() {
|
|||
self.serial_additionalPorts(response.serial.additionalPorts.join("\n"));
|
||||
self.serial_longRunningCommands(response.serial.longRunningCommands.join(", "));
|
||||
self.serial_ignoreErrorsFromFirmware(response.serial.ignoreErrorsFromFirmware);
|
||||
self.serial_disconnectOnErrors(response.serial.disconnectOnErrors);
|
||||
|
||||
self.folder_uploads(response.folder.uploads);
|
||||
self.folder_timelapse(response.folder.timelapse);
|
||||
|
|
@ -539,7 +541,8 @@ $(function() {
|
|||
"log": self.serial_log(),
|
||||
"additionalPorts": commentableLinesToArray(self.serial_additionalPorts()),
|
||||
"longRunningCommands": splitTextToArray(self.serial_longRunningCommands(), ",", true),
|
||||
"ignoreErrorsFromFirmware": self.serial_ignoreErrorsFromFirmware()
|
||||
"ignoreErrorsFromFirmware": self.serial_ignoreErrorsFromFirmware(),
|
||||
"disconnectOnErrors": self.serial_disconnectOnErrors()
|
||||
},
|
||||
"folder": {
|
||||
"uploads": self.folder_uploads(),
|
||||
|
|
|
|||
|
|
@ -87,7 +87,14 @@
|
|||
<div class="control-group">
|
||||
<div class="controls">
|
||||
<label class="checkbox">
|
||||
<input type="checkbox" data-bind="checked: serial_ignoreErrorsFromFirmware" id="settings-ignoreErrorsFromFirmware"> {{ _('Ignore any errors from the firmware. Only use this if your firmware sends stuff prefixed with "Error" that is not an actual error. Might mask printer issues, be careful!') }} <span class="label label-important">{{ _('Warning') }}</span>
|
||||
<input type="checkbox" data-bind="checked: serial_disconnectOnErrors" id="settings-disconnectOnErrors"> {{ _('Not only cancel ongoing prints but also disconnect on unhandled errors from the firmware.') }}</span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<div class="controls">
|
||||
<label class="checkbox">
|
||||
<input type="checkbox" data-bind="checked: serial_ignoreErrorsFromFirmware" id="settings-ignoreErrorsFromFirmware"> {{ _('Ignore any unhandled errors from the firmware. Only use this if your firmware sends stuff prefixed with "Error" that is not an actual error. Might mask printer issues, be careful!') }} <span class="label label-important">{{ _('Warning') }}</span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -242,6 +242,7 @@ class MachineCom(object):
|
|||
self._resendSwallowRepetitions = settings().getBoolean(["feature", "ignoreIdenticalResends"])
|
||||
self._resendSwallowRepetitionsCounter = 0
|
||||
|
||||
self._disconnect_on_errors = settings().getBoolean(["serial", "disconnectOnErrors"])
|
||||
self._ignore_errors = settings().getBoolean(["serial", "ignoreErrorsFromFirmware"])
|
||||
|
||||
self._clear_to_send = CountedEvent(max=10, name="comm.clear_to_send")
|
||||
|
|
@ -649,7 +650,7 @@ class MachineCom(object):
|
|||
eventManager().fire(Events.FILE_DESELECTED)
|
||||
self._callback.on_comm_file_selected(None, None, False)
|
||||
|
||||
def cancelPrint(self):
|
||||
def cancelPrint(self, firmware_error=None):
|
||||
if not self.isOperational() or self.isStreaming():
|
||||
return
|
||||
|
||||
|
|
@ -667,7 +668,8 @@ class MachineCom(object):
|
|||
payload = {
|
||||
"file": self._currentFile.getFilename(),
|
||||
"filename": os.path.basename(self._currentFile.getFilename()),
|
||||
"origin": self._currentFile.getFileLocation()
|
||||
"origin": self._currentFile.getFileLocation(),
|
||||
"firmwareError": firmware_error
|
||||
}
|
||||
|
||||
self.sendGcodeScript("afterPrintCancelled", replacements=dict(event=payload))
|
||||
|
|
@ -1375,11 +1377,16 @@ class MachineCom(object):
|
|||
elif not self.isError():
|
||||
error_text = line[6:] if line.startswith("Error:") else line[2:]
|
||||
if not self._ignore_errors:
|
||||
self._errorValue = error_text
|
||||
self._changeState(self.STATE_ERROR)
|
||||
eventManager().fire(Events.ERROR, {"error": self.getErrorString()})
|
||||
if self._disconnect_on_errors:
|
||||
self._errorValue = error_text
|
||||
self._changeState(self.STATE_ERROR)
|
||||
eventManager().fire(Events.ERROR, {"error": self.getErrorString()})
|
||||
elif self.isPrinting():
|
||||
self.cancelPrint(firmware_error=error_text)
|
||||
self._clear_to_send.set()
|
||||
else:
|
||||
self._log("WARNING! Received an error from the printer's firmware, ignoring that as configured but you might want to investigate what happened here! Error: {}".format(error_text))
|
||||
self._clear_to_send.set()
|
||||
return line
|
||||
|
||||
def _readline(self):
|
||||
|
|
|
|||
Loading…
Reference in a new issue