virtual_sdcard: Define a default for on_gcode_error

If on_gcode_error is not specified, default to running the
TURN_OFF_HEATERS command.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
Kevin O'Connor
2024-03-21 23:22:10 -04:00
parent 36f9b26ef9
commit 2425a74638
3 changed files with 15 additions and 2 deletions

View File

@@ -7,6 +7,12 @@ import os, sys, logging, io
VALID_GCODE_EXTS = ['gcode', 'g', 'gco']
DEFAULT_ERROR_GCODE = """
{% if 'heaters' in printer %}
TURN_OFF_HEATERS
{% endif %}
"""
class VirtualSD:
def __init__(self, config):
self.printer = config.get_printer()
@@ -27,7 +33,7 @@ class VirtualSD:
# Error handling
gcode_macro = self.printer.load_object(config, 'gcode_macro')
self.on_error_gcode = gcode_macro.load_template(
config, 'on_error_gcode', '')
config, 'on_error_gcode', DEFAULT_ERROR_GCODE)
# Register commands
self.gcode = self.printer.lookup_object('gcode')
for cmd in ['M20', 'M21', 'M23', 'M24', 'M25', 'M26', 'M27']: