diff options
author | Kamil TrzciĆski <ayufan@ayufan.eu> | 2021-06-14 21:09:55 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-06-14 15:09:55 -0400 |
commit | 46f51b2bb0dadfff0382af32c22356571bb46d17 (patch) | |
tree | ffc30c601b7bc5c21658fb1defb96d4c6ee34a63 /klippy/extras/virtual_sdcard.py | |
parent | f7279a037d7760befb2f085ab0ab99057681862e (diff) | |
download | kutter-46f51b2bb0dadfff0382af32c22356571bb46d17.tar.gz kutter-46f51b2bb0dadfff0382af32c22356571bb46d17.tar.xz kutter-46f51b2bb0dadfff0382af32c22356571bb46d17.zip |
print_stats: add `cancelled` when `CANCEL_PRINT` used (#4366)
Before this change, a `CANCEL_PRINT` set a `print_stats` to `paused`
that would later be workaround-ed with `fluidd`/`mainsail` to re-define
`CANCEL_PRINT`.
This sets a proper canceled state, but additionally closes a file
from a `virtual_sdcard` context for `canceled`/`error`, as this is no longer
resumable from this point.
Signed-off-by: Kamil Trzcinski <ayufan@ayufan.eu>
Diffstat (limited to 'klippy/extras/virtual_sdcard.py')
-rw-r--r-- | klippy/extras/virtual_sdcard.py | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/klippy/extras/virtual_sdcard.py b/klippy/extras/virtual_sdcard.py index 66fc5ade..3cd77612 100644 --- a/klippy/extras/virtual_sdcard.py +++ b/klippy/extras/virtual_sdcard.py @@ -98,6 +98,13 @@ class VirtualSD: self.must_pause_work = False self.work_timer = self.reactor.register_timer( self.work_handler, self.reactor.NOW) + def do_cancel(self): + if self.current_file is not None: + self.do_pause() + self.current_file.close() + self.current_file = None + self.print_stats.note_cancel() + self.file_position = self.file_size = 0. # G-Code commands def cmd_error(self, gcmd): raise gcmd.error("SD write not supported") @@ -212,6 +219,7 @@ class VirtualSD: gcode_mutex = self.gcode.get_mutex() partial_input = "" lines = [] + error_message = None while not self.must_pause_work: if not lines: # Read more data @@ -245,7 +253,7 @@ class VirtualSD: try: self.gcode.run_script(line) except self.gcode.error as e: - self.print_stats.note_error(str(e)) + error_message = str(e) break except: logging.exception("virtual_sdcard dispatch") @@ -265,7 +273,9 @@ class VirtualSD: logging.info("Exiting SD card print (position %d)", self.file_position) self.work_timer = None self.cmd_from_sd = False - if self.current_file is not None: + if error_message is not None: + self.print_stats.note_error(error_message) + elif self.current_file is not None: self.print_stats.note_pause() else: self.print_stats.note_complete() |