Skip to content

Commit

Permalink
virtual_sdcard: Define a default for on_gcode_error
Browse files Browse the repository at this point in the history
If on_gcode_error is not specified, default to running the
TURN_OFF_HEATERS command.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
  • Loading branch information
KevinOConnor committed Apr 15, 2024
1 parent 36f9b26 commit 2425a74
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
6 changes: 6 additions & 0 deletions docs/Config_Changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ All dates in this document are approximate.

## Changes

20240415: The `on_error_gcode` parameter in the `[virtual_sdcard]`
config section now has a default. If this parameter is not specified
it now defaults to `TURN_OFF_HEATERS`. If the previous behavior is
desired (take no default action on an error during a virtual_sdcard
print) then define `on_error_gcode` with an empty value.

20240313: The `max_accel_to_decel` parameter in the `[printer]` config
section has been deprecated. The `ACCEL_TO_DECEL` parameter of the
`SET_VELOCITY_LIMIT` command has been deprecated. The
Expand Down
3 changes: 2 additions & 1 deletion docs/Config_Reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -1472,7 +1472,8 @@ path:
# be provided.
#on_error_gcode:
# A list of G-Code commands to execute when an error is reported.
# See docs/Command_Templates.md for G-Code format. The default is to
# run TURN_OFF_HEATERS.
```

### [sdcard_loop]
Expand Down
8 changes: 7 additions & 1 deletion klippy/extras/virtual_sdcard.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@

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()
Expand All @@ -27,7 +33,7 @@ def __init__(self, config):
# 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']:
Expand Down

0 comments on commit 2425a74

Please sign in to comment.