Skip to content

Commit

Permalink
Save without restart (#191)
Browse files Browse the repository at this point in the history
* SAVE_CONFIG without restart

* black formatting

* Added caution warning

* Update README.md

* Added test case

---------

Co-authored-by: Rogerio Goncalves <[email protected]>
  • Loading branch information
Zeanon and rogerlz authored Apr 10, 2024
1 parent c906c80 commit d209dee
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 3 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ If I want my printer to light itself on fire, I should be able to make my printe

- [filament_switch|motion_sensor: runout distance, smart and runout gcode](https://github.com/DangerKlippers/danger-klipper/pull/158)

- [save_config: save without restarting the firmware](https://github.com/DangerKlippers/danger-klipper/pull/191)

- [configfile: recursive globs](https://github.com/DangerKlippers/danger-klipper/pull/200) / ([klipper#6375](https://github.com/Klipper3d/klipper/pull/6375))

If you're feeling adventurous, take a peek at the extra features in the bleeding-edge branch [feature documentation](docs/Bleeding_Edge.md)
Expand Down
3 changes: 2 additions & 1 deletion docs/G-Codes.md
Original file line number Diff line number Diff line change
Expand Up @@ -291,10 +291,11 @@ EEPROM of a BLTouch V3.1 Available output_modes are: `5V`, `OD`
The configfile module is automatically loaded.

#### SAVE_CONFIG
`SAVE_CONFIG`: This command will overwrite the main printer config
`SAVE_CONFIG [RESTART=0|1]`: This command will overwrite the main printer config
file and restart the host software. This command is used in
conjunction with other calibration commands to store the results of
calibration tests.
If RESTART is set to 0, no restart will be performed !!USE WITH CAUTION!!.

### [delayed_gcode]

Expand Down
11 changes: 9 additions & 2 deletions klippy/configfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -696,5 +696,12 @@ def cmd_SAVE_CONFIG(self, gcmd):
data = regular_data.rstrip() + autosave_data
self._write_backup(cfgname, data, gcode)

# Request a restart
gcode.request_restart("restart")
# If requested restart or no restart just flag config saved
require_restart = gcmd.get_int("RESTART", 1, minval=0, maxval=1)
if require_restart:
# Request a restart
gcode.request_restart("restart")
else:
# flag config updated to false since config saved with no restart
self.save_config_pending = False
gcode.respond_info("Config update without restart successful")
4 changes: 4 additions & 0 deletions test/klippy/danger_options.test
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,7 @@ G1 X1
G1 Y1

SAVE_CONFIG

SAVE_CONFIG RESTART=0

SAVE_CONFIG RESTART=1

0 comments on commit d209dee

Please sign in to comment.