From 5eefee3a4d3f1471c004d4f1dd746461b4db8f28 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 :-( (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 @@ +
+
+ +
+