virtual_sdcard: Adds on_error_gcode

Signed-off-by: Pedro Lamas <pedrolamas@gmail.com>
This commit is contained in:
Pedro Lamas authored and KevinOConnor committed 2022-06-03 11:26:34 -04:00
1 parent dbc24ce339
commit c16eab212e
2 files changed
+11

No files matched your search

+3
View File
@@ -1334,6 +1334,9 @@ path:
# are not supported). One may point this to OctoPrint's upload
# directory (generally ~/.octoprint/uploads/ ). This parameter must
# be provided.
#on_error_gcode:
# A list of G-Code commands to execute when an error is reported.
```
### [sdcard_loop]
+8
View File
@@ -23,6 +23,10 @@ class VirtualSD:
self.must_pause_work = self.cmd_from_sd = False
self.next_file_position = 0
self.work_timer = None
# Error handling
gcode_macro = printer.load_object(config, 'gcode_macro')
self.on_error_gcode = gcode_macro.load_template(
config, 'on_error_gcode', '')
# Register commands
self.gcode = printer.lookup_object('gcode')
for cmd in ['M20', 'M21', 'M23', 'M24', 'M25', 'M26', 'M27']:
@@ -258,6 +262,10 @@ class VirtualSD:
self.gcode.run_script(line)
except self.gcode.error as e:
error_message = str(e)
try:
self.gcode.run_script(self.on_error_gcode.render())
except:
logging.exception("virtual_sdcard on_error")
break
except:
logging.exception("virtual_sdcard dispatch")