SheevaPlug.de

Die deutschsprachige Plug Community.

  • Schrift vergrößern
  • Standard-Schriftgröße
  • Schriftgröße verkleinern
Startseite Anleitungen NSLU2 USB Steckdose von Gembird steuern

USB Steckdose von Gembird steuern

E-Mail Drucken

NSLU - Master/Slave USB Steckdose von Gembird

Um die Steckdosenleiste komfortabel per Browser steuern zu können, kann das Tool SYSPMCTL installiert werden, das das Schalten einzelner Steckdosen per Webif ermöglicht.

libusb installieren

(erforderlich)


1. Download des letzten sourcecode Release auf http://libusb.wiki.sourceforge.net/
z.B. libusb-0.1.12

2. Entpacken mit

tar xzvf libusb-0.1.12.tar.gz

3. In entpacktes Verzeichniss wechseln
cd libusb-0.1.12

4. Konfigurieren
./configure

5. Dann
make

6. Zuletzt
make install

 

SIS-PM installieren

(libusb Installation muss vorher abgeschlossen sein):
Quelle:http://sispmctl.sourceforge.net/#mozTocId127686

tar xzvf sispmctl-2.7.tar.gz
cd sispmctl-2.7
./configure
make
make install


Starten mit Webserver:
/usr/local/bin/sispmctl -l

Zugriff per Browser:
http://NSLU_IP:2638/index.html

Socket Beschriftungen ändern

Im Webfrontend sind die Sockets einfach durchnummeriert (Socket 1, Socket 2...).
Das kann man ändern indem man die index.html entsprechend anpasst.
jed /usr/local/share/httpd/sispmctl/doc/index.html


Autostart einrichten

Folgendes Skript "steckdose.sh" in /etc/init.d/ legen und anpassen.
Damit es beim Hochfahren ausgeführt wird z.B. per Webmin aktivieren (unter System - Bootup and Shutdown).

#! /bin/sh

# PATH should only include /usr/* if it runs after the mountnfs.sh script

PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin

DESC="sispmctl"
NAME="sispmctl"
DAEMON=/usr/local/bin/sispmctl
# run webserver
DAEMON_ARGS="-l"
PIDFILE=/var/run/$NAME.pid
SCRIPTNAME=/etc/init.d/steckdose.sh
#the user that will run the script
USER=root

# NO NEED TO MODIFY THE LINES BELOW

# Load the VERBOSE setting and other rcS variables
. /lib/init/vars.sh

# Define LSB log_* functions.
# Depend on lsb-base (>= 3.0-6) to ensure that this file is present.
. /lib/lsb/init-functions

#
# Function that starts the daemon/service
#
do_start()
{

#start-stop-daemon --start --chuid $USER -m -p $PIDFILE --exec $DAEMON -- $DAEMON_ARGS \
#|| return 2

#start-stop-daemon -b --start --quiet -m -p $PIDFILE --chuid $USER --exec $DAEMON -- $DAEMON_ARGS \
start-stop-daemon --start --quiet --chuid $USER -m -p $PIDFILE --exec $DAEMON -- $DAEMON_ARGS \
|| return 2
}

#
# Function that stops the daemon/service
#
do_stop()
{
start-stop-daemon --stop --quiet --oknodo --pidfile $PIDFILE
RETVAL="$?"
rm -f $PIDFILE
return "$RETVAL"
}

case "$1" in
start)
[ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
do_start
case "$?" in
0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
esac
;;
stop)
[ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
do_stop
case "$?" in
0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
esac
;;
restart)
#
# If the "reload" option is implemented then remove the
# 'force-reload' alias
#
log_daemon_msg "Restarting $DESC" "$NAME"
do_stop
case "$?" in
0|1)
do_start
case "$?" in
0) log_end_msg 0 ;;
1) log_end_msg 1 ;; # Old process is still running
*) log_end_msg 1 ;; # Failed to start
esac
;;
*)
# Failed to stop
log_end_msg 1
;;
esac
;;
*)
echo "Usage: $SCRIPTNAME {start|stop|restart}" >&2
exit 3
;;
esac

:

Skript testen:
sh /etc/init.d/steckdose.sh start

Skript zum Aus- und Einschalten der NSLU2

(funktioniert nur mit usb autopowermod)

nslu2.sh start bzw. stop

    #!/bin/sh

#PowerPort an den die NSLU2 angeschlossen ist
port="1"
#PowerPort an den Zubehör angeschlossen ist
attach="2"
#IP-Adresse der NSLU2
ip="192.168.178.77"

case "$1" in
'start')
# Ist die NSLU2 schon an?
# Wenn nicht einschalten!
s1=`sispmctl -g $port | grep on`
if [ -z "$s1" ]
then
echo NSLU2 einschalten
sispmctl -o $port
else
echo NSLU2 schon eingeschaltet
fi
;;
'stop')
# Ist die NSLU" schon aus?
s2=`sispmctl -g $port | grep on`
if [ -z "$s2" ]
then
echo NSLU2 ist bereits aus
else
echo NSLU2 herunterfahren
ssh $ip shutdown -h now
# Solange warten bis NSLU2 nicht mehr pingbar
s1=`ping -c 1 $ip | grep ttl`
while [ -n "$s1" ]
do
sleep 1
s1=`ping -c 1 $ip | grep ttl`
done
# Strom aus!
echo NSLU2 wird ausgeschaltet
sleep 5
sispmctl -f $port
fi
s3=`sispmctl -g $attach | grep on`
if [ -z "$s3" ]
then
echo Zubehör ist bereits aus
else
echo Zubehör wird ausgeschaltet
sismpctl -f $attach
fi

;;
esac
exit 0
Zuletzt aktualisiert am Mittwoch, den 15. April 2009 um 09:27 Uhr  
AddThis Social Bookmark Button