From e689a2c73344969ccac490ac1a701486a81a645a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Mon, 24 Aug 2015 13:40:00 +0200 Subject: [PATCH] Handle Repetier resend repetitions Repetier might resend the same resend request to make sure it arrives. This commit makes OctoPrint not react to such a repeated request and instead ignore up to a configurable amount of repeated requests for the same (current) line. (cherry picked from commit 6f83695) --- src/octoprint/settings.py | 5 ++++- src/octoprint/util/comm.py | 11 +++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/octoprint/settings.py b/src/octoprint/settings.py index a21b7f85..c6f5f6dc 100644 --- a/src/octoprint/settings.py +++ b/src/octoprint/settings.py @@ -83,7 +83,9 @@ default_settings = { "sdStatus": 1 }, "additionalPorts": [], - "longRunningCommands": ["G4", "G28", "G29", "G30", "G32"] + "longRunningCommands": ["G4", "G28", "G29", "G30", "G32"], + "ignoreIdenticalResends": False, + "identicalResendsCountdown": 7 }, "server": { "host": "0.0.0.0", @@ -271,6 +273,7 @@ default_settings = { }, "hasBed": True, "repetierStyleTargetTemperature": False, + "repetierStyleResends": False, "okBeforeCommandOutput": False, "smoothieTemperatureReporting": False, "extendedSdFileList": False, diff --git a/src/octoprint/util/comm.py b/src/octoprint/util/comm.py index 8fdcf655..883fe58a 100644 --- a/src/octoprint/util/comm.py +++ b/src/octoprint/util/comm.py @@ -238,6 +238,8 @@ class MachineCom(object): self._lastResendNumber = None self._currentResendCount = 0 self._resendSwallowNextOk = False + self._resendSwallowRepetitions = settings().getBoolean(["serial", "ignoreIdenticalResends"]) + self._resendSwallowRepetitionsCounter = 0 self._clear_to_send = CountedEvent(max=10, name="comm.clear_to_send") self._send_queue = TypedQueue() @@ -1422,9 +1424,18 @@ class MachineCom(object): self._currentResendCount += 1 return + # If we ignore resend repetitions (Repetier firmware...), check if we + # need to do this now. If the same line number has been requested we + # already saw and resent, we'll ignore it up to times. + if self._resendSwallowRepetitions and lineToResend == self._lastResendNumber and self._resendSwallowRepetitionsCounter > 0: + self._logger.debug("Ignoring resend request for line %d, that is probably a repetition sent by the firmware to ensure it arrives, not a real request" % lineToResend) + self._resendSwallowRepetitionsCounter -= 1 + return + self._resendDelta = resendDelta self._lastResendNumber = lineToResend self._currentResendCount = 0 + self._resendSwallowRepetitionsCounter = settings().getInt(["serial", "identicalResendsCountdown"]) if self._resendDelta > len(self._lastLines) or len(self._lastLines) == 0 or self._resendDelta < 0: self._errorValue = "Printer requested line %d but no sufficient history is available, can't resend" % lineToResend