Bouton ON / OFF / Reboot
-
Merci l'ami, j'essaie sa ce soir.
-
Moi j'ai juste connecté un bouton (le même que sur les bornes d'arcade) sur 2 pins du gpio et je peux allumer sans problème et rebooter mon pi2. Pour l’éteindre je le fais par le menu, c'est bien plus simple et aucun besoin de trifouiller dans des lignes de codes.
-
Bon pas reussis mais j'abandonne pas... Error :
ATXRaspi shutdown script started: asserted pins (7=input,LOW; 8=output,HIGH). Waiting for GPIO7 to become HIGH... sleep: invalid number '0.02' /etc/init.d/shutdowncheck.sh: line 35: 1427321809%N-1427321809%N: division by 0 (error token is "N-1427321809%N")
-
Bonjour J'ai modifié la fin de ton script et j'ai ajouté un script pour que ça tourne en "service" je ne sais pas si ça te sera utile. J'ai supprimé aussi la commande sudo car tu es déjà en root dans recalbox J'ai supprimé la derniere ligne du sed ne sachant pas vraiement à quoi elle sert. essaie ceci : shutdowncheck.sh
echo '#!/bin/bash #This is GPIO 7 (pin 26 on the pinout diagram). #This is an input from ATXRaspi to the Pi. #When button is held for ~3 seconds, this pin will become HIGH signalling to this script to poweroff the Pi. SHUTDOWN=7 REBOOTPULSEMINIMUM=200 #reboot pulse signal should be at least this long REBOOTPULSEMAXIMUM=600 #reboot pulse signal should be at most this long echo "$SHUTDOWN" > /sys/class/gpio/export echo "in" > /sys/class/gpio/gpio$SHUTDOWN/direction #Added reboot feature (with ATXRaspi R2.6 (or ATXRaspi 2.5 with blue dot on chip) #Hold ATXRaspi button for at least 500ms but no more than 2000ms and a reboot HIGH pulse of 500ms length will be issued #This is GPIO 8 (pin 24 on the pinout diagram). #This is an output from Pi to ATXRaspi and signals that the Pi has booted. #This pin is asserted HIGH as soon as this script runs (by writing "1" to /sys/class/gpio/gpio8/value) BOOT=8 echo "$BOOT" > /sys/class/gpio/export echo "out" > /sys/class/gpio/gpio$BOOT/direction echo "1" > /sys/class/gpio/gpio$BOOT/value echo "ATXRaspi shutdown script started: asserted pins ($SHUTDOWN=input,LOW; $BOOT=output,HIGH). Waiting for GPIO$SHUTDOWN to become HIGH..." #This loop continuously checks if the shutdown button was pressed on ATXRaspi (GPIO7 to become HIGH), and issues a shutdown when that happens. #It sleeps as long as that has not happened. while [ 1 ]; do shutdownSignal=$(cat /sys/class/gpio/gpio$SHUTDOWN/value) if [ $shutdownSignal = 0 ]; then /bin/sleep 0.2 else pulseStart=$(date +%s%N | cut -b1-13) # mark the time when Shutoff signal went HIGH (milliseconds since epoch) while [ $shutdownSignal = 1 ]; do /bin/sleep 0.02 if [ $(($(date +%s%N | cut -b1-13)-$pulseStart)) -gt $REBOOTPULSEMAXIMUM ]; then echo "ATXRaspi triggered a shutdown signal, halting Rpi ... " poweroff exit fi shutdownSignal=$(cat /sys/class/gpio/gpio$SHUTDOWN/value) done #pulse went LOW, check if it was long enough, and trigger reboot if [ $(($(date +%s%N | cut -b1-13)-$pulseStart)) -gt $REBOOTPULSEMINIMUM ]; then echo "ATXRaspi triggered a reboot signal, recycling Rpi ... " reboot exit fi fi done' > /recalbox/scripts/shutdowncheck.sh chmod 775 /recalbox/scripts/shutdowncheck.sh
Création du service à nommer S92shutdownService et à placer dans
/etc/init.d/
#!/bin/bash ### BEGIN INIT INFO # Provides: shutdowncheck.sh # Required-Start: $network $local_fs $remote_fs # Required-Stop: $network $local_fs $remote_fs # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: switch init script. # Description: Starts and stops shutdowndeamon service. ### END INIT INFO #VAR RUN="/recalbox/scripts/shutdowncheck.sh" BTD_PID=$(ps -eo pid,command | grep "/bin/bash $RUN" | grep -v grep | awk '{print $1}') serviceStatus() { if [ ! -z "$BTD_PID" ]; then echo -e '33[0mservice shutdowncheck.sh ['$BTD_PID'] [33[33;32m OK 33[0m]' else echo -e '33[0mservice shutdowncheck.sh [33[33;31m KO 33[0m]' fi } # Carry out specific functions when asked to by the system case "$1" in start) echo "Starting script $RUN ..." if [ -z "$BTD_PID" ]; then nice -n 19 $RUN& if [ $? -eq 0 ]; then echo -e "33[0mscript $RUN [33[33;32m STARTED 33[0m]" fi else echo "script $RUN already started ['$BTD_PID']!" fi #serviceStatus ;; stop) echo "Stopping script $RUN ..." if [ ! -z "$BTD_PID" ]; then kill $BTD_PID if [ $? -eq 0 ]; then echo -e "33[0mscript $RUN [33[33;31m STOPPED 33[0m]" fi fi #serviceStatus ;; status) serviceStatus ;; *) echo "Usage: /etc/init.d/S92shutdownService {start | stop | status}" exit 1 ;; esac exit 0
chmod 777 /etc/init.d/S92shutdownService
Ensuite tester :/etc/init.d/S92shutdownService start /etc/init.d/S92shutdownService stop /etc/init.d/S92shutdownService status
Tiens nous au courant
-
Bonjour, Du coup cette méthode fonctionne correctement ? Merci.
-
Désolé j'ai pas eu le temps de tester, j'ai refait entièrement ma salle à manger et cuisine. N'était plutôt hard que soft lol. Je mis remet cet semaine je pense.
-
Bonjour, D'accord bah tiens nous au courant dès que tu as fait ça. de mon côté si j'ai le temps je vais essayé aussi. Merci.
-
Salut Acris encore desole du temp de reponse, gros travaux chez moi... Donc je viens de faire laisser cela marche tres bien juste une corrections dans ton script .
Tu as mis : done' > /recalbox/script/shutdowncheck.sh chmod 755 /recalbox/script/shutdowncheck.sh Et il fallait : done' > /recalbox/scripts/shutdowncheck.sh chmod 755 /recalbox/scripts/shutdowncheck.sh
De plus le shutdown ne se fait pas à 3 seconde mais à 7 et le reboot à 8 ! Bizarre je regarderais plus tard.
-
Bonjour dans le script il est noté en haut : et si j ai bien compris le reboot se fait entre 3 et 10 secondes non ?
#When button is held for ~3 seconds, this pin will become HIGH signalling to this script to poweroff the Pi. SHUTDOWN=7 REBOOTPULSEMINIMUM=200 #reboot pulse signal should be at least this long REBOOTPULSEMAXIMUM=600 #reboot pulse signal should be at most this long echo "$SHUTDOWN" > /sys/class/gpio/export echo "in" > /sys/class/gpio/gpio$SHUTDOWN/direction
Pour les autres, j ai uploadé les scripts Via putty in SSH : login (root) / password (recalboxroot)
wget https://app.box.com/s/79104q7bwlzdvgjt1fjlsf9h7ktmsp3g bash setup.sh wget https://app.box.com/s/uz3sp9ya0ls2e6w825w26slpspeqno0m cp ~/S92shutdownService /etc/init.d/ chmod 775 /etc/init.d/S92shutdownService reboot
-
<pre id="tw-target-text" class="tw-data-text vk_txt tw-ta tw-text-small" dir="ltr" style="unicode-bidi: isolate; font-family: inherit; border: none; padding: 0px 0.14em 0px 0px; position: relative; margin-top: 0px; margin-bottom: 0px; resize: none; overflow: hidden; width: 237.5px; white-space: pre-wrap; word-wrap: break-word; color: #212121; height: 288px;" data-placeholder="Tradução" data-fulltext=""><span lang="en">Hello personal , okay ? Unfortunately i do not speak French . Me parece que managed you create script To turn the rasp . Could provide OS Files paragraph download? I could not understand abcos**tamente Nothing Francisca . Thank you and sorry for the inconvenience . Beto .</span>