Cannot get menu command to work on Raspberry Pi running repetier server 0.86.2

edited December 2017 in Repetier-Server
I've added a command to /var/lib/Repetier-Server/database/extcommands.xml, yet it doesn't work from the menu.  The bash script I'm calling works fine from the command prompt.  
       <command>
                <name>Switch Printer OFF</name>
                <execute>sudo /bin/bash /home/pi/switch_off.sh</execute>
                <confirm>Really switch off?</confirm>
       </command>
</config>
The server.log file shows that the external command has loaded.  The other menu options (reboot / shutdown) work fine.

What am I doing wrong?

Thanks.

Comments

  • For shutdown you have added

    repetierserver ALL=NOPASSWD: /sbin/shutdown

    in /etc/sudoers.d

    Did you add /bin/bash as well to that list?

  • No, I didn’t. I’ll try that later. Thanks
  • Repetier said:
    For shutdown you have added

    repetierserver ALL=NOPASSWD: /sbin/shutdown

    in /etc/sudoers.d

    Did you add /bin/bash as well to that list?

    Thank you!  That works fine now.
  • @Icarus care to share the contents of your switch_off.sh, I'm somewhat curious what you need to do here.

    @Repetier .. this inspired a "would be nice to have":
    Setup: my Printer, RasPi/Repetierserver and my PC share a power-strip with a "main-switch".
    If something's printing and I want to call it a day for me I usually shut down the PC, turn off the lights and leave the rest running.

    ... time passes ... print's done: to properly shut down the RasPi I've to either power up the PC (and wait...) just to fire up a browser to shutdown repetierserver and power down the PC again afterwards (or faff around with my smartphone which usually isn't at hand).

    So, the question is: is there a way to "connect back" from the printer's firmware (got a display with click-wheel here) to repetierserver to issue a "my dear server, please execute /sbin/shutdown"-command back to the RasPi?

    All the best for 2018!


    PS: opening http://repetier.com/ defaults to the server's apache-default-page right now, I don't think this is what you want.






  • @xBot150 Here's my switch_off.sh and python code.  Hope this helps......

    #!/bin/bash
    cd /home/pi/pyenergenie-master/src/
    sudo /usr/bin/python /home/pi/pyenergenie-master/src/switch_off.py
    sleep 5
    sudo shutdown -h now

    And the python code....

    # switch_off.py  18/12/201  PAD

    # Switches Energenie device "name" off
    # The name resides in file 'registry.kvs' after setting up device with setup.py

    import energenie
    #===== GLOBALS =====

    quit = False
    energenie.init()

    #===== INPUT METHODS ============================================

    try:
        readin = raw_input # Python 2
    except NameError:
        readin = input # Python 3

    device_index = 1
    name = 'SW1'
    device = energenie.registry.get(name)
    print (device)

    #===== ACTION ROUTINE =============================================

    device.turn_off()

    # END
  • @xBot150 ; I also meant to add that in my Slic3r printer settings end G-code I've got:

    M104 S0 ; turn off temperature
    M140 S0 ; turn off bed
    G92 Z0 ; relative
    G1 Z10 ; lift z
    G28 X Y ; home 
    M84     ; disable motors
    M400
    M400
    (Add about 30 more M400s here - removed in this forum post for clarity)
    M400
    M400
    @pushmessage switching power off
    @execute switchoff ; powers off printer.

    So, at the end of the print the bed homes and executes switch_off.sh script which powers off the printer, followed closely by switching off the Pi.
  • @Icarus ah... so you have n printers connected some kind of power-strip where you want to do...
    .. if print on deviceN has completed then
    ... lift the nozzle, move away the extruder from the print, (wait some time / M400...) and then send "cut the power for deviceN" to <another device>?

    cool & THX

    PS: being a native german speaker I don't even dare to think about the typo-potential of "energenie" :-D

  • @xBot150 ; I have the printer connected to the energenie socket and the Pi connected to a separate socket.  When the script is finished the printer is physically powered off and the Pi is just shutdown (but powered still).
  • No, there is no easy way for communicating a shutdown back from firmware. The only possible solution that currently is working is to add module written in lua that listens for firmware responses and then initiates the action.

    While the script would be very short it still requires some programming skills, so I consider it non trivial task.

    I wonder if it makes sense to add a general purpose answer like
    // run_script:Scriptname

    that forces server to execute a named script which can contain gcode or @execute commands for shutdown. So it would search for "Scriptname" and if found just inserts that script into gcode to send. Makes it easy to add some more complex things from frimware side without requirement to modify server.

  • edited July 2018
    Hello everyone. 
    I have same problem. 

    Script to turn on the printer

    #!/bin/bash
    if [ ! -d /sys/class/gpio/gpio17 ]
    then
      echo "17" > /sys/class/gpio/export
      sleep 1;
    fi
    echo "out" > /sys/class/gpio/gpio17/direction
    echo "1" > /sys/class/gpio/gpio17/value
    When I run it from console it works.
    In extcommands.xml 
    <execute>/var/lib/Repetier-Server/database/turnOnPrinter.sh</execute>
    I added /bin/bash to sudoers.d
    # echo "repetierserver ALL=NOPASSWD: /bin/bash" > /etc/sudoers.d/repetierserver-bash
    When I run external command nothing happens. Log says Starting external command /var/lib/Repetier-Server/database/turnOnPrinter.sh with 0 parameters. Tried
    <execute>sudo /var/lib/Repetier-Server/database/turnOnPrinter.sh</execute>
    with same result.
Sign In or Register to comment.