Différences entre versions de « Rasp-Hack-Afficheur-LCD-InitScript »

De MCHobby - Wiki
Sauter à la navigation Sauter à la recherche
Ligne 2 : Ligne 2 :
  
 
{{bloc-etroit
 
{{bloc-etroit
   |text= It's all fine and dandy to have a script like ''Adafruit_CharLCD_IPclock_example.py''  which we can manually run, but wouldn't it be nice to have the time and ip address pop up on the display when the raspberry pi boots up? This is done using a init script which runs the ''Adafruit_CharLCD_IPclock_example.py'' code on boot and kills it during system shut down.  
+
   |text= Disposer d'un script tel que ''Adafruit_CharLCD_IPclock_example.py''  à exécuter manuellement est pratique et élégant. Mais ne serait-il pas sympa d'avoir l'adresse IP et l'heure qui s'affiche automatiquement lorsque le Rapsberry-Pi boot?  
 +
 
 +
Cela est réalisé à l'aide d'un '''script init''' qui exécutera le code ''Adafruit_CharLCD_IPclock_example.py'' durant le boot et qui l'arrêtera (kill) au moment du Shutdown.  
 
}}
 
}}
  
Paste this code into '''/etc/init.d/lcd'''
+
Collez le code suivant dans '''/etc/init.d/lcd'''
  
(you will need to use sudo to write to this directory)  
+
(vous aurez besoin d'utiliser sudo pour écrire dans ce répertoire)  
  
 
  <nowiki>### BEGIN INIT INFO
 
  <nowiki>### BEGIN INIT INFO
Ligne 43 : Ligne 45 :
 
</nowiki>
 
</nowiki>
  
You should change
+
Vous devriez adapter le nom de fichier
'''/home/pi/Adafruit-Raspberry-Pi-Python-Code/Adafruit_CharLCD/Adafruit_CharLCD_IPclock_example.py''' to where-ever you are actually keeping the IPclock python script
+
'''/home/pi/Adafruit-Raspberry-Pi-Python-Code/Adafruit_CharLCD/Adafruit_CharLCD_IPclock_example.py''' pour indiquer l'endroit exacte pù vous avez placez/enregistré le script Python IPclock
  
Make the init script executable.
+
Rendez le script init exécutable.
  
 
  $ sudo chmod +x /etc/init.d/lcd
 
  $ sudo chmod +x /etc/init.d/lcd
  
Make the lcd init script known to the system by using the update-rc.d command.  
+
Utilisez la commande update-rc.d de sorte que le système sache qu'il y a un nouveau script init nommé "lcd".  
  
 
  $ sudo update-rc.d lcd defaults
 
  $ sudo update-rc.d lcd defaults
Ligne 56 : Ligne 58 :
 
[[Fichier:Rasp-Hack-Afficheur-LCD-init.jpg]]
 
[[Fichier:Rasp-Hack-Afficheur-LCD-init.jpg]]
  
Now on each boot the lcd will automatically show the date/time/ip address on startup. This means you will know when the pi is reachable and what the ip address is without having to plug a monitor in.  
+
Maintenant, à chaque fois que vous booterez/démarrez votre Pi, l'afficheur LCD montrera automatiquement la date/heure/adresse IP .  
 +
 
 +
Cela vous permettra également de savoir si votre Pi est disponible sur le réseau et à quelle adresse IP sans avoir besoin de connecter un moniteur.  
  
 
{{Rasp-Hack-Afficheur-LCD-TRAILER}}
 
{{Rasp-Hack-Afficheur-LCD-TRAILER}}

Version du 30 janvier 2013 à 12:22

Disposer d'un script tel que Adafruit_CharLCD_IPclock_example.py à exécuter manuellement est pratique et élégant. Mais ne serait-il pas sympa d'avoir l'adresse IP et l'heure qui s'affiche automatiquement lorsque le Rapsberry-Pi boot?

Cela est réalisé à l'aide d'un script init qui exécutera le code Adafruit_CharLCD_IPclock_example.py durant le boot et qui l'arrêtera (kill) au moment du Shutdown.

Collez le code suivant dans /etc/init.d/lcd

(vous aurez besoin d'utiliser sudo pour écrire dans ce répertoire)

### BEGIN INIT INFO
# Provides: LCD - date / time / ip address
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Liquid Crystal Display
# Description: date / time / ip address
### END INIT INFO


#! /bin/sh
# /etc/init.d/lcd


export HOME
case "$1" in
    start)
        echo "Starting LCD"
        /home/pi/Adafruit-Raspberry-Pi-Python-Code/Adafruit_CharLCD/Adafruit_CharLCD_IPclock_example.py  2>&1 &
    ;;
    stop)
        echo "Stopping LCD"
	LCD_PID=`ps auxwww | grep Adafruit_CharLCD_IPclock_example.py | head -1 | awk '{print $2}'`
	kill -9 $LCD_PID
    ;;
    *)
        echo "Usage: /etc/init.d/lcd {start|stop}"
        exit 1
    ;;
esac
exit 0

Vous devriez adapter le nom de fichier /home/pi/Adafruit-Raspberry-Pi-Python-Code/Adafruit_CharLCD/Adafruit_CharLCD_IPclock_example.py pour indiquer l'endroit exacte pù vous avez placez/enregistré le script Python IPclock

Rendez le script init exécutable.

$ sudo chmod +x /etc/init.d/lcd

Utilisez la commande update-rc.d de sorte que le système sache qu'il y a un nouveau script init nommé "lcd".

$ sudo update-rc.d lcd defaults

Rasp-Hack-Afficheur-LCD-init.jpg

Maintenant, à chaque fois que vous booterez/démarrez votre Pi, l'afficheur LCD montrera automatiquement la date/heure/adresse IP .

Cela vous permettra également de savoir si votre Pi est disponible sur le réseau et à quelle adresse IP sans avoir besoin de connecter un moniteur.


Source: Character LCD with Raspberry Pi or BeagleBone Black écrit par Tony Dicola pour Adafruit Industries.

Traduit avec l'autorisation d'AdaFruit Industries - Translated with the permission from Adafruit Industries - www.adafruit.com

Toute référence, mention ou extrait de cette traduction doit être explicitement accompagné du texte suivant : «  Traduction par MCHobby (www.MCHobby.be) - Vente de kit et composants » avec un lien vers la source (donc cette page) et ce quelque soit le média utilisé.

L'utilisation commercial de la traduction (texte) et/ou réalisation, même partielle, pourrait être soumis à redevance. Dans tous les cas de figures, vous devez également obtenir l'accord du(des) détenteur initial des droits. Celui de MC Hobby s'arrêtant au travail de traduction proprement dit.