From c8875fd0f143e412e14a800e3b2f357f2bce51a8 Mon Sep 17 00:00:00 2001 From: Bryan Mayland Date: Thu, 20 Jun 2013 11:41:10 -0400 Subject: [PATCH] Resend correct gcode line when resend is requested --- octoprint/util/comm.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/octoprint/util/comm.py b/octoprint/util/comm.py index 5a7a1be..e61d045 100644 --- a/octoprint/util/comm.py +++ b/octoprint/util/comm.py @@ -779,7 +779,7 @@ 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) @@ -834,13 +834,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): @@ -1232,4 +1232,4 @@ class PrintingGcodeFileInformation(PrintingFileInformation): return None class StreamingGcodeFileInformation(PrintingGcodeFileInformation): - pass \ No newline at end of file + pass