Made communication mode more error resilient
parent
8b702db0d0
commit
50914df07a
|
@ -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)
|
||||||
|
@ -867,7 +875,7 @@ class MachineCom(object):
|
||||||
# Make sure we are only handling one sending job at a time
|
# Make sure we are only handling one sending job at a time
|
||||||
with self._sendingLock:
|
with self._sendingLock:
|
||||||
self._logger.debug("Resending line %d, delta is %d, history log is %s items strong" % (self._currentLine - self._resendDelta, self._resendDelta, len(self._lastLines)))
|
self._logger.debug("Resending line %d, delta is %d, history log is %s items strong" % (self._currentLine - self._resendDelta, self._resendDelta, len(self._lastLines)))
|
||||||
cmd = self._lastLines[-(self._resendDelta+1)]
|
cmd = self._lastLines[-(self._resendDelta + 1)]
|
||||||
lineNumber = self._currentLine - self._resendDelta
|
lineNumber = self._currentLine - self._resendDelta
|
||||||
|
|
||||||
self._doSendWithChecksum(cmd, lineNumber)
|
self._doSendWithChecksum(cmd, lineNumber)
|
||||||
|
|
Loading…
Reference in New Issue