From ac685703c12074da78c6e135604888b5b8da640e Mon Sep 17 00:00:00 2001 From: Mark Walker Date: Sun, 5 Jun 2016 07:00:14 +0000 Subject: [PATCH] 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 @@ +
+
+ +
+