Creator of this extension is Arksine.
This is a brief explanation of how to use the shell command extension for Klipper, which you can install with KIAUH. After installing the extension you can execute linux commands or even scripts from within Klipper with custom commands defined in your printer.cfg.
cd ~
git clone https://github.com/th33xitus/kiauh.git
~/kiauh/kiauh.sh
4) [Advanced]
8) [G-Code Shell Command]
Aufruf : RUN_SHELL_COMMAND cmd=hello_world
[gcode_shell_command hello_world] command: echo hello world timeout: 2. verbose: True
Komplexere Kommandos können über eine eigene Shell gestartet werden und müssen in Hochkommata.
command: sh -c "ls -lR /dev/ | grep -v '\→\s../tty' | grep -e 'ttyalpha' -e serial"
Beispiel für Rechner:
expr 5 + 6
Beispiel Disk Free:
df -h
Aufruf: RUN_SHELL_COMMAND cmd=CmdSerial
[gcode_shell_command CmdSerial] command: sh -c "sudo /home/pi/shellcmd/serial.sh" timeout: 5. verbose: True
pi@Make-Voron2:~/shellcmd $ cat serial.sh #!/bin/sh ls -lR /dev/ | grep -v '\->\s../tty' | grep -e 'tty[[:alpha:]]' -e serial
Aufruf : RUN_SHELL_COMMAND cmd=CmdWLED PARAMS=50
Hinweis:
Mehrere Parameter müssen in Hochkommata angegeben werden und mit Leerzeichen getrennt.
RUN_SHELL_COMMAND cmd=CmdWLED params="50 40"
[gcode_shell_command CmdWLED] command: /home/pi/shellcmd/webservice.sh timeout: 5. verbose: True
pi@Make-Voron2:~/shellcmd $ cat webservice.sh #!/bin/sh echo "Call Webservice with : $1" curl -X GET "http://192.168.30.242/win/&IX=$1" curl -X GET https://httpbin.org/get?WLED=$1 #echo "$1" >> "/home/pi/shellcmd/test.txt"
Aufruf für WLED : http://192.168.30.242/win/&IX=100
command: sh -c "curl -X GET 'http://192.168.30.242/win/&IX=50'"
curl -X GET 'http://192.168.30.242/win/&IX=100'
[delayed_gcode testdelay] gcode: RUN_SHELL_COMMAND cmd=hello_world UPDATE_DELAYED_GCODE ID=testdelay DURATION=5
UPDATE_DELAYED_GCODE ID=testdelay DURATION=10
[delayed_gcode testdelay] initial_duration: 5. gcode: RUN_SHELL_COMMAND cmd=hello_world UPDATE_DELAYED_GCODE ID=testdelay DURATION=5
[delayed_gcode delayedled] initial_duration: 15. gcode: {% if printer.print_stats.state == 'printing' %} {% set val = printer.display_status.progress * 100 %} RUN_SHELL_COMMAND cmd=CmdWLED PARAMS={val} {% else %} M118 "Drucker inaktiv" {% endif %} UPDATE_DELAYED_GCODE ID=delayedled DURATION=15
WLED Control auch über
https://github.com/Gliptopolis/WLED_Klipper
Wenn Klipper nicht aktiv ist, können die GCode Shell Kommandos nicht gestartet werden!
Beispiel :
20:21 Pin 'xPE11' is not a valid pin name on mcu 'mcu' 20:21 Pin 'xPE11' is not a valid pin name on mcu 'mcu' Once the underlying issue is corrected, use the "RESTART" command to reload the config and restart the host software. Printer is halted 20:21 RUN_SHELL_COMMAND cmd=CmdSerial
Viel extra Ausgabe
20:12 sudo: a password is required 20:12 sudo: a terminal is required to read the password; either use the -S option to read from standard input or configure an askpass helper
printer.print_stats.state : complete
printer.print_stats.state : printing
printer.virtual_sdcard.progress : 0.06650429377548903
printer.display_status.progress : 0.1
{% if printer.heater_bed.target > 0.0 %} {% set temp = printer.heater_bed.target %} {% else %} {% set temp = printer.configfile.config.heater_bed.max_temp %} {% endif %}
[gcode_shell_command hello_world] command: echo hello world timeout: 2. verbose: True