From 1d602509429b6d806d3769f021cdbc86048d0c47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Wed, 30 Oct 2019 12:47:40 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Only=20detect=20sd=20printing=20?= =?UTF-8?q?on=20byte=20pos=20change?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Should fix #3301, or at least make it way less likely to happen. The problem seems to have been made worse by `M25` not being blocking on Klipper and thus the SD printing not being guaranteed to have stopped yet after its return, meaning the following `M26 S0` will be denied, causing the file position to not be properly reset and hence the issue to arise in the first place. --- src/octoprint/util/comm.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/octoprint/util/comm.py b/src/octoprint/util/comm.py index 401edc364..0f2200705 100644 --- a/src/octoprint/util/comm.py +++ b/src/octoprint/util/comm.py @@ -2053,7 +2053,12 @@ class MachineCom(object): else: self._consecutive_not_sd_printing = 0 if self.isSdFileSelected(): - if not self.isSdPrinting() and current != total and current > 0: + + # If we are not yet sd printing, the current does not equal the total, is larger + # than zero and has increased since the last time we saw a position report, then + # yes, this looks like we just started printing due to an external trigger. + if not self.isSdPrinting() and current != total and current > 0 \ + and self._currentFile and current > self._currentFile.pos: self.startPrint(external_sd=True) self._currentFile.pos = current @@ -2509,6 +2514,8 @@ class MachineCom(object): if self._busy_protocol_support: self._set_busy_protocol_interval() + self._consecutive_not_sd_printing = 0 + def _get_temperature_timer_interval(self): busy_default = 4.0 target_default = 2.0