Jump to content
View in the app

A better way to browse. Learn more.

Tinkerunity

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Geschrieben

Hallo,

 

ich möchte das der RGB LED Button beim Starten/Herunterfahren des Bricks seine Farbe wechselt (On=White, Off=Schwarz).

Ein entsprechendes Start/Stop-Script habe ich im /etc/init.d angelegt und mittels "update-rc.d SCRIPT defaults" die erforderlichen S* und K* Links in den rc*.d-Ordnern erzeugt.

 

Beim Starten funktioniert das ganze auch wie gewünscht, aber beim Shutdown wird das Script scheinbar überhaubt nicht aufgerufen - die LED bleibt im letzten Status und auch das im Script eingebaute Log-File wird nicht geschrieben (beim starten funktioniert´s).

 

Auch der Versuch mittels "chkconfig" und dem Erzeugen eines lock-Files (/var/lock/subsys/) hat hier nicht zum Erfolg geführt.

 

Hat jemand eine Idee was ich noch versuchen kann?

 

 

Geschrieben

Ist die Reihenfolge korrekt: Skript wird beim Shutdown aufgerufen, bevor der brickd runtergefahren wird und USB deaktiviert wird?

 

Beim Shutdown geht alles sehr schnell. Theoretisch auch möglich, dass sofort nach dem Skript der brickd gekillt wird -> ggf. mal einen "sleep 1" ins Skript mit aufnehmen.

 

Und um zu testen, ob das Skript aufgerufen wird mal ein "echo DONE > /home/tf/script_called" oder so ähnlich.

Geschrieben
  • Autor

Das Shutdown-Skript (Links unter /etc/rcX.d/K*) zum "Ausschalten" der LED hatte wurde testweise zu verschiedenen Zeiten aufgerufen.

Im Script ist ein ein Logging eingebaut, das beim Starten ebenso eine Nachricht in ein Logfile schreibt wie beim Beenden. Beim Aufruf "per Hand" wird das Logfile entsprechend weitergeschrieben, beim herunterfahren gibt es keine Nachricht im Logfile.

 

Aktueller Stand des Scripts:

#!/bin/sh

### BEGIN INIT INFO
# Provides:          set_RGB_white
# Required-Start:    $all
# Required-Stop:     $remote_fs $syslog
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: set RGB
# Description:       set RGB to white at boot time / to black at shutdown
### END INIT INFO

dir="/home/tf"
cmdboot="./set_RGB_bricklet_white.sh"
cmdshut="./set_RGB_bricklet_black.sh"
testlog="/var/log/RGB_on_off.log"
DATE=`date`
status_runlevel=`runlevel`
lockfile="/var/lock/subsys/$0"

case "$1" in
    start)
touch $lockfile
        echo "$DATE RGB_on_of start" >> $testlog
echo "Runlevel: $status_runlevel" >> $testlog
        cd "$dir"
        sudo $cmdboot
echo "---White---" >> $testlog
        exit 1
    ;;
    stop)
        echo "$DATE RGB_on_off stop" >> $testlog
        echo "Runlevel: $status_runlevel" >> $testlog
cd "$dir"
        sudo $cmdshut
        echo "---Black---" >> $testlog
rm -f $lockfileexit 1
    ;;
*)
        echo "Usage: $0 {start|stop}"
        exit 1
    esac

exit 0

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Gast
Reply to this topic...

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.