diff --git a/src/octoprint/comm/protocol/reprap/__init__.py b/src/octoprint/comm/protocol/reprap/__init__.py index 1cfc29e1f..86f7d75cb 100644 --- a/src/octoprint/comm/protocol/reprap/__init__.py +++ b/src/octoprint/comm/protocol/reprap/__init__.py @@ -130,9 +130,7 @@ class RepRapProtocol(Protocol): self._last_resend_request = None self._force_checksum = False - self._pingpong = False - self._rx_cache_fill = 0 - self._rx_cache_size = 127 + self._rx_cache_size = settings().getInt(["communication", "protocolOptions", "buffer"]) self._nack_lines = deque([]) self._nack_lock = threading.Lock() @@ -172,9 +170,7 @@ class RepRapProtocol(Protocol): self._resend_delta = None self._last_resend_request = None - self._force_checksum = self._useChecksum() - self._pingpong = self._usePingPong() - self._rx_cache_fill = 0 + self._force_checksum = settings().getBoolean(["feature", "alwaysSendChecksum"]) self._nack_lines.clear() self._current_line = 1 @@ -347,7 +343,6 @@ class RepRapProtocol(Protocol): if RepRapProtocol.MESSAGE_RESEND(message): # zero cache fill count with self._nack_lock: - self._rx_cache_fill = 0 self._nack_lines.clear() self._handle_resend_request(message) return @@ -369,7 +364,7 @@ class RepRapProtocol(Protocol): # lower cache fill count since the command went through with self._nack_lock: if len(self._nack_lines) > 0: - self._rx_cache_fill -= self._nack_lines.popleft() + self._nack_lines.popleft() self._clear_for_send.set() return @@ -466,7 +461,6 @@ class RepRapProtocol(Protocol): if self._state != State.OFFLINE: self._clear_for_send.set() - ##~~ private def _evaluate_firmware_specific_messages(self, source, message): @@ -637,9 +631,6 @@ class RepRapProtocol(Protocol): def _useChecksum(self): return settings().getBoolean(["feature", "alwaysSendChecksum"]) - def _usePingPong(self): - return settings().getBoolean(["feature", "pingPong"]) - ##~~ specific command actions def _gcode_T(self, command, with_checksum, with_line_number): @@ -712,10 +703,12 @@ class RepRapProtocol(Protocol): # queue is full, wait a bit before checking again if self._send_queue.qsize() > 20: time.sleep(0.05) - # -send_next only if printing (not SD) or streaming + + # send_next only if printing (not SD) or streaming elif ((self._state == State.PRINTING and not isinstance(self._current_file, PrintingSdFileInformation)) or self._state == State.STREAMING): self._send_next() + # not printing or streaming else: time.sleep(0.1) @@ -738,14 +731,13 @@ class RepRapProtocol(Protocol): size = len(preprocessed) + 1 # deassert _clear_for_send to wait for an "ok" if cache full self._nack_lock.acquire() - if self._rx_cache_fill + size > self._rx_cache_size: + if sum(self._nack_lines) + size > self._rx_cache_size > 0: self._nack_lock.release() self._clear_for_send.clear() self._clear_for_send.wait() continue # put tx size into the list so we can pop it later when we get "ok" self._nack_lines.append(size) - self._rx_cache_fill += size self._nack_lock.release() # send the command self._transport.send(preprocessed) @@ -754,7 +746,7 @@ class RepRapProtocol(Protocol): if command is not None: self._last_lines.append(command) - if self._pingpong == True: + if self._rx_cache_size <= 0: self._clear_for_send.clear() self._clear_for_send.wait() diff --git a/src/octoprint/server/api/settings.py b/src/octoprint/server/api/settings.py index 5ace60e41..63ed8eb08 100644 --- a/src/octoprint/server/api/settings.py +++ b/src/octoprint/server/api/settings.py @@ -66,7 +66,6 @@ def getSettings(): "temperatureGraph": s.getBoolean(["feature", "temperatureGraph"]), "waitForStart": s.getBoolean(["feature", "waitForStartOnConnect"]), "alwaysSendChecksum": s.getBoolean(["feature", "alwaysSendChecksum"]), - "pingPong": s.getBoolean(["feature", "pingPong"]), "sdSupport": s.getBoolean(["feature", "sdSupport"]), "sdAlwaysAvailable": s.getBoolean(["feature", "sdAlwaysAvailable"]), "swallowOkAfterResend": s.getBoolean(["feature", "swallowOkAfterResend"]), @@ -164,7 +163,6 @@ def setSettings(): if "temperatureGraph" in data["feature"].keys(): s.setBoolean(["feature", "temperatureGraph"], data["feature"]["temperatureGraph"]) if "waitForStart" in data["feature"].keys(): s.setBoolean(["feature", "waitForStartOnConnect"], data["feature"]["waitForStart"]) if "alwaysSendChecksum" in data["feature"].keys(): s.setBoolean(["feature", "alwaysSendChecksum"], data["feature"]["alwaysSendChecksum"]) - if "pingPong" in data["feature"].keys(): s.setBoolean(["feature", "pingPong"], data["feature"]["pingPong"]) if "sdSupport" in data["feature"].keys(): s.setBoolean(["feature", "sdSupport"], data["feature"]["sdSupport"]) if "sdAlwaysAvailable" in data["feature"].keys(): s.setBoolean(["feature", "sdAlwaysAvailable"], data["feature"]["sdAlwaysAvailable"]) if "swallowOkAfterResend" in data["feature"].keys(): s.setBoolean(["feature", "swallowOkAfterResend"], data["feature"]["swallowOkAfterResend"]) diff --git a/src/octoprint/settings.py b/src/octoprint/settings.py index cc91c1128..ddca70319 100644 --- a/src/octoprint/settings.py +++ b/src/octoprint/settings.py @@ -25,7 +25,9 @@ def settings(init=False, configfile=None, basedir=None): default_settings = { "communication": { "protocol": "reprap", - "protocolOptions": {}, + "protocolOptions": { + "buffer": 0 + }, "transport": "serial", "transportOptions": { "port": None, @@ -100,7 +102,6 @@ default_settings = { "temperatureGraph": True, "waitForStartOnConnect": False, "alwaysSendChecksum": False, - "pingPong": False, "sdSupport": True, "sdAlwaysAvailable": False, "swallowOkAfterResend": True, diff --git a/src/octoprint/static/js/app/viewmodels/settings.js b/src/octoprint/static/js/app/viewmodels/settings.js index 7bbf3b697..54bd19e56 100644 --- a/src/octoprint/static/js/app/viewmodels/settings.js +++ b/src/octoprint/static/js/app/viewmodels/settings.js @@ -259,7 +259,6 @@ function SettingsViewModel(loginStateViewModel, usersViewModel) { self.feature_temperatureGraph(response.feature.temperatureGraph); self.feature_waitForStart(response.feature.waitForStart); self.feature_alwaysSendChecksum(response.feature.alwaysSendChecksum); - self.feature_pingPong(response.feature.pingPong); self.feature_sdSupport(response.feature.sdSupport); self.feature_sdAlwaysAvailable(response.feature.sdAlwaysAvailable); self.feature_swallowOkAfterResend(response.feature.swallowOkAfterResend); @@ -332,7 +331,6 @@ function SettingsViewModel(loginStateViewModel, usersViewModel) { "temperatureGraph": self.feature_temperatureGraph(), "waitForStart": self.feature_waitForStart(), "alwaysSendChecksum": self.feature_alwaysSendChecksum(), - "pingPong": self.feature_pingPong(), "sdSupport": self.feature_sdSupport(), "sdAlwaysAvailable": self.feature_sdAlwaysAvailable(), "swallowOkAfterResend": self.feature_swallowOkAfterResend(), diff --git a/src/octoprint/templates/settings.jinja2 b/src/octoprint/templates/settings.jinja2 index 43d782bdc..da80b057d 100644 --- a/src/octoprint/templates/settings.jinja2 +++ b/src/octoprint/templates/settings.jinja2 @@ -297,13 +297,6 @@ -