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