From 517a32f08fdb676bb7b349681f3da2c8c058a2b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Mon, 4 May 2015 12:36:35 +0200 Subject: [PATCH] Less strict error parsing for detecting communication errors Instead of matching to full strings send by firmware in case of checksum or line number issues, now matches only against lower case "checksum", "line number" and "line expected". Should make it more resilient to firmware side changes of the sent messages. --- src/octoprint/util/comm.py | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/octoprint/util/comm.py b/src/octoprint/util/comm.py index e05809dc..f4b79703 100644 --- a/src/octoprint/util/comm.py +++ b/src/octoprint/util/comm.py @@ -1277,13 +1277,7 @@ class MachineCom(object): line = line.rstrip() + self._readline() #Skip the communication errors, as those get corrected. - if 'checksum mismatch' in line \ - or 'Wrong checksum' in line \ - or 'Line Number is not Last Line Number' in line \ - or 'expected line' in line \ - or 'No Line Number with checksum' in line \ - or 'No Checksum with line number' in line \ - or 'Missing checksum' in line: + if 'line number' in line.lower() or 'checksum' in line.lower() or 'expected line' in line.lower(): self._lastCommError = line[6:] if line.startswith("Error:") else line[2:] pass elif not self.isError(): @@ -1370,7 +1364,7 @@ class MachineCom(object): resendDelta = self._currentLine - lineToResend if lastCommError is not None \ - and ("line number is not line number" in lastCommError.lower() or "expected line" in lastCommError.lower()) \ + and ("line number" in lastCommError.lower() or "expected line" in lastCommError.lower()) \ and lineToResend == self._lastResendNumber \ and self._resendDelta is not None and self._currentResendCount < self._resendDelta: self._logger.debug("Ignoring resend request for line %d, that still originates from lines we sent before we got the first resend request" % lineToResend)