Merge branch 'fix/positionLogTimeout' into maintenance
# Conflicts: # src/octoprint/util/comm.py
This commit is contained in:
commit
a9441400b3
5 files changed
+100
-21
No files matched your search
@@ -140,6 +140,7 @@ def getSettings():
|
||||
"timeoutSdStatus": s.getFloat(["serial", "timeout", "sdStatus"]),
|
||||
"timeoutSdStatusAutoreport": s.getFloat(["serial", "timeout", "sdStatusAutoreport"]),
|
||||
"timeoutBaudrateDetectionPause": s.getFloat(["serial", "timeout", "baudrateDetectionPause"]),
|
||||
"timeoutPositionLogWait": s.getFloat(["serial", "timeout", "positionLogWait"]),
|
||||
"log": s.getBoolean(["serial", "log"]),
|
||||
"additionalPorts": s.get(["serial", "additionalPorts"]),
|
||||
"additionalBaudrates": s.get(["serial", "additionalBaudrates"]),
|
||||
@@ -373,6 +374,7 @@ def _saveSettings(data):
|
||||
if "timeoutSdStatus" in data["serial"]: s.setFloat(["serial", "timeout", "sdStatus"], data["serial"]["timeoutSdStatus"])
|
||||
if "timeoutSdStatusAutoreport" in data["serial"]: s.setFloat(["serial", "timeout", "sdStatusAutoreport"], data["serial"]["timeoutSdStatusAutoreport"])
|
||||
if "timeoutBaudrateDetectionPause" in data["serial"]: s.setFloat(["serial", "timeout", "baudrateDetectionPause"], data["serial"]["timeoutBaudrateDetectionPause"])
|
||||
if "timeoutPositionLogWait" in data["serial"]: s.setFloat(["serial", "timeout", "positionLogWait"], data["serial"]["timeoutPositionLogWait"])
|
||||
if "additionalPorts" in data["serial"] and isinstance(data["serial"]["additionalPorts"], (list, tuple)): s.set(["serial", "additionalPorts"], data["serial"]["additionalPorts"])
|
||||
if "additionalBaudrates" in data["serial"] and isinstance(data["serial"]["additionalBaudrates"], (list, tuple)): s.set(["serial", "additionalBaudrates"], data["serial"]["additionalBaudrates"])
|
||||
if "longRunningCommands" in data["serial"] and isinstance(data["serial"]["longRunningCommands"], (list, tuple)): s.set(["serial", "longRunningCommands"], data["serial"]["longRunningCommands"])
|
||||
|
||||
@@ -101,7 +101,8 @@ default_settings = {
|
||||
"sdStatus": 1,
|
||||
"sdStatusAutoreport": 1,
|
||||
"resendOk": .5,
|
||||
"baudrateDetectionPause": 1.0
|
||||
"baudrateDetectionPause": 1.0,
|
||||
"positionLogWait": 10.0,
|
||||
},
|
||||
"maxCommunicationTimeouts": {
|
||||
"idle": 2,
|
||||
|
||||
@@ -159,6 +159,7 @@ $(function() {
|
||||
self.serial_timeoutSdStatus = ko.observable(undefined);
|
||||
self.serial_timeoutSdStatusAutoreport = ko.observable(undefined);
|
||||
self.serial_timeoutBaudrateDetectionPause = ko.observable(undefined);
|
||||
self.serial_timeoutPositionLogWait = ko.observable(undefined);
|
||||
self.serial_log = ko.observable(undefined);
|
||||
self.serial_additionalPorts = ko.observable(undefined);
|
||||
self.serial_additionalBaudrates = ko.observable(undefined);
|
||||
|
||||
@@ -143,6 +143,15 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group" title="{{ _('Time after which to consider a position query on pause or cancel to have failed') }}">
|
||||
<label class="control-label" for="settings-serialTimeoutPositionLogWait">{{ _('Position query timeout') }}</label>
|
||||
<div class="controls">
|
||||
<div class="input-append">
|
||||
<input type="number" step="any" min="0" class="input-mini text-right" data-bind="value: serial_timeoutPositionLogWait" id="settings-serialTimeoutPositionLogWait">
|
||||
<span class="add-on">s</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<div><small><a href="#" class="muted" data-bind="toggleContent: { class: 'fa-caret-right fa-caret-down', container: '#settings_serial_timeouts_timeouts .hide' }"><i class="fa fa-caret-right"></i> {{ _('Advanced options') }}</a></small></div>
|
||||
<div class="hide">
|
||||
|
||||
+86
-20
@@ -36,7 +36,7 @@ from octoprint.events import eventManager, Events
|
||||
from octoprint.filemanager import valid_file_type
|
||||
from octoprint.filemanager.destinations import FileDestinations
|
||||
from octoprint.util import get_exception_string, sanitize_ascii, filter_non_ascii, CountedEvent, RepeatedTimer, \
|
||||
to_unicode, bom_aware_open, TypedQueue, PrependableQueue, TypeAlreadyInQueue, chunks
|
||||
to_unicode, bom_aware_open, TypedQueue, PrependableQueue, TypeAlreadyInQueue, chunks, ResettableTimer
|
||||
|
||||
try:
|
||||
import _winreg
|
||||
@@ -514,6 +514,11 @@ class MachineCom(object):
|
||||
self._record_pause_data = False
|
||||
self._record_cancel_data = False
|
||||
|
||||
self._pause_position_timer = None
|
||||
self._pause_mutex = threading.RLock()
|
||||
self._cancel_position_timer = None
|
||||
self._cancel_mutex = threading.RLock()
|
||||
|
||||
self._log_position_on_pause = settings().getBoolean(["serial", "logPositionOnPause"])
|
||||
self._log_position_on_cancel = settings().getBoolean(["serial", "logPositionOnCancel"])
|
||||
|
||||
@@ -1090,14 +1095,26 @@ class MachineCom(object):
|
||||
self._currentFile = None
|
||||
self._callback.on_comm_file_selected(None, None, False)
|
||||
|
||||
def _cancel_preparation_done(self):
|
||||
self._recordFilePosition()
|
||||
self._callback.on_comm_print_job_cancelled()
|
||||
def _cancel_preparation_failed(self):
|
||||
timeout = self._timeout_intervals.get("positionLogWait", 10.0)
|
||||
self._log("Did not receive parseable position data from printer within {}s, continuing without it".format(timeout))
|
||||
self._cancel_preparation_done()
|
||||
|
||||
def finalize():
|
||||
self._changeState(self.STATE_OPERATIONAL)
|
||||
self.sendCommand(SendQueueMarker(finalize))
|
||||
self._continue_sending()
|
||||
def _cancel_preparation_done(self, check_timer=True):
|
||||
with self._cancel_mutex:
|
||||
if self._cancel_position_timer is not None:
|
||||
self._cancel_position_timer.cancel()
|
||||
self._cancel_position_timer = None
|
||||
elif check_timer:
|
||||
return
|
||||
|
||||
self._recordFilePosition()
|
||||
self._callback.on_comm_print_job_cancelled()
|
||||
|
||||
def finalize():
|
||||
self._changeState(self.STATE_OPERATIONAL)
|
||||
self.sendCommand(SendQueueMarker(finalize))
|
||||
self._continue_sending()
|
||||
|
||||
def cancelPrint(self, firmware_error=None, disable_log_position=False, tags=None, external_sd=False):
|
||||
if not self.isOperational():
|
||||
@@ -1120,7 +1137,16 @@ class MachineCom(object):
|
||||
# because we do this only after our M114 has been answered
|
||||
# by the firmware
|
||||
self._record_cancel_data = True
|
||||
self.sendCommand("M114", tags=tags | {"trigger:comm.cancel", "trigger:record_position"})
|
||||
|
||||
with self._cancel_mutex:
|
||||
if self._cancel_position_timer is not None:
|
||||
self._cancel_position_timer.cancel()
|
||||
self._cancel_position_timer = ResettableTimer(self._timeout_intervals.get("positionLogWait", 10.0),
|
||||
self._cancel_preparation_done)
|
||||
self._cancel_position_timer.daemon = True
|
||||
self._cancel_position_timer.start()
|
||||
self.sendCommand("M114", tags=tags | {"trigger:comm.cancel",
|
||||
"trigger:record_position"})
|
||||
|
||||
self._callback.on_comm_print_job_cancelling(firmware_error=firmware_error)
|
||||
|
||||
@@ -1139,18 +1165,33 @@ class MachineCom(object):
|
||||
pass
|
||||
|
||||
if self._log_position_on_cancel and not disable_log_position:
|
||||
self.sendCommand("M400", on_sent=_on_M400_sent, tags=tags | {"trigger:comm.cancel", "trigger:record_position"})
|
||||
self.sendCommand("M400",
|
||||
on_sent=_on_M400_sent,
|
||||
tags=tags | {"trigger:comm.cancel",
|
||||
"trigger:record_position"})
|
||||
self._continue_sending()
|
||||
else:
|
||||
self._cancel_preparation_done()
|
||||
self._cancel_preparation_done(check_timer=False)
|
||||
|
||||
def _pause_preparation_done(self):
|
||||
self._callback.on_comm_print_job_paused()
|
||||
def _pause_preparation_failed(self):
|
||||
timeout = self._timeout_intervals.get("positionLogWait", 10.0)
|
||||
self._log("Did not receive parseable position data from printer within {}s, continuing without it".format(timeout))
|
||||
self._pause_preparation_done()
|
||||
|
||||
def finalize():
|
||||
self._changeState(self.STATE_PAUSED)
|
||||
self.sendCommand(SendQueueMarker(finalize))
|
||||
self._continue_sending()
|
||||
def _pause_preparation_done(self, check_timer=True):
|
||||
with self._pause_mutex:
|
||||
if self._pause_position_timer is not None:
|
||||
self._pause_position_timer.cancel()
|
||||
self._pause_position_timer = None
|
||||
elif check_timer:
|
||||
return
|
||||
|
||||
self._callback.on_comm_print_job_paused()
|
||||
|
||||
def finalize():
|
||||
self._changeState(self.STATE_PAUSED)
|
||||
self.sendCommand(SendQueueMarker(finalize))
|
||||
self._continue_sending()
|
||||
|
||||
def setPause(self, pause, tags=None):
|
||||
if self.isStreaming():
|
||||
@@ -1202,13 +1243,28 @@ class MachineCom(object):
|
||||
# because we do this only after our M114 has been answered
|
||||
# by the firmware
|
||||
self._record_pause_data = True
|
||||
self.sendCommand("M114", tags=tags | {"trigger:comm.set_pause", "trigger:pause", "trigger:record_position"})
|
||||
|
||||
with self._pause_mutex:
|
||||
if self._pause_position_timer is not None:
|
||||
self._pause_position_timer.cancel()
|
||||
self._pause_position_timer = None
|
||||
self._pause_position_timer = ResettableTimer(self._timeout_intervals.get("positionLogWait", 10.0),
|
||||
self._pause_preparation_failed)
|
||||
self._pause_position_timer.daemon = True
|
||||
self._pause_position_timer.start()
|
||||
self.sendCommand("M114", tags=tags | {"trigger:comm.set_pause",
|
||||
"trigger:pause",
|
||||
"trigger:record_position"})
|
||||
|
||||
if self._log_position_on_pause:
|
||||
self.sendCommand("M400", on_sent=_on_M400_sent, tags=tags | {"trigger:comm.set_pause", "trigger:pause", "trigger:record_position"})
|
||||
self.sendCommand("M400",
|
||||
on_sent=_on_M400_sent,
|
||||
tags=tags | {"trigger:comm.set_pause",
|
||||
"trigger:pause",
|
||||
"trigger:record_position"})
|
||||
self._continue_sending()
|
||||
else:
|
||||
self._pause_preparation_done()
|
||||
self._pause_preparation_done(check_timer=False)
|
||||
|
||||
def getSdFiles(self):
|
||||
return self._sdFiles
|
||||
@@ -3238,6 +3294,10 @@ class MachineCom(object):
|
||||
# I hope it got it the first time because as far as I can tell, there is no way to know
|
||||
return None,
|
||||
|
||||
def _gcode_M114_queued(self, *args, **kwargs):
|
||||
self._reset_position_timers()
|
||||
_gcode_M114_sent = _gcode_M114_queued
|
||||
|
||||
def _gcode_G4_sent(self, cmd, cmd_type=None, gcode=None, subcode=None, *args, **kwargs):
|
||||
# we are intending to dwell for a period of time, increase the timeout to match
|
||||
p_match = regexes_parameters["floatP"].search(cmd)
|
||||
@@ -3255,6 +3315,12 @@ class MachineCom(object):
|
||||
def _validate_tool(self, tool):
|
||||
return tool < self._printerProfileManager.get_current_or_default()["extruder"]["count"] and not tool in self._knownInvalidTools
|
||||
|
||||
def _reset_position_timers(self):
|
||||
if self._cancel_position_timer:
|
||||
self._cancel_position_timer.reset()
|
||||
if self._pause_position_timer:
|
||||
self._pause_position_timer.reset()
|
||||
|
||||
## atcommands
|
||||
|
||||
def _atcommand_pause_queuing(self, command, parameters, tags=None, *args, **kwargs):
|
||||
|
||||
Reference in new issue
Block a user