From aa02750458d345fdcd1b6f5d520ae6f31e3e3e73 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Mon, 8 Jan 2024 11:05:09 +0100 Subject: [PATCH 1/3] =?UTF-8?q?=F0=9F=90=9B=20Make=20sure=20to=20sort=20fo?= =?UTF-8?q?lder=20list?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Closes #4922 --- src/octoprint/static/js/app/viewmodels/files.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/octoprint/static/js/app/viewmodels/files.js b/src/octoprint/static/js/app/viewmodels/files.js index e0f2c659e..f7e5c3610 100644 --- a/src/octoprint/static/js/app/viewmodels/files.js +++ b/src/octoprint/static/js/app/viewmodels/files.js @@ -506,7 +506,9 @@ $(function () { }); return result; }; - self.folderList(["/"].concat(createFolderList(files))); + const folders = createFolderList(files); + folders.sort(); + self.folderList(["/"].concat(folders)); // Sanity check file list - see #2572 var nonrecursive = false; From 3e94574a9bb4084250acd61a9bb3ed81e8d880d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Mon, 8 Jan 2024 15:03:07 +0100 Subject: [PATCH 2/3] =?UTF-8?q?=F0=9F=90=9B=20virtual:=20remove=20wrong=20?= =?UTF-8?q?assertion?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Was actually wrong to have that here, but thankfully it was implemented wrong as well, and here two wrongs made one right. To match existing firmware out there, we should be sending SD status auto reports with progress information whenever a print from a selected SD file has been started. If a such a print is cancelled via OctoPrint, all we can do is send an M25 to pause it and just never resume it. That means that the SD status will continue to report the current file position. See #4924 --- src/octoprint/plugins/virtual_printer/virtual.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/octoprint/plugins/virtual_printer/virtual.py b/src/octoprint/plugins/virtual_printer/virtual.py index dc0e3c74a..ca48e9507 100644 --- a/src/octoprint/plugins/virtual_printer/virtual.py +++ b/src/octoprint/plugins/virtual_printer/virtual.py @@ -1579,7 +1579,7 @@ class VirtualPrinter: self._newSdFilePos = pos def _reportSdStatus(self): - if self._sdPrinter is not None and self._sdPrintingSemaphore.is_set: + if self._sdPrinter is not None: self._send( f"SD printing byte {self._selectedSdFilePos}/{self._selectedSdFileSize}" ) From 0a3e19a34216e170f9006eb55bc94208612d28dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Mon, 8 Jan 2024 17:01:07 +0100 Subject: [PATCH 3/3] =?UTF-8?q?=E2=9C=A8=20virtual:=20Implement=20basic=20?= =?UTF-8?q?M524=20support?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../plugins/virtual_printer/virtual.py | 23 +++++++++++++++---- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/octoprint/plugins/virtual_printer/virtual.py b/src/octoprint/plugins/virtual_printer/virtual.py index ca48e9507..19eaf20b4 100644 --- a/src/octoprint/plugins/virtual_printer/virtual.py +++ b/src/octoprint/plugins/virtual_printer/virtual.py @@ -250,6 +250,7 @@ class VirtualPrinter: self._sdCardReady = True self._sdPrinting = False + self._sdCacnelled = False if self._sdPrinter: self._sdPrinting = False self._sdPrintingSemaphore.set() @@ -682,6 +683,10 @@ class VirtualPrinter: if file is not None: self._send(file["name"]) + def _gcode_M524(self, data: str) -> None: + if self._sdCardReady: + self._cancelSdPrint() + def _gcode_M113(self, data: str) -> None: matchS = re.search(r"S([0-9]+)", data) if matchS is not None: @@ -1566,7 +1571,9 @@ class VirtualPrinter: def _startSdPrint(self): if self._selectedSdFile is not None: + self._sdPrinting = False if self._sdPrinter is None: + self._sdCancelled = False self._sdPrinting = True self._sdPrinter = threading.Thread(target=self._sdPrintingWorker) self._sdPrinter.start() @@ -1575,6 +1582,12 @@ class VirtualPrinter: def _pauseSdPrint(self): self._sdPrintingSemaphore.clear() + def _cancelSdPrint(self): + self._sdCancelled = True + self._sdPrinting = False + self._sdPrintingSemaphore.set() # just in case it was cleared before + self._sdPrinter.join() + def _setSdPos(self, pos): self._newSdFilePos = pos @@ -1975,12 +1988,12 @@ class VirtualPrinter: self._finishSdPrint() def _finishSdPrint(self): - if not self._killed: - self._sdPrintingSemaphore.clear() + self._sdPrintingSemaphore.clear() + self._selectedSdFilePos = 0 + self._sdPrinting = False + self._sdPrinter = None + if not self._killed and not self._sdCancelled: self._send("Done printing file") - self._selectedSdFilePos = 0 - self._sdPrinting = False - self._sdPrinter = None def _waitForHeatup(self, heater: str, only_wait_if_higher: bool) -> None: delta = 1