#G-Code Shell Command Extension Broke Klipper

1 messages · Page 1 of 1 (latest)

fringe delta
#

I just installed Staubgeborener's Klipper Back Up Script (https://github.com/Staubgeborener/klipper-backup/). Everything seemed to be going fine, right up until I installed G-Code Shell Command Extension via Kiauh. As soon as I did that, I was faced with this error in Klipper:

Klipper reports: ERROR

Option 'control' in section 'heater_bed' must be specified

Once the underlying issue is corrected, use the "RESTART"
command to reload the config and restart the host software.
Printer is halted

Except nothing was changed in my heater_bed section (which was working this morning). Right now, my heater bed code looks like this:

#####################################################################
#   Bed Heater
#####################################################################

[heater_bed]
##  SSR Pin - HEATBED
##  Thermistor - TH1
heater_pin: PG11
sensor_type: ATC Semitec 104NT-4-R025H42G
sensor_pin: PA2
pullup_resistor: 2200
##  Adjust Max Power so your heater doesn't warp your bed. Rule of thumb is 0.4 watts / cm^2 .
max_power: 0.7
min_temp: 0
max_temp: 120
#control: pid
#pid_kp: 58.437
#pid_ki: 2.347
#pid_kd: 363.769

And if I go and uncomment control: pid, I just get another error to go go "define" (uncomment) pid_kp, then pid_ki, pid_kd. Just to experiment, I went down the line until it started complaining about the Z-offset being undefined, which sent up even more alarm bells for me, since I use Tap. So that is when I undid all my uncomments, and re-commented everything back in.

#

If I scroll to the very bottom of the printer.cfg file, I find this:

    #*# <---------------------- SAVE_CONFIG ---------------------->
    #*# DO NOT EDIT THIS BLOCK OR BELOW. The contents are auto-generated.
    #*#
    #*# [heater_bed]
    #*# control = pid
    #*# pid_kp = 48.944
    #*# pid_ki = 2.913
    #*# pid_kd = 205.566
    #*#
    #*# [extruder]
    #*# control = pid
    #*# pid_kp = 25.319
    #*# pid_ki = 2.722
    #*# pid_kd = 58.868
    #*#
    #*# [probe]
    #*# z_offset = -1.070
    #*#
    #*# [bed_mesh default]
    #*# version = 1
    #*# points =
    #*#     0.003750, -0.007500, -0.010000, 0.005000, 0.003750
    #*#     0.033750, 0.023750, 0.032500, 0.016250, 0.007500
    #*#     0.023750, 0.000000, 0.005000, 0.012500, -0.008750
    #*#     0.017500, 0.017500, 0.027500, 0.003750, -0.030000
    #*#     0.007500, 0.036250, 0.051250, 0.022500, -0.001250
    #*# x_count = 5
    #*# y_count = 5
    #*# mesh_x_pps = 2
    #*# mesh_y_pps = 2
    #*# algo = bicubic
    #*# tension = 0.2
    #*# min_x = 40.0
    #*# max_x = 310.0
    #*# min_y = 40.0
    #*# max_y = 310.0

[include shell_command.cfg]

I am guessing that the problem is [include shell_command.cfg] ended up at the bottom of my printer.cfg file? Will moving that call-out to the top break anything? Or am I hunting something else?

That wasn't it. So I am stumped.

#

I also just tried changing the network manager settings discussed on this page: https://klipperbackup.xyz/automation/#backup-on-file-changes

My backup on boot did look like this:

[Unit]
Description=Klipper Backup On-boot Service
#Uncomment below lines if using network manager
After=NetworkManager-wait-online.service
Wants=NetworkManager-wait-online.service
#Uncomment below lines if not using network manager
#After=network-online.target
#Wants=network-online.target

[Service]
User={replace with your username}
Type=oneshot
ExecStart=/usr/bin/env bash -c "/usr/bin/env bash $HOME/klipper-backup/script.sh -c \"New Backup on boot - $(date +\"%%x - %%X\")\""

[Install]
WantedBy=default.target

And I changed it to this (because I do not know much about network managers):

[Unit]
Description=Klipper Backup On-boot Service
#Uncomment below lines if using network manager
#After=NetworkManager-wait-online.service
#Wants=NetworkManager-wait-online.service
#Uncomment below lines if not using network manager
After=network-online.target
Wants=network-online.target

[Service]
User={replace with your username}
Type=oneshot
ExecStart=/usr/bin/env bash -c "/usr/bin/env bash $HOME/klipper-backup/script.sh -c \"New Backup on boot - $(date +\"%%x - %%X\")\""

[Install]
WantedBy=default.target

But it made no difference (didn't even break my github integration). Ditto for backup on file change.

eager vale
#

But something about the save_config block must still be messed up, so klipper isn't loading it

#

What exactly does the bottom of the file look like there, now that you've pulled that back out?

fringe delta
#

Right now, the file is a collection of g-code macros that I didn't touch (though I commented out a couple of duplicate pause/unpause macros that probably explain why I had the odd print pause due to a runout sensor triggering).

eager vale
#

The #*# section

fringe delta
#

Below those macros this is what it looks like:

#
[gcode_macro LOAD_FILAMENT]
description: Loads new filament into toolhead
gcode:
    {% set EXTRUDER_TEMP = params.TEMP|default(230)|int %}
    {% set MIN_TEMP = params.TEMP|default(230)|float * 0.98 %}
    {% set CURRENT_TARGET = printer.extruder.target|float %}
    FRONT                       ; move the toolhead to the front
    {% if EXTRUDER_TEMP != 0 %}
    _LOGO_PENDING
    {% if CURRENT_TARGET < EXTRUDER_TEMP %}
    M104 S{EXTRUDER_TEMP} ; only heat up if the current extruder is not already hot
    {% endif %}
    TEMPERATURE_WAIT SENSOR="extruder" MINIMUM={MIN_TEMP} ; wait for min extrude temp to reach
    {% endif %}
    _LOGO_READY
    _HEADLIGHT_ON
    M83                         ; set extruder to relative mode
    G1 E50 F300                 ; extrude slowlyL
    G1 E50 F300
    M400                        ; wait for moves to finish
    M117 Load Complete!
    _LOGO_OFF
    _HEADLIGHT_OFF
    
    #*# <---------------------- SAVE_CONFIG ---------------------->
    #*# DO NOT EDIT THIS BLOCK OR BELOW. The contents are auto-generated.
    #*#
    #*# [heater_bed]
    #*# control = pid
    #*# pid_kp = 48.944
    #*# pid_ki = 2.913
    #*# pid_kd = 205.566
    #*#
    #*# [extruder]
    #*# control = pid
    #*# pid_kp = 25.319
    #*# pid_ki = 2.722
    #*# pid_kd = 58.868
    #*#
    #*# [probe]
    #*# z_offset = -1.070
    #*#
    #*# [bed_mesh default]
    #*# version = 1
    #*# points =
    #*#     0.003750, -0.007500, -0.010000, 0.005000, 0.003750
    #*#     0.033750, 0.023750, 0.032500, 0.016250, 0.007500
    #*#     0.023750, 0.000000, 0.005000, 0.012500, -0.008750
    #*#     0.017500, 0.017500, 0.027500, 0.003750, -0.030000
    #*#     0.007500, 0.036250, 0.051250, 0.022500, -0.001250
    #*# x_count = 5
    #*# y_count = 5
    #*# mesh_x_pps = 2
    #*# mesh_y_pps = 2
    #*# algo = bicubic
    #*# tension = 0.2
    #*# min_x = 40.0
    #*# max_x = 310.0
    #*# min_y = 40.0
    #*# max_y = 310.0
#

There is nothing else below this.

eager vale
#

Not even blank lines?

#

One other thing is puzzling me

fringe delta
#

A total of three blank lines (looks like discord trimmed them while I was wrestling with the message limits)

eager vale
#

In your snippet there, it looks like your #*# lines are indented

#

iirc, the #*# characters should be ...not indented. The first # should literally be the first char of the line

#

I'd also delete 2 of those blank lines at the end

#

And make sure there aren't any spaces or anything in the one you leave

fringe delta
#

They are in fact indented. I'll go fix that now

#

And the extra lines

eager vale
#

Hopefully that'll be enough to get that section loading again

#

Klipper is...touchy...about it. That's why it tells you not to mess with it. Lots of things that you'd never expect to be a problem are enough to make it go nuts

fringe delta
#

Well, two things:

First, it didn't fix it, but it did change the error message to complaining about max_velocity instead, so I think you are absolutely on the right track.

Second, I noticed while deleting the indents, that my errors "skipped" over the extruder section. Back when I thought it was in the heater_bed section proper, and was uncommenting those, it jumped to the z_offset in the [probe] section, ignoring the [extruder] section. I don't know if that is actually informative, though.

eager vale
#

Uh...that's weird

#

Can you just upload the printer.cfg itself?

#

Forget all this snippet-ing and just show me the whole thing...

fringe delta
#

Digging around, it looks like max_velocity is just straight up gone from the printer.cfg file?

eager vale
#

It does

#

I'm confused how that would have happened

#

But then, I'm also unclear on how all that other stuff got indented

#

So.... 🤷

#

The max velocity error does seem to be just what it appears to be though...

fringe delta
#

Is there a way to re-run input shaping with printer.cfg borked?

#

Digging through the github backups, it looks like I might have the original data there-ish. Thankfully, I got the backup manually running via terminal commands prior to messing with any macros to trigger it, and did one full backup there.

#

So I guess I could just manually copy over the original data?

eager vale
#

Yep, I'd just do that

fringe delta
#

Alright, time to go line-by-line, and figure out what else this scripted decided to just... straight up eat (I guess?)

eager vale
#

Alternatively, could you just replace the whole file with the intact one from github?

fringe delta
#

Not sure. I can see all the plain-text FROM-TO edits, but the macro that pushes all changes to github with each file change works just fine... so unless there is a way to pull and old version of the entire file, it would seem to be gone. Because right now, its not versioning pushes, just... pushing.

#

The irony of backup software is the root cause for needing the backup in the first place.

#

Once its no longer FUBAR, next missing is figuring out how to make this script do some kind of versioning.

eager vale
#

The entire point is that you can retrieve every version that has ever been there

#

I'm on mobile right now, so it looks a little different

#

But when you're in the diff

#

Hit this thing

#

And it'll take you the files, as of that commit

#

And then you can just browse through, find the printer.cfg, and download it normally

#

And yes. I have many questions about how a backup tool managed to create this much chaos

fringe delta
#

Oh, very helpful! I had only used git previously to push version of the grad papers to, and that was just a whole LaTeX folder, once a day, so it was simple to keep an eye on the changes. So I am not super familiar with all the ins and out of git.

#

On a more on-topic note: whatever added those few indents to the end of the file added them all over the place and haphazardly.

eager vale
#

You can also grab that commit id and do things like git reset --hard the_commit_id, and suddenly your whole directory reverts to that version

fringe delta
#

I am assuming these shouldn't be indented, either:

eager vale
#

Those should

#

But...all of them should

fringe delta
#

If I get truly desperate, I'll probably just roll everything back by copying the print.cfg back over.

eager vale
#

The non indented line is "aliases"

#

And all the rest of the exp stuff is the continuation of that thought

#

And thus, is indented

fringe delta
#

The stuff below it was commented out section for the displays that has obviously been indented. Not going to break anything, but definitely not the way I left it per github, so I was assuming that that area had been auto-indented, too.

#

And we have lift-off!

#

The last thing was it ate pretty much all of my input shapper code, and some of the neighboring thermistor code, too.

#

Thanks for all your help!

eager vale
fringe delta
#

It's the one everyone seems to be recommending, so idk what happened during the install.

#

I can't even wrap my head around how it could have edited files it was backing up. A push to GitHub should not have changed anything.

#

Only thing I can think of maybe Kiauh (or the packages that was installed via terminal) for some reason touched these files? They did automatically add some of the macros and .cfg files it needed, so it did have write permissions to those directories.

eager vale
#

most people around here that want to backup to github use eric zimmerman's scripts, as far as I know

#

I've never seen that other one before

#

(which isn't to say I know its bad either. just...wtf...)

#

I don't think I've ever seen kiauh edit the printer.cfg, fwiw

fair maple
fringe delta
#

Yeah, I'm thinking it's a weird bug in the backup code.

But as far as I can tell, it only happens during the initial setup. I haven't gone over my backup line-by-line, but it also hasn't changed anything else live on my printer, either.

fair maple
#

I didn't run that feature of kiauh but did update things with it. Luckily I had my printer.cfg tracked by git but my recent updates weren't committed so I'm going through the diff manually to see exactly how messed up it got

fair maple
#

looks like kiauh DOES update printer.cfg
it added [include shell_command.cfg] along with the other indents

fringe delta
# fair maple What's "ate my code" mean i nthis context? did it delete blocks?

Literally just straight up deleted it. All the input shaper values were just gone. Only reason I noticed is because after I noticed things were changed on the printer during the initial backup, I went over everything on GitHub, line-by-line, and looked at all the reported changes. Most were added or deleted blank lines; some were changed indents; but input shaper was just completely deleted on the printer.

Strangely, all the original code before the initial backup was run, was uploaded to GitHub without modification in the very first backup. It was only the code on the printer that was modified between the first and second backup and then this modified uploaded to GitHub. That's how I found it the first time

#

It's a really strange bug.

#

But, it's yet to change anything else on the printer. But I really do need to go over my GitHub commits and see if anyone else changed during each commit that wasn't supposed to change.