diff --git a/src/octoprint/printer/standard.py b/src/octoprint/printer/standard.py index 742035022..2acf848c9 100644 --- a/src/octoprint/printer/standard.py +++ b/src/octoprint/printer/standard.py @@ -78,7 +78,6 @@ class Printer(PrinterInterface, comm.MachineComPrintCallback): # sd handling self._sdPrinting = False self._sdStreaming = False - self._sdFilelistAvailable = threading.Event() self._streamingFinishedCallback = None self._streamingFailedCallback = None @@ -1007,12 +1006,10 @@ class Printer(PrinterInterface, comm.MachineComPrintCallback): if tags is None: tags = set() - remote_name = self._get_free_remote_name(filename) self._create_estimator("stream") - self._comm.startFileTransfer( + remote_name = self._comm.startFileTransfer( path, filename, - "/" + remote_name, special=not valid_file_type(filename, "gcode"), tags=tags | {"trigger:printer.add_sd_file"}, ) @@ -1049,12 +1046,11 @@ class Printer(PrinterInterface, comm.MachineComPrintCallback): """ if not self._comm or not self._comm.isSdReady(): return - self._sdFilelistAvailable.clear() self._comm.refreshSdFiles( - tags=kwargs.get("tags", set()) | {"trigger:printer.refresh_sd_files"} + tags=kwargs.get("tags", set()) | {"trigger:printer.refresh_sd_files"}, + blocking=blocking, + timeout=kwargs.get("timeout", 10), ) - if blocking and not self.is_printing(): - self._sdFilelistAvailable.wait(kwargs.get("timeout", 10)) # ~~ state monitoring @@ -1225,7 +1221,7 @@ class Printer(PrinterInterface, comm.MachineComPrintCallback): ) ) - def _setJobData(self, filename, filesize, sd, user=None): + def _setJobData(self, filename, filesize, sd, user=None, data=None): with self._selectedFileMutex: if filename is not None: if sd: @@ -1278,11 +1274,11 @@ class Printer(PrinterInterface, comm.MachineComPrintCallback): date = None filament = None display_name = name_in_storage + if path_on_disk: - # Use a string for mtime because it could be float and the + # Use an int for mtime because it could be float and the # javascript needs to exact match - if not sd: - date = int(os.stat(path_on_disk).st_mtime) + date = int(os.stat(path_on_disk).st_mtime) try: fileData = self._fileManager.get_metadata( @@ -1329,6 +1325,10 @@ class Printer(PrinterInterface, comm.MachineComPrintCallback): self._selectedFile["estimatedPrintTime"] = estimatedPrintTime self._selectedFile["estimatedPrintTimeType"] = "analysis" + elif data: + display_name = data.longname + date = data.timestamp + self._stateMonitor.set_job_data( self._dict( file=self._dict( @@ -1539,9 +1539,8 @@ class Printer(PrinterInterface, comm.MachineComPrintCallback): def on_comm_sd_files(self, files): eventManager().fire(Events.UPDATED_FILES, {"type": "printables"}) - self._sdFilelistAvailable.set() - def on_comm_file_selected(self, full_path, size, sd, user=None): + def on_comm_file_selected(self, full_path, size, sd, user=None, data=None): if full_path is not None: payload = self._payload_for_print_job_event( location=FileDestinations.SDCARD if sd else FileDestinations.LOCAL, @@ -1564,7 +1563,7 @@ class Printer(PrinterInterface, comm.MachineComPrintCallback): "Print job deselected - user: {}".format(user if user else "n/a") ) - self._setJobData(full_path, size, sd, user=user) + self._setJobData(full_path, size, sd, user=user, data=data) self._stateMonitor.set_state( self._dict( text=self.get_state_string(), diff --git a/src/octoprint/schema/config/serial.py b/src/octoprint/schema/config/serial.py index 61d453580..6da0e2f5c 100644 --- a/src/octoprint/schema/config/serial.py +++ b/src/octoprint/schema/config/serial.py @@ -70,13 +70,22 @@ class SerialCapabilities(BaseModel): """Whether to enable temperature autoreport in the firmware if its support is detected""" autoreport_sdstatus: bool = True + """Whether to enable SD printing autoreport in the firmware if its support is detected""" + autoreport_pos: bool = True + """Whether to enable position autoreport in the firmware if its support is detected""" busy_protocol: bool = True """Whether to shorten the communication timeout if the firmware seems to support the busy protocol""" emergency_parser: bool = True + """Whether to send emergency commands out of band if the firmware seems to support the emergency parser""" + extended_m20: bool = True + """Whether to request extended M20 (file list) output from the firmware if its support is detected""" + + lfn_write: bool = True + """Whether to enable long filename support for SD card writes if the firmware reports support for it""" @with_attrs_docs diff --git a/src/octoprint/server/api/settings.py b/src/octoprint/server/api/settings.py index 625b2cafd..fd3f18f82 100644 --- a/src/octoprint/server/api/settings.py +++ b/src/octoprint/server/api/settings.py @@ -258,6 +258,7 @@ def getSettings(): ["serial", "capabilities", "emergency_parser"] ), "capExtendedM20": s.getBoolean(["serial", "capabilities", "extended_m20"]), + "capLfnWrite": s.getBoolean(["serial", "capabilities", "lfn_write"]), "resendRatioThreshold": s.getInt(["serial", "resendRatioThreshold"]), "resendRatioStart": s.getInt(["serial", "resendRatioStart"]), "ignoreEmptyPorts": s.getBoolean(["serial", "ignoreEmptyPorts"]), @@ -957,6 +958,11 @@ def _saveSettings(data): ["serial", "capabilities", "extended_m20"], data["serial"]["capExtendedM20"], ), + if "capLfnWrite" in data["serial"]: + s.setBoolean( + ["serial", "capabilities", "lfn_write"], + data["serial"]["capLfnWrite"], + ) if "resendRatioThreshold" in data["serial"]: s.setInt( ["serial", "resendRatioThreshold"], data["serial"]["resendRatioThreshold"] diff --git a/src/octoprint/static/js/app/viewmodels/settings.js b/src/octoprint/static/js/app/viewmodels/settings.js index 1d72febf0..d07466105 100644 --- a/src/octoprint/static/js/app/viewmodels/settings.js +++ b/src/octoprint/static/js/app/viewmodels/settings.js @@ -238,6 +238,7 @@ $(function () { self.serial_capBusyProtocol = ko.observable(undefined); self.serial_capEmergencyParser = ko.observable(undefined); self.serial_capExtendedM20 = ko.observable(undefined); + self.serial_capLfnWrite = ko.observable(undefined); self.serial_sendM112OnError = ko.observable(undefined); self.serial_disableSdPrintingDetection = ko.observable(undefined); self.serial_ackMax = ko.observable(undefined); diff --git a/src/octoprint/templates/dialogs/settings/serialconnection.jinja2 b/src/octoprint/templates/dialogs/settings/serialconnection.jinja2 index 2a147052a..cb3cfbcd3 100644 --- a/src/octoprint/templates/dialogs/settings/serialconnection.jinja2 +++ b/src/octoprint/templates/dialogs/settings/serialconnection.jinja2 @@ -411,6 +411,13 @@ +
+
+ +
+