User Tools

Site Tools


klipper_faq:64_gcode_shell_commands

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
klipper_faq:64_gcode_shell_commands [2023/10/21 10:35] – removed - external edit (Unknown date) 127.0.0.1klipper_faq:64_gcode_shell_commands [2023/10/21 10:39] (current) – [YouTube Video #64] dominik
Line 1: Line 1:
 +====== G-Code Shell Commands ======
 +**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.
 +
 +===== YouTube Video #64 =====
 +{{youtube>qkn3Su7QCpk?half}}
 +
 +\\ 
 +
 +===== Installation Shell Erweiterung =====
 +  * ''cd ~''
 +  * ''git clone https://github.com/th33xitus/kiauh.git''
 +  * ''~/kiauh/kiauh.sh''
 +    * -> ''4) [Advanced]''
 +    * -> ''8) [G-Code Shell Command]''
 +
 +===== Beispiel - direktes Kommando =====
 +Aufruf : ''RUN_SHELL_COMMAND cmd=hello_world''
 +
 +<code>
 +[gcode_shell_command hello_world]
 +command: echo hello world
 +timeout: 2.
 +verbose: True
 +</code>
 +
 +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 'tty[[:alpha:]]' -e serial%%"%% ''
 +
 +Beispiel für Rechner: \\ 
 +''expr 5 + 6 ''
 +
 +Beispiel Disk Free: \\
 +''df -h''
 +===== Beispiel - Bash Script =====
 +
 +Aufruf: ''RUN_SHELL_COMMAND cmd=CmdSerial''
 +
 +<code | download>
 +[gcode_shell_command CmdSerial]
 +command: sh -c "sudo /home/pi/shellcmd/serial.sh"
 +timeout: 5.
 +verbose: True
 +</code>
 +
 +<code bash>
 +pi@Make-Voron2:~/shellcmd $ cat serial.sh
 +#!/bin/sh
 +
 +ls -lR /dev/ | grep -v '\->\s../tty' | grep -e 'tty[[:alpha:]]' -e serial
 +
 +</code>
 +===== Beispiel - Parameter übergeben =====
 +
 +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%%"%%''
 +
 +<code>
 +[gcode_shell_command CmdWLED]
 +command: /home/pi/shellcmd/webservice.sh
 +timeout: 5.
 +verbose: True
 +</code>
 +
 +<code bash>
 +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"</code>
 +
 +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' ''
 +===== Beispiel - Wiederkehrender Aufruf =====
 +  * Code 1x beim Start verzögert ausführen \\ <code>
 +[delayed_gcode testdelay]
 +gcode:
 +  RUN_SHELL_COMMAND cmd=hello_world
 +  UPDATE_DELAYED_GCODE ID=testdelay DURATION=5
 +</code>
 +    * Einmalig kann man den verzögerten GCode so starten : \\ ''UPDATE_DELAYED_GCODE ID=testdelay DURATION=10''  \\ Der läuft dann nach 10 Sekunden 1x !
 +    * Beim Start wird der Code auch ausgeführt!
 +  * Code immer alle x Sekunden neu starten (startet sofort mit dem Drucker!) \\ <color #ed1c24>ACHTUNG</color> : Läuft immer !! \\ <code>
 +[delayed_gcode testdelay]
 +initial_duration: 5.
 +gcode:
 +  RUN_SHELL_COMMAND cmd=hello_world
 +  UPDATE_DELAYED_GCODE ID=testdelay DURATION=5
 +</code>
 +  * Webservice immer wiederkehrend aufrufen, um einen Wert zu übergeben: \\ <code>
 +[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
 +</code>
 +    * Dazu muss natürlich wo oben beschrieben das Bash Script eingerichtet sein! 
 +
 +WLED Control auch über \\ https://github.com/Gliptopolis/WLED_Klipper
 +
 +===== Probleme =====
 +
 +==== Klipper nicht aktiv ====
 +Wenn Klipper nicht aktiv ist, können die GCode Shell Kommandos nicht gestartet werden! \\ Beispiel : <code>
 +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 </code>
 +
 +==== verbose: True ====
 +Viel extra Ausgabe :-) 
 +
 +
 +==== sudo ====
 +<code>
 +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
 +</code>
 +
 +===== Code Stuff für Prozente =====
 +
 +printer.print_stats.state : complete \\
 +printer.print_stats.state : printing \\
 +printer.virtual_sdcard.progress : 0.06650429377548903 \\
 +printer.display_status.progress : 0.1
 +
 +<code | download>
 +    {% if printer.heater_bed.target > 0.0 %}
 +        {%  set temp = printer.heater_bed.target %}
 +    {% else %}
 +        {% set temp = printer.configfile.config.heater_bed.max_temp %}
 +    {% endif %}
 +</code>
 +
 +===== Links =====
 +  * https://github.com/th33xitus/kiauh/blob/master/docs/gcode_shell_command.md
 +  * https://kno.wled.ge/basics/getting-started/
 +  * https://github.com/Aircoookie/WLED/releases
 +  * REST Test \\ https://resttesttest.com/
 +  * https://www.klipper3d.org/Command_Templates.html?h=delay#delayed-gcodes
 +  * https://klipper.discourse.group/t/example-search-printer-objects/164
 +  * Beispiel Coding \\ https://github.com/digitalninja-ro/klipper-neopixel/blob/master/led_progress.cfg
 +===== Example =====
 +<code>
 +[gcode_shell_command hello_world]
 +command: echo hello world
 +timeout: 2.
 +verbose: True
 +</code>
  

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki