11chrisadams11 / Klipper-WS281x_LED_Status

Use WS281x LED strips with Klipper
52 stars 11 forks source link

Noob question - How to call/start the script before a print? #6

Closed ajscheid closed 2 years ago

ajscheid commented 2 years ago

Hi,

thank you for developing this, really great and works like a charm! But I have a bit of issues in starting the script before a print.

My idea was to start the script via a GCode shell command which I add to the start code of the slicer. Here a snip form my printer.cfg:

[gcode_shell_command led_off] command: sudo /home/pi/klipper_ledstrip.py 0 0 0 timeout: 2. verbose: True

[gcode_shell_command led_white] command: sudo /home/pi/klipper_ledstrip.py 255 255 255 timeout: 2. verbose: True

[gcode_shell_command status_led] command: sudo /home/pi/klipper_ledstrip.py timeout: 2. verbose: True

[gcode_macro LED_OFF] gcode: RUN_SHELL_COMMAND CMD=led_off

[gcode_macro LED_WHITE] gcode: RUN_SHELL_COMMAND CMD=led_white

[gcode_macro STATUS_LED] gcode: RUN_SHELL_COMMAND CMD=status_led

You note that I had to add sudo, which is per se not allowed for gcode shell command, but nevertheless LED_OFF and LED_WHITE is working with this setup. As soon as I run STATUS_LED the script gets loaded and led's are displaying standby but immediately Klipper shuts down with

Errno 1 Operation not permitted 19:23:49 // Klipper state: Shutdown 19:23:49 !! Internal error on command:"RUN_SHELL_COMMAND" 19:23:49 !! Internal error on command:"STATUS_LED"

Surely I am doing something wrong but like to understand​ what that would be and how to recify.

If I start the script via ssh everything runs fine using same command.

Sorry to misuse this; this is most probably not an issue with the script but with me not understanding what's actually going on....

ajscheid commented 2 years ago

Hi,

I clearly have a misunderstanding of usage of sudo; systemd service fails. Still trying to understand why though; manual start of the script with sudo ./klipper_ledstrip.py works like a charm but script does not get executed when running as systemd service.

Will dig further

ajscheid commented 2 years ago

Hi,

Will close this, Have realized the start of the script via a corn job for now. Be, aj