Support SD status autoreport
This commit is contained in:
1 parent
98c7ad0c20
commit
e6ec48b8a1
6 files changed
+74
-6
No files matched your search
@@ -126,9 +126,10 @@ class VirtualPrinter(object):
|
||||
|
||||
self._okFormatString = settings().get(["devel", "virtualPrinter", "okFormatString"])
|
||||
|
||||
self._capabilities = settings().get(["devel", "virtualPrinter", "capabilities"])
|
||||
self._capabilities = settings().get(["devel", "virtualPrinter", "capabilities"], merged=True)
|
||||
|
||||
self._temperature_reporter = None
|
||||
self._sdstatus_reporter = None
|
||||
|
||||
self.currentLine = 0
|
||||
self.lastN = 0
|
||||
@@ -414,8 +415,23 @@ class VirtualPrinter(object):
|
||||
self._setSdPos(pos)
|
||||
|
||||
def _gcode_M27(self, data):
|
||||
if self._sdCardReady:
|
||||
self._reportSdStatus()
|
||||
def report():
|
||||
if self._sdCardReady:
|
||||
self._reportSdStatus()
|
||||
|
||||
match = re.search("S([0-9]+)", data)
|
||||
if match:
|
||||
interval = int(match.group(1))
|
||||
if self._sdstatus_reporter is not None:
|
||||
self._sdstatus_reporter.cancel()
|
||||
|
||||
if interval > 0:
|
||||
self._sdstatus_reporter = RepeatedTimer(interval, report)
|
||||
self._sdstatus_reporter.start()
|
||||
else:
|
||||
self._sdstatus_reporter = None
|
||||
|
||||
report()
|
||||
|
||||
def _gcode_M28(self, data):
|
||||
if self._sdCardReady:
|
||||
|
||||
@@ -139,6 +139,7 @@ def getSettings():
|
||||
"timeoutTemperatureTargetSet": s.getFloat(["serial", "timeout", "temperatureTargetSet"]),
|
||||
"timeoutTemperatureAutoreport": s.getFloat(["serial", "timeout", "temperatureAutoreport"]),
|
||||
"timeoutSdStatus": s.getFloat(["serial", "timeout", "sdStatus"]),
|
||||
"timeoutSdStatusAutoreport": s.getFloat(["serial", "timeout", "sdStatusAutoreport"]),
|
||||
"log": s.getBoolean(["serial", "log"]),
|
||||
"additionalPorts": s.get(["serial", "additionalPorts"]),
|
||||
"additionalBaudrates": s.get(["serial", "additionalBaudrates"]),
|
||||
@@ -166,6 +167,7 @@ def getSettings():
|
||||
"maxTimeoutsPrinting": s.getInt(["serial", "maxCommunicationTimeouts", "printing"]),
|
||||
"maxTimeoutsLong": s.getInt(["serial", "maxCommunicationTimeouts", "long"]),
|
||||
"capAutoreportTemp": s.getBoolean(["serial", "capabilities", "autoreport_temp"]),
|
||||
"capAutoreportSdStatus": s.getBoolean(["serial", "capabilities", "autoreport_sdstatus"]),
|
||||
"capBusyProtocol": s.getBoolean(["serial", "capabilities", "busy_protocol"])
|
||||
},
|
||||
"folder": {
|
||||
@@ -370,6 +372,7 @@ def _saveSettings(data):
|
||||
if "timeoutTemperatureTargetSet" in data["serial"]: s.setFloat(["serial", "timeout", "temperatureTargetSet"], data["serial"]["timeoutTemperatureTargetSet"])
|
||||
if "timeoutTemperatureAutoreport" in data["serial"]: s.setFloat(["serial", "timeout", "temperatureAutoreport"], data["serial"]["timeoutTemperatureAutoreport"])
|
||||
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 "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"])
|
||||
@@ -399,6 +402,7 @@ def _saveSettings(data):
|
||||
if "maxTimeoutsPrinting" in data["serial"]: s.setInt(["serial", "maxCommunicationTimeouts", "printing"], data["serial"]["maxTimeoutsPrinting"])
|
||||
if "maxTimeoutsLong" in data["serial"]: s.setInt(["serial", "maxCommunicationTimeouts", "long"], data["serial"]["maxTimeoutsLong"])
|
||||
if "capAutoreportTemp" in data["serial"]: s.setBoolean(["serial", "capabilities", "autoreport_temp"], data["serial"]["capAutoreportTemp"])
|
||||
if "capAutoreportSdStatus" in data["serial"]: s.setBoolean(["serial", "capabilities", "autoreport_sdstatus"], data["serial"]["capAutoreportSdStatus"])
|
||||
if "capBusyProtocol" in data["serial"]: s.setBoolean(["serial", "capabilities", "busy_protocol"], data["serial"]["capBusyProtocol"])
|
||||
|
||||
oldLog = s.getBoolean(["serial", "log"])
|
||||
|
||||
@@ -99,6 +99,7 @@ default_settings = {
|
||||
"temperatureTargetSet": 2,
|
||||
"temperatureAutoreport": 2,
|
||||
"sdStatus": 1,
|
||||
"sdStatusAutoreport": 1,
|
||||
"resendOk": .5
|
||||
},
|
||||
"maxCommunicationTimeouts": {
|
||||
@@ -137,6 +138,7 @@ default_settings = {
|
||||
|
||||
"capabilities": {
|
||||
"autoreport_temp": True,
|
||||
"autoreport_sdstatus": True,
|
||||
"busy_protocol": True
|
||||
},
|
||||
|
||||
@@ -403,7 +405,8 @@ default_settings = {
|
||||
"m115FormatString": "FIRMWARE_NAME: {firmware_name} PROTOCOL_VERSION:1.0",
|
||||
"m115ReportCapabilities": False,
|
||||
"capabilities": {
|
||||
"AUTOREPORT_TEMP": True
|
||||
"AUTOREPORT_TEMP": True,
|
||||
"AUTOREPORT_SD_STATUS": True
|
||||
},
|
||||
"ambientTemperature": 21.3,
|
||||
"errors": {
|
||||
|
||||
@@ -158,6 +158,7 @@ $(function() {
|
||||
self.serial_timeoutTemperatureTargetSet = ko.observable(undefined);
|
||||
self.serial_timeoutTemperatureAutoreport = ko.observable(undefined);
|
||||
self.serial_timeoutSdStatus = ko.observable(undefined);
|
||||
self.serial_timeoutSdStatusAutoreport = ko.observable(undefined);
|
||||
self.serial_log = ko.observable(undefined);
|
||||
self.serial_additionalPorts = ko.observable(undefined);
|
||||
self.serial_additionalBaudrates = ko.observable(undefined);
|
||||
@@ -183,6 +184,7 @@ $(function() {
|
||||
self.serial_maxTimeoutsPrinting = ko.observable(undefined);
|
||||
self.serial_maxTimeoutsLong = ko.observable(undefined);
|
||||
self.serial_capAutoreportTemp = ko.observable(undefined);
|
||||
self.serial_capAutoreportSdStatus = ko.observable(undefined);
|
||||
self.serial_capBusyProtocol = ko.observable(undefined);
|
||||
|
||||
self.folder_uploads = ko.observable(undefined);
|
||||
|
||||
@@ -87,7 +87,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group" title="{{ _('Interval in which to poll for the SD printing status information from the printer while printing') }}">
|
||||
<label class="control-label" for="settings-serialTimeoutSdStatus">{{ _('SD status interval') }}</label>
|
||||
<label class="control-label" for="settings-serialTimeoutSdStatus">{{ _('SD status interval (polling)') }}</label>
|
||||
<div class="controls">
|
||||
<div class="input-append">
|
||||
<input type="number" step="any" min="0" class="input-mini text-right" data-bind="value: serial_timeoutSdStatus" id="settings-serialTimeoutSdStatus">
|
||||
@@ -95,6 +95,16 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group" title="{{ _('SD status interval to request from autoreport capable firmwares. A value of 0 disables autoreporting by the firmware and forces polling.') }}">
|
||||
<label class="control-label" for="settings-serialTimeoutSdStatus">{{ _('SD status interval (autoreport)') }}</label>
|
||||
<div class="controls">
|
||||
<div class="input-append">
|
||||
<input type="number" step="any" min="0" class="input-mini text-right" data-bind="value: serial_timeoutSdStatusAutoreport" id="settings-serialTimeoutSdStatusAutoreport">
|
||||
<span class="add-on">s</span>
|
||||
</div>
|
||||
<span class="help-inline">{{ _('Autoreport interval to request from firmware')}}</span>
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
||||
<fieldset id="settings_serial_timeouts_timeouts">
|
||||
<legend>{{ _('Timeouts') }}</legend>
|
||||
@@ -243,6 +253,13 @@
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<div class="controls">
|
||||
<label class="checkbox">
|
||||
<input type="checkbox" data-bind="checked: serial_capAutoreportSdStatus" id="settings-serialCapAutoreportSdStatus"> {{ _('Support sd status autoreporting by firmware, if detected') }}
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<div class="controls">
|
||||
<label class="checkbox">
|
||||
|
||||
@@ -336,6 +336,7 @@ class MachineCom(object):
|
||||
STATE_PAUSING = 13
|
||||
|
||||
CAPABILITY_AUTOREPORT_TEMP = "AUTOREPORT_TEMP"
|
||||
CAPABILITY_AUTOREPORT_SD_STATUS = "AUTOREPORT_SD_STATUS"
|
||||
CAPABILITY_BUSY_PROTOCOL = "BUSY_PROTOCOL"
|
||||
|
||||
CAPABILITY_SUPPORT_ENABLED = "enabled"
|
||||
@@ -422,6 +423,7 @@ class MachineCom(object):
|
||||
|
||||
self._capability_support = {
|
||||
self.CAPABILITY_AUTOREPORT_TEMP: settings().getBoolean(["serial", "capabilities", "autoreport_temp"]),
|
||||
self.CAPABILITY_AUTOREPORT_SD_STATUS: settings().getBoolean(["serial", "capabilities", "autoreport_sdstatus"]),
|
||||
self.CAPABILITY_BUSY_PROTOCOL: settings().getBoolean(["serial", "capabilities", "busy_protocol"])
|
||||
}
|
||||
|
||||
@@ -438,6 +440,7 @@ class MachineCom(object):
|
||||
self._firmware_capabilities = dict()
|
||||
|
||||
self._temperature_autoreporting = False
|
||||
self._sdstatus_autoreporting = False
|
||||
self._busy_protocol_detected = False
|
||||
|
||||
self._trigger_ok_after_resend = settings().get(["serial", "supportResendsWithoutOk"])
|
||||
@@ -1642,6 +1645,9 @@ class MachineCom(object):
|
||||
if capability == self.CAPABILITY_AUTOREPORT_TEMP and enabled:
|
||||
self._logger.info("Firmware states that it supports temperature autoreporting")
|
||||
self._set_autoreport_temperature_interval()
|
||||
elif capability == self.CAPABILITY_AUTOREPORT_SD_STATUS and enabled:
|
||||
self._logger.info("Firmware states that it supports sd status autoreporting")
|
||||
self._set_autoreport_sdstatus_interval()
|
||||
|
||||
##~~ invalid extruder
|
||||
elif 'invalid extruder' in lower_line:
|
||||
@@ -2036,7 +2042,7 @@ class MachineCom(object):
|
||||
command or heating, no poll will be done.
|
||||
"""
|
||||
|
||||
if self.isOperational() and not self._connection_closing and self.isSdPrinting() and not self._long_running_command and not self._dwelling_until and not self._heating:
|
||||
if self.isOperational() and not self._sdstatus_autoreporting and not self._connection_closing and self.isSdPrinting() and not self._long_running_command and not self._dwelling_until and not self._heating:
|
||||
self.sendCommand("M27", cmd_type="sd_status_poll", tags={"trigger:comm.poll_sd_status"})
|
||||
|
||||
def _set_autoreport_temperature_interval(self, interval=None):
|
||||
@@ -2047,6 +2053,14 @@ class MachineCom(object):
|
||||
interval = 2
|
||||
self.sendCommand("M155 S{}".format(interval), tags={"trigger:comm.set_autoreport_temperature_interval"})
|
||||
|
||||
def _set_autoreport_sdstatus_interval(self, interval=None):
|
||||
if interval is None:
|
||||
try:
|
||||
interval = int(self._timeout_intervals.get("sdStatusAutoreport", 1))
|
||||
except:
|
||||
interval = 1
|
||||
self.sendCommand("M27 S{}".format(interval), tags={"trigger:comm.set_autoreport_sdstatus_interval"})
|
||||
|
||||
def _set_busy_protocol_interval(self, interval=None):
|
||||
if interval is None:
|
||||
try:
|
||||
@@ -2079,6 +2093,8 @@ class MachineCom(object):
|
||||
|
||||
if self._temperature_autoreporting:
|
||||
self._set_autoreport_temperature_interval()
|
||||
if self._sdstatus_autoreporting:
|
||||
self._set_autoreport_sdstatus_interval()
|
||||
if self._busy_protocol_detected:
|
||||
self._set_busy_protocol_interval()
|
||||
|
||||
@@ -3053,6 +3069,16 @@ class MachineCom(object):
|
||||
except:
|
||||
pass
|
||||
|
||||
def _gcode_M27_sending(self, cmd, cmd_type=None, gcode=None, subcode=None, *args, **kwargs):
|
||||
match = regexes_parameters["intS"].search(cmd)
|
||||
if match:
|
||||
try:
|
||||
interval = int(match.group("value"))
|
||||
self._sdstatus_autoreporting = self._firmware_capabilities.get(self.CAPABILITY_AUTOREPORT_SD_STATUS, False) \
|
||||
and (interval > 0)
|
||||
except:
|
||||
pass
|
||||
|
||||
def _gcode_M110_sending(self, cmd, cmd_type=None, gcode=None, subcode=None, *args, **kwargs):
|
||||
newLineNumber = 0
|
||||
match = regexes_parameters["intN"].search(cmd)
|
||||
|
||||
Reference in new issue
Block a user