Removed self._ping_pong (can be done by setting self._rx_cache_size to 0) and self._rx_cache_fill (can be done by sum(self._nack_lines)), made self._rx_cache_size configurable

This commit is contained in:
Gina Häußge committed 2014-10-31 18:51:54 +01:00
1 parent 41c6978880
commit 785ac07de9
5 files changed
+11 -29

No files matched your search

+8 -16
View File
@@ -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()
-2
View File
@@ -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"])
+3 -2
View File
@@ -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,
@@ -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(),
-7
View File
@@ -297,13 +297,6 @@
</label>
</div>
</div>
<div class="control-group">
<div class="controls">
<label class="checkbox">
<input type="checkbox" data-bind="checked: feature_pingPong" id="settings-featurePingPong"> {{ _('Use <strong>ping-pong</strong> communication (reconnect after changing)') }}
</label>
</div>
</div>
<div class="control-group">
<div class="controls">
<label class="checkbox">