From bbad030a9227db6ca2df42d393c38fb4db6817a4 Mon Sep 17 00:00:00 2001 From: Bryan Mayland Date: Thu, 20 Jun 2013 17:41:10 +0200 Subject: [PATCH] Resend correct gcode line when resend is requested (manually cherry picked from commit c8875fd) --- octoprint/util/comm.py | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/octoprint/util/comm.py b/octoprint/util/comm.py index c846e930..74296f5d 100644 --- a/octoprint/util/comm.py +++ b/octoprint/util/comm.py @@ -40,7 +40,13 @@ def serialList(): i+=1 except: pass - baselist = baselist + glob.glob("/dev/ttyUSB*") + glob.glob("/dev/ttyACM*") + glob.glob("/dev/tty.usb*") + glob.glob("/dev/cu.*") + glob.glob("/dev/rfcomm*") + baselist = baselist \ + + glob.glob("/dev/ttyUSB*") \ + + glob.glob("/dev/ttyACM*") \ + + glob.glob("/dev/ttyAMA*") \ + + glob.glob("/dev/tty.usb*") \ + + glob.glob("/dev/cu.*") \ + + glob.glob("/dev/rfcomm*") prev = settings().get(["serial", "port"]) if prev in baselist: baselist.remove(prev) @@ -766,10 +772,11 @@ class MachineCom(object): if lineToResend is not None: self._resendDelta = self._currentLine - lineToResend - if self._resendDelta > len(self._lastLines): + if self._resendDelta >= len(self._lastLines): self._errorValue = "Printer requested line %d but history is only available up to line %d" % (lineToResend, self._currentLine - len(self._lastLines)) - self._changeState(self.STATE_ERROR) self._logger.warn(self._errorValue) + if self.isPrinting(): + self._changeState(self.STATE_ERROR) else: self._resendNextCommand() @@ -821,13 +828,13 @@ class MachineCom(object): # Make sure we are only handling one sending job at a time 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))) - cmd = self._lastLines[-self._resendDelta] + cmd = self._lastLines[-(self._resendDelta+1)] lineNumber = self._currentLine - self._resendDelta self._doSendWithChecksum(cmd, lineNumber) self._resendDelta -= 1 - if self._resendDelta <= 0: + if self._resendDelta < 0: self._resendDelta = None def _sendCommand(self, cmd, sendChecksum=False):