✨ Send M20 L if detected as supported

Also support quoted long names, which apparently are sent by some
firmwares? Make a suggestion for a format that is universally parseable,
document it on the reprep wiki, people STILL find a way to be
incompatible to it. I can't even...

Anyhow. See https://community.octoprint.org/t/adding-support-for-m20-l/34402
This commit is contained in:
Gina Häußge committed 2021-05-25 11:15:43 +02:00
1 parent 9cf0802bf2
commit 88921542ef
7 files changed
+37 -6

No files matched your search

@@ -30,7 +30,7 @@ class VirtualPrinterPlugin(
"smoothieTemperatureReporting": False,
"klipperTemperatureReporting": False,
"reprapfwM114": False,
"sdFiles": {"size": True, "longname": False},
"sdFiles": {"size": True, "longname": False, "longname_quoted": True},
"throttle": 0.01,
"sendWait": True,
"waitInterval": 1.0,
@@ -55,6 +55,7 @@ class VirtualPrinterPlugin(
"AUTOREPORT_TEMP": True,
"AUTOREPORT_SD_STATUS": True,
"EMERGENCY_PARSER": True,
"EXTENDED_M20": False,
},
"m114FormatString": "X:{x} Y:{y} Z:{z} E:{e[current]} Count: A:{a} B:{b} C:{c}",
"m105TargetFormatString": "{heater}:{actual:.2f}/ {target:.2f}",
@@ -607,7 +607,7 @@ class VirtualPrinter(object):
def _gcode_M20(self, data):
# type: (str) -> None
if self._sdCardReady:
self._listSd()
self._listSd(incl_long="L" in data)
# noinspection PyUnusedLocal
def _gcode_M21(self, data):
@@ -1415,10 +1415,13 @@ class VirtualPrinter(object):
except Exception:
self._logger.exception("While handling %r", data)
def _listSd(self):
def _listSd(self, incl_long=False):
if self._settings.get_boolean(["sdFiles", "size"]):
if self._settings.get_boolean(["sdFiles", "longname"]):
line = "{dosname} {size} {name}"
if self._settings.get_boolean(["sdFiles", "longname"]) or incl_long:
if self._settings.get_boolean(["sdFiles", "longname_quoted"]):
line = '{dosname} {size} "{name}"'
else:
line = "{dosname} {size} {name}"
else:
line = "{dosname} {size}"
else:
+6
View File
@@ -253,6 +253,7 @@ def getSettings():
"capEmergencyParser": s.getBoolean(
["serial", "capabilities", "emergency_parser"]
),
"capExtendedM20": s.getBoolean(["serial", "capabilities", "extended_m20"]),
"resendRatioThreshold": s.getInt(["serial", "resendRatioThreshold"]),
"resendRatioStart": s.getInt(["serial", "resendRatioStart"]),
},
@@ -913,6 +914,11 @@ def _saveSettings(data):
["serial", "capabilities", "emergency_parser"],
data["serial"]["capEmergencyParser"],
)
if "capExtendedM20" in data["serial"]:
s.setBoolean(
["serial", "capabilities", "extended_m20"],
data["serial"]["capExtendedM20"],
),
if "resendRatioThreshold" in data["serial"]:
s.setInt(
["serial", "resendRatioThreshold"], data["serial"]["resendRatioThreshold"]
+1
View File
@@ -180,6 +180,7 @@ default_settings = {
"autoreport_sdstatus": True,
"busy_protocol": True,
"emergency_parser": True,
"extended_m20": True,
},
"resendRatioThreshold": 10,
"resendRatioStart": 100,
@@ -237,6 +237,7 @@ $(function () {
self.serial_capAutoreportSdStatus = ko.observable(undefined);
self.serial_capBusyProtocol = ko.observable(undefined);
self.serial_capEmergencyParser = ko.observable(undefined);
self.serial_capExtendedM20 = ko.observable(undefined);
self.serial_sendM112OnError = ko.observable(undefined);
self.serial_disableSdPrintingDetection = ko.observable(undefined);
self.serial_ackMax = ko.observable(undefined);
@@ -365,6 +365,13 @@
</label>
</div>
</div>
<div class="control-group">
<div class="controls">
<label class="checkbox">
<input type="checkbox" data-bind="checked: serial_capExtendedM20" id="settings-serialCapExtendedM20"> {{ _('Send <code>M20 L</code> instead of <code>M20</code> to use extended SD file lists, if detected as supported by the firmware') }}
</label>
</div>
</div>
<div class="control-group">
<div class="controls">
<label class="checkbox">
+13 -1
View File
@@ -470,6 +470,7 @@ class MachineCom(object):
CAPABILITY_BUSY_PROTOCOL = "BUSY_PROTOCOL"
CAPABILITY_EMERGENCY_PARSER = "EMERGENCY_PARSER"
CAPABILITY_CHAMBER_TEMP = "CHAMBER_TEMPERATURE"
CAPABILITY_EXTENDED_M20 = "EXTENDED_M20"
CAPABILITY_SUPPORT_ENABLED = "enabled"
CAPABILITY_SUPPORT_DETECTED = "detected"
@@ -589,6 +590,9 @@ class MachineCom(object):
self.CAPABILITY_CHAMBER_TEMP: settings().getBoolean(
["serial", "capabilities", "chamber_temp"]
),
self.CAPABILITY_EXTENDED_M20: settings().getBoolean(
["serial", "capabilities", "extended_m20"]
),
}
last_line_count = settings().getInt(["serial", "lastLineBufferSize"])
@@ -1951,8 +1955,13 @@ class MachineCom(object):
if tags is None:
tags = set()
if self._capability_supported(self.CAPABILITY_EXTENDED_M20):
command = "M20 L"
else:
command = "M20"
self.sendCommand(
"M20",
command,
tags=tags
| {
"trigger:comm.refresh_sd_files",
@@ -2388,6 +2397,9 @@ class MachineCom(object):
filename = filename.lower()
self._sdFiles.append((filename, size))
if longname is not None:
if longname[0] == '"' and longname[-1] == '"':
# apparently some firmwares enclose the long name in quotes...
longname = longname[1:-1]
self._sdFilesMap[filename] = longname
continue