From bbbe85f737804b83fa771aeb595895dc73365a7c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Sat, 29 Sep 2018 14:38:54 +0200 Subject: [PATCH] Multiline fatal error parsing for Marlin --- src/octoprint/util/comm.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/octoprint/util/comm.py b/src/octoprint/util/comm.py index 9492b0e18..c8cd4a2ee 100644 --- a/src/octoprint/util/comm.py +++ b/src/octoprint/util/comm.py @@ -76,6 +76,9 @@ regexes_parameters = dict( regex_minMaxError = re.compile("Error:[0-9]\n") """Regex matching first line of min/max errors from the firmware.""" +regex_marlinKillError = re.compile("Heating failed|Thermal Runaway|MAXTEMP triggered|MINTEMP triggered|Invalid extruder number|Watchdog barked|KILL caused") +"""Regex matching first line of kill causing errors from Marlin.""" + regex_sdPrintingByte = re.compile("(?P[0-9]*)/(?P[0-9]*)") """Regex matching SD printing status reports. @@ -2507,8 +2510,7 @@ class MachineCom(object): "cannot open", "open failed", "cannot enter") - _fatal_errors = ("system stopped", - "kill() called", + _fatal_errors = ("kill() called", "fatal:") def _handle_errors(self, line): if line is None: @@ -2521,6 +2523,13 @@ class MachineCom(object): # special delivery for firmware that goes "Error:x\n: Extruder switched off. MAXTEMP triggered !\n" line = line.rstrip() + self._readline() lower_line = line.lower() + elif regex_marlinKillError.search(line): + # special delivery for marlin kill errors that are split across multiple error lines + next_line = self._readline().strip() + if next_line.lower().startswith("error:"): + next_line = next_line[6:].strip() + line = line.rstrip() + " - " + next_line + lower_line = line.lower() stripped_error = (line[6:] if lower_line.startswith("error:") else line[2:]).strip()