From 257c4ed8aa417a15dba693f97967ab817af67e84 Mon Sep 17 00:00:00 2001 From: Mark Walker Date: Wed, 30 Dec 2015 14:13:33 -0700 Subject: [PATCH 1/3] Add RepRapPro style file opened to virtual printer --- 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 258e8464..a23241df 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 ab0773f2..4385b2f7 100644 --- a/src/octoprint/plugins/virtual_printer/virtual.py +++ b/src/octoprint/plugins/virtual_printer/virtual.py @@ -539,7 +539,10 @@ class VirtualPrinter(object): else: self._selectedSdFile = file self._selectedSdFileSize = os.stat(file).st_size - self._send("File opened: %s Size: %d" % (filename, self._selectedSdFileSize)) + if settings().getBoolean(["devel", "virtualPrinter", "includeFilenameInOpened"]): + self._send("File opened: %s Size: %d" % (filename, self._selectedSdFileSize)) + else: + self._send("File opened") self._send("File selected") def _startSdPrint(self): diff --git a/src/octoprint/settings.py b/src/octoprint/settings.py index 45d17297..da58564a 100644 --- a/src/octoprint/settings.py +++ b/src/octoprint/settings.py @@ -300,6 +300,7 @@ default_settings = { "okWithLinenumber": False, "numExtruders": 1, "includeCurrentToolInTemps": True, + "includeFilenameOnOpened": True, "movementSpeed": { "x": 6000, "y": 6000, From ba4b7c09bfe60274fc319891a74135d9cd2cd381 Mon Sep 17 00:00:00 2001 From: Mark Walker Date: Wed, 30 Dec 2015 14:25:58 -0700 Subject: [PATCH 2/3] Allow M23 "File opened" response with no filename --- 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 da58564a..5c168cda 100644 --- a/src/octoprint/settings.py +++ b/src/octoprint/settings.py @@ -300,7 +300,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 27181edb..fd3b3090 100644 --- a/src/octoprint/util/comm.py +++ b/src/octoprint/util/comm.py @@ -1140,12 +1140,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 ac685703c12074da78c6e135604888b5b8da640e Mon Sep 17 00:00:00 2001 From: Mark Walker Date: Sun, 5 Jun 2016 07:00:14 +0000 Subject: [PATCH 3/3] 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 :-( --- 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 a23241df..64c372a8 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 276c365f..28412ffd 100644 --- a/src/octoprint/printer/standard.py +++ b/src/octoprint/printer/standard.py @@ -362,7 +362,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 d0f56874..9d369e05 100644 --- a/src/octoprint/server/api/settings.py +++ b/src/octoprint/server/api/settings.py @@ -68,6 +68,7 @@ def getSettings(): "alwaysSendChecksum": s.getBoolean(["feature", "alwaysSendChecksum"]), "neverSendChecksum": s.getBoolean(["feature", "neverSendChecksum"]), "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"]), @@ -229,6 +230,7 @@ def _saveSettings(data): if "alwaysSendChecksum" in data["feature"].keys(): s.setBoolean(["feature", "alwaysSendChecksum"], data["feature"]["alwaysSendChecksum"]) if "neverSendChecksum" in data["feature"].keys(): s.setBoolean(["feature", "neverSendChecksum"], data["feature"]["neverSendChecksum"]) 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 5c168cda..52187f0e 100644 --- a/src/octoprint/settings.py +++ b/src/octoprint/settings.py @@ -166,6 +166,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 d13b0708..9f6a72c7 100644 --- a/src/octoprint/static/js/app/viewmodels/settings.js +++ b/src/octoprint/static/js/app/viewmodels/settings.js @@ -124,6 +124,7 @@ $(function() { self.feature_waitForStart = ko.observable(undefined); self.feature_sendChecksum = ko.observable("print"); 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 ad13738c..3f4aacdd 100644 --- a/src/octoprint/templates/dialogs/settings/features.jinja2 +++ b/src/octoprint/templates/dialogs/settings/features.jinja2 @@ -27,6 +27,13 @@ +
+
+ +
+