From 3069e05766815f408cb614f483812e8e6d03852c Mon Sep 17 00:00:00 2001 From: Mark Walker Date: Wed, 30 Dec 2015 14:13:33 -0700 Subject: [PATCH 1/7] Add RepRapPro style file opened to virtual printer (cherry-picked from 257c4ed) Conflicts: src/octoprint/plugins/virtual_printer/virtual.py --- docs/configuration/config_yaml.rst | 8 ++++++++ src/octoprint/plugins/virtual_printer/virtual.py | 5 ++++- src/octoprint/settings.py | 1 + 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/docs/configuration/config_yaml.rst b/docs/configuration/config_yaml.rst index 2b75ba93..f6b64de2 100644 --- a/docs/configuration/config_yaml.rst +++ b/docs/configuration/config_yaml.rst @@ -290,6 +290,14 @@ The following settings are only relevant to you if you want to do OctoPrint deve # < ok T0:34.3/0.0 T1:23.5/0.0 B:43.2/0.0 includeCurrentToolInTemps: true + # Whether to include the selected filename in the M23 File opened response. + # + # True: > M23 filename.gcode + # < File opened: filename.gcode Size: 27 + # False: > M23 filename.gcode + # > File opened + includeFilenameInOpened: true + # The maximum movement speeds of the simulated printer's axes, in mm/s movementSpeed: x: 6000 diff --git a/src/octoprint/plugins/virtual_printer/virtual.py b/src/octoprint/plugins/virtual_printer/virtual.py index 0ad7adec..8d253f14 100644 --- a/src/octoprint/plugins/virtual_printer/virtual.py +++ b/src/octoprint/plugins/virtual_printer/virtual.py @@ -425,7 +425,10 @@ class VirtualPrinter(): else: self._selectedSdFile = file self._selectedSdFileSize = os.stat(file).st_size - self.outgoing.put("File opened: %s Size: %d" % (filename, self._selectedSdFileSize)) + if settings().getBoolean(["devel", "virtualPrinter", "includeFilenameInOpened"]): + self.outgoing.put("File opened: %s Size: %d" % (filename, self._selectedSdFileSize)) + else: + self.outgoing.put("File opened") self.outgoing.put("File selected") def _startSdPrint(self): diff --git a/src/octoprint/settings.py b/src/octoprint/settings.py index 2bbc7bd3..d9a0f6df 100644 --- a/src/octoprint/settings.py +++ b/src/octoprint/settings.py @@ -293,6 +293,7 @@ default_settings = { "okWithLinenumber": False, "numExtruders": 1, "includeCurrentToolInTemps": True, + "includeFilenameOnOpened": True, "movementSpeed": { "x": 6000, "y": 6000, From 02b0e906f1ee0a92db5e9d5732cd1d17d014e431 Mon Sep 17 00:00:00 2001 From: Mark Walker Date: Wed, 30 Dec 2015 14:25:58 -0700 Subject: [PATCH 2/7] Allow M23 "File opened" response with no filename (cherry-picked from ba4b7c0) --- src/octoprint/settings.py | 2 +- src/octoprint/util/comm.py | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/octoprint/settings.py b/src/octoprint/settings.py index d9a0f6df..577e02bc 100644 --- a/src/octoprint/settings.py +++ b/src/octoprint/settings.py @@ -293,7 +293,7 @@ default_settings = { "okWithLinenumber": False, "numExtruders": 1, "includeCurrentToolInTemps": True, - "includeFilenameOnOpened": True, + "includeFilenameInOpened": True, "movementSpeed": { "x": 6000, "y": 6000, diff --git a/src/octoprint/util/comm.py b/src/octoprint/util/comm.py index dc88d71f..bd84f70a 100644 --- a/src/octoprint/util/comm.py +++ b/src/octoprint/util/comm.py @@ -1120,12 +1120,16 @@ class MachineCom(object): elif 'File opened' in line and not self._ignore_select: # answer to M23, at least on Marlin, Repetier and Sprinter: "File opened:%s Size:%d" match = regex_sdFileOpened.search(line) + if match: + name = match.group("name") + size = int(match.group("size")) + else: + name = "Unknown" + size = 0 if self._sdFileToSelect: name = self._sdFileToSelect self._sdFileToSelect = None - else: - name = match.group("name") - self._currentFile = PrintingSdFileInformation(name, int(match.group("size"))) + self._currentFile = PrintingSdFileInformation(name, size) elif 'File selected' in line: if self._ignore_select: self._ignore_select = False From 5eefee3a4d3f1471c004d4f1dd746461b4db8f28 Mon Sep 17 00:00:00 2001 From: Mark Walker Date: Sun, 5 Jun 2016 07:00:14 +0000 Subject: [PATCH 3/7] RepRapFirmware style M23 select file RepRapFirmware enumerates the gcode files starting at /gcode, it will also interpret any relative path as being relative to that folder. However a full absolute path will actually interpret as from the real root of the SD card :-( (cherry-picked from ac68570) --- docs/configuration/config_yaml.rst | 3 +++ src/octoprint/printer/standard.py | 2 +- src/octoprint/server/api/settings.py | 2 ++ src/octoprint/settings.py | 1 + src/octoprint/static/js/app/viewmodels/settings.js | 1 + src/octoprint/templates/dialogs/settings/features.jinja2 | 7 +++++++ 6 files changed, 15 insertions(+), 1 deletion(-) diff --git a/docs/configuration/config_yaml.rst b/docs/configuration/config_yaml.rst index f6b64de2..a0aad14b 100644 --- a/docs/configuration/config_yaml.rst +++ b/docs/configuration/config_yaml.rst @@ -434,6 +434,9 @@ Use the following settings to enable or disable OctoPrint features: # Specifies whether support for SD printing and file management should be enabled sdSupport: true + # Specifies whether firmware expects relative paths for selecting SD files + sdRelativePath: false + # Whether to always assume that an SD card is present in the printer. # Needed by some firmwares which don't report the SD card status properly. sdAlwaysAvailable: false diff --git a/src/octoprint/printer/standard.py b/src/octoprint/printer/standard.py index 8567594f..ca5517ae 100644 --- a/src/octoprint/printer/standard.py +++ b/src/octoprint/printer/standard.py @@ -360,7 +360,7 @@ class Printer(PrinterInterface, comm.MachineComPrintCallback): self._printAfterSelect = printAfterSelect self._posAfterSelect = pos - self._comm.selectFile("/" + path if sd else path, sd) + self._comm.selectFile("/" + path if sd and not settings().getBoolean(["feature", "sdRelativePath"]) else path, sd) self._setProgressData(completion=0) self._setCurrentZ(None) diff --git a/src/octoprint/server/api/settings.py b/src/octoprint/server/api/settings.py index 61c58b6c..eb00dd17 100644 --- a/src/octoprint/server/api/settings.py +++ b/src/octoprint/server/api/settings.py @@ -64,6 +64,7 @@ def getSettings(): "waitForStart": s.getBoolean(["feature", "waitForStartOnConnect"]), "alwaysSendChecksum": s.getBoolean(["feature", "alwaysSendChecksum"]), "sdSupport": s.getBoolean(["feature", "sdSupport"]), + "sdRelativePath": s.getBoolean(["feature", "sdRelativePath"]), "sdAlwaysAvailable": s.getBoolean(["feature", "sdAlwaysAvailable"]), "swallowOkAfterResend": s.getBoolean(["feature", "swallowOkAfterResend"]), "repetierTargetTemp": s.getBoolean(["feature", "repetierTargetTemp"]), @@ -213,6 +214,7 @@ def setSettings(): 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 "sdSupport" in data["feature"].keys(): s.setBoolean(["feature", "sdSupport"], data["feature"]["sdSupport"]) + if "sdRelativePath" in data["feature"].keys(): s.setBoolean(["feature", "sdRelativePath"], data["feature"]["sdRelativePath"]) 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"]) if "repetierTargetTemp" in data["feature"].keys(): s.setBoolean(["feature", "repetierTargetTemp"], data["feature"]["repetierTargetTemp"]) diff --git a/src/octoprint/settings.py b/src/octoprint/settings.py index 577e02bc..84fe8d80 100644 --- a/src/octoprint/settings.py +++ b/src/octoprint/settings.py @@ -162,6 +162,7 @@ default_settings = { "sendChecksumWithUnknownCommands": False, "unknownCommandsNeedAck": False, "sdSupport": True, + "sdRelativePath": False, "sdAlwaysAvailable": False, "swallowOkAfterResend": True, "repetierTargetTemp": False, diff --git a/src/octoprint/static/js/app/viewmodels/settings.js b/src/octoprint/static/js/app/viewmodels/settings.js index a28f54ed..d255a063 100644 --- a/src/octoprint/static/js/app/viewmodels/settings.js +++ b/src/octoprint/static/js/app/viewmodels/settings.js @@ -116,6 +116,7 @@ $(function() { self.feature_waitForStart = ko.observable(undefined); self.feature_alwaysSendChecksum = ko.observable(undefined); self.feature_sdSupport = ko.observable(undefined); + self.feature_sdRelativePath = ko.observable(undefined); self.feature_sdAlwaysAvailable = ko.observable(undefined); self.feature_swallowOkAfterResend = ko.observable(undefined); self.feature_repetierTargetTemp = ko.observable(undefined); diff --git a/src/octoprint/templates/dialogs/settings/features.jinja2 b/src/octoprint/templates/dialogs/settings/features.jinja2 index 97a5864f..02ff09c6 100644 --- a/src/octoprint/templates/dialogs/settings/features.jinja2 +++ b/src/octoprint/templates/dialogs/settings/features.jinja2 @@ -34,6 +34,13 @@ +
+
+ +
+