mirror of https://github.com/Desuuuu/klipper.git
virtual_sdcard: Adds on_error_gcode
Signed-off-by: Pedro Lamas <pedrolamas@gmail.com>
This commit is contained in:
parent
dbc24ce339
commit
c16eab212e
|
@ -1334,6 +1334,9 @@ path:
|
||||||
# are not supported). One may point this to OctoPrint's upload
|
# are not supported). One may point this to OctoPrint's upload
|
||||||
# directory (generally ~/.octoprint/uploads/ ). This parameter must
|
# directory (generally ~/.octoprint/uploads/ ). This parameter must
|
||||||
# be provided.
|
# be provided.
|
||||||
|
#on_error_gcode:
|
||||||
|
# A list of G-Code commands to execute when an error is reported.
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
### [sdcard_loop]
|
### [sdcard_loop]
|
||||||
|
|
|
@ -23,6 +23,10 @@ class VirtualSD:
|
||||||
self.must_pause_work = self.cmd_from_sd = False
|
self.must_pause_work = self.cmd_from_sd = False
|
||||||
self.next_file_position = 0
|
self.next_file_position = 0
|
||||||
self.work_timer = None
|
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
|
# Register commands
|
||||||
self.gcode = printer.lookup_object('gcode')
|
self.gcode = printer.lookup_object('gcode')
|
||||||
for cmd in ['M20', 'M21', 'M23', 'M24', 'M25', 'M26', 'M27']:
|
for cmd in ['M20', 'M21', 'M23', 'M24', 'M25', 'M26', 'M27']:
|
||||||
|
@ -258,6 +262,10 @@ class VirtualSD:
|
||||||
self.gcode.run_script(line)
|
self.gcode.run_script(line)
|
||||||
except self.gcode.error as e:
|
except self.gcode.error as e:
|
||||||
error_message = str(e)
|
error_message = str(e)
|
||||||
|
try:
|
||||||
|
self.gcode.run_script(self.on_error_gcode.render())
|
||||||
|
except:
|
||||||
|
logging.exception("virtual_sdcard on_error")
|
||||||
break
|
break
|
||||||
except:
|
except:
|
||||||
logging.exception("virtual_sdcard dispatch")
|
logging.exception("virtual_sdcard dispatch")
|
||||||
|
|
Loading…
Reference in New Issue