Made communication mode more error resilient

master
Bryan Mayland 2013-06-20 17:41:10 +02:00 committed by Gina Häußge
parent 8b702db0d0
commit 50914df07a
1 changed files with 202 additions and 194 deletions

View File

@ -581,6 +581,7 @@ class MachineCom(object):
startSeen = not settings().getBoolean(["feature", "waitForStartOnConnect"]) startSeen = not settings().getBoolean(["feature", "waitForStartOnConnect"])
heatingUp = False heatingUp = False
while True: while True:
try:
line = self._readline() line = self._readline()
if line == None: if line == None:
break break
@ -795,6 +796,13 @@ class MachineCom(object):
self._sendNext() self._sendNext()
elif "resend" in line.lower() or "rs" in line: elif "resend" in line.lower() or "rs" in line:
self._handleResendRequest(line) self._handleResendRequest(line)
except:
self._logger.exception("Something crashed inside the serial connection loop, please report this in OctoPrint's bug tracker:")
errorMsg = "Please see octoprint.log for details"
self._log(errorMsg)
self._errorValue = errorMsg
self._changeState(self.STATE_ERROR)
self._log("Connection closed, closing down monitor") self._log("Connection closed, closing down monitor")
def _handleResendRequest(self, line): def _handleResendRequest(self, line):
@ -849,7 +857,7 @@ class MachineCom(object):
return ret return ret
def close(self, isError = False): def close(self, isError = False):
if self._serial != None: if self._serial is not None:
self._serial.close() self._serial.close()
if isError: if isError:
self._changeState(self.STATE_CLOSED_WITH_ERROR) self._changeState(self.STATE_CLOSED_WITH_ERROR)