diff --git a/src/octoprint/server/api/settings.py b/src/octoprint/server/api/settings.py
index 2c5e79df1..84cd7497a 100644
--- a/src/octoprint/server/api/settings.py
+++ b/src/octoprint/server/api/settings.py
@@ -176,6 +176,7 @@ def getSettings():
"blockWhileDwelling": s.getBoolean(["serial", "blockWhileDwelling"]),
"useParityWorkaround": s.get(["serial", "useParityWorkaround"]),
"sendM112OnError": s.getBoolean(["serial", "sendM112OnError"]),
+ "ackMax": s.getInt(["serial", "ackMax"]),
"maxTimeoutsIdle": s.getInt(["serial", "maxCommunicationTimeouts", "idle"]),
"maxTimeoutsPrinting": s.getInt(["serial", "maxCommunicationTimeouts", "printing"]),
"maxTimeoutsLong": s.getInt(["serial", "maxCommunicationTimeouts", "long"]),
@@ -471,6 +472,7 @@ def _saveSettings(data):
if value in ("always", "detect", "never"):
s.set(["serial", "useParityWorkaround"], value)
if "sendM112OnError" in data["serial"]: s.setBoolean(["serial", "sendM112OnError"], data["serial"]["sendM112OnError"])
+ if "ackMax" in data["serial"]: s.setInt(["serial", "ackMax"], data["serial"]["ackMax"])
if "logPositionOnPause" in data["serial"]: s.setBoolean(["serial", "logPositionOnPause"], data["serial"]["logPositionOnPause"])
if "logPositionOnCancel" in data["serial"]: s.setBoolean(["serial", "logPositionOnCancel"], data["serial"]["logPositionOnCancel"])
if "abortHeatupOnCancel" in data["serial"]: s.setBoolean(["serial", "abortHeatupOnCancel"], data["serial"]["abortHeatupOnCancel"])
diff --git a/src/octoprint/settings.py b/src/octoprint/settings.py
index 1d9a87b20..1dcdcd830 100644
--- a/src/octoprint/settings.py
+++ b/src/octoprint/settings.py
@@ -147,6 +147,7 @@ default_settings = {
"useParityWorkaround": "detect",
"maxConsecutiveResends": 10,
"sendM112OnError": True,
+ "ackMax": 1,
"capabilities": {
"autoreport_temp": True,
diff --git a/src/octoprint/static/js/app/viewmodels/settings.js b/src/octoprint/static/js/app/viewmodels/settings.js
index c90fa42c3..6b2c22262 100644
--- a/src/octoprint/static/js/app/viewmodels/settings.js
+++ b/src/octoprint/static/js/app/viewmodels/settings.js
@@ -200,6 +200,7 @@ $(function() {
self.serial_capBusyProtocol = ko.observable(undefined);
self.serial_capEmergencyParser = ko.observable(undefined);
self.serial_sendM112OnError = ko.observable(undefined);
+ self.serial_ackMax = ko.observable(undefined);
self.folder_uploads = ko.observable(undefined);
self.folder_timelapse = ko.observable(undefined);
diff --git a/src/octoprint/templates/dialogs/settings/serialconnection.jinja2 b/src/octoprint/templates/dialogs/settings/serialconnection.jinja2
index 2b5d1dffe..03c8af4b6 100644
--- a/src/octoprint/templates/dialogs/settings/serialconnection.jinja2
+++ b/src/octoprint/templates/dialogs/settings/serialconnection.jinja2
@@ -398,6 +398,13 @@
{{ _('Use this to specify which commands always need to be sent with a checksum. Comma separated list.') }}
+
+
+
+
+ {{ _('Only modify if told to do so') }}
+
+
diff --git a/src/octoprint/util/comm.py b/src/octoprint/util/comm.py
index 4c4991fd7..80196735c 100644
--- a/src/octoprint/util/comm.py
+++ b/src/octoprint/util/comm.py
@@ -512,7 +512,8 @@ class MachineCom(object):
self._pausing_commands = settings().get(["serial", "pausingCommands"])
self._emergency_commands = settings().get(["serial", "emergencyCommands"])
- self._clear_to_send = CountedEvent(name="comm.clear_to_send", minimum=None)
+ self._ack_max = settings().getInt(["serial", "ackMax"])
+ self._clear_to_send = CountedEvent(name="comm.clear_to_send", minimum=None, maximum=self._ack_max)
self._send_queue = SendQueue()
self._temperature_timer = None
self._sd_status_timer = None
@@ -3143,6 +3144,19 @@ class MachineCom(object):
self._logger.debug("Type already in send queue: " + e.type)
return False
+ def _use_up_clear(self, gcode):
+ # we only need to use up a clear if the command we just sent was either a gcode command or if we also
+ # require ack's for unknown commands
+ eats_clear = self._unknownCommandsNeedAck
+ if gcode is not None:
+ eats_clear = True
+
+ if eats_clear:
+ # if we need to use up a clear, do that now
+ self._clear_to_send.clear()
+
+ return eats_clear
+
def _send_loop(self):
"""
The send loop is responsible of sending commands in ``self._send_queue`` over the line, if it is cleared for
@@ -3189,6 +3203,7 @@ class MachineCom(object):
if linenumber is not None:
# line number predetermined - this only happens for resends, so we'll use the number and
# send directly without any processing (since that already took place on the first sending!)
+ self._use_up_clear(gcode)
self._do_send_with_checksum(command, linenumber)
else:
@@ -3239,7 +3254,13 @@ class MachineCom(object):
continue
# now comes the part where we increase line numbers and send stuff - no turning back now
+ used_up_clear = self._use_up_clear(gcode)
self._do_send(command, gcode=gcode)
+ if not used_up_clear:
+ # If we didn't use up a clear we need to tickle the read queue - there might
+ # not be a reply to this command, so our _monitor loop will stay waiting until
+ # timeout. We definitely do not want that, so we tickle the queue manually here
+ self._continue_sending()
# trigger "sent" phase and use up one "ok"
if on_sent is not None and callable(on_sent):
@@ -3247,21 +3268,6 @@ class MachineCom(object):
on_sent()
self._process_command_phase("sent", command, command_type, gcode=gcode, subcode=subcode, tags=tags)
- # we only need to use up a clear if the command we just sent was either a gcode command or if we also
- # require ack's for unknown commands
- use_up_clear = self._unknownCommandsNeedAck
- if gcode is not None:
- use_up_clear = True
-
- if use_up_clear:
- # if we need to use up a clear, do that now
- self._clear_to_send.clear()
- else:
- # Otherwise we need to tickle the read queue - there might not be a reply
- # to this command, so our _monitor loop will stay waiting until timeout. We
- # definitely do not want that, so we tickle the queue manually here
- self._continue_sending()
-
finally:
# no matter _how_ we exit this block, we signal that we
# are done processing the last fetched queue entry
@@ -3788,10 +3794,12 @@ class MachineCom(object):
return
self._logger.info(message)
- self._do_send(cmd, gcode=gcode)
# use up an ok since we will get one back for this command and don't want to get out of sync
- self._clear_to_send.clear()
+ used_up_clear = self._use_up_clear(gcode)
+ self._do_send(cmd, gcode=gcode)
+ if not used_up_clear:
+ self._continue_sending()
return None,