Ik ben bezig met een startup script voor mijn Raspberry Pi die draait op Rasbian zonder GUI. Hiervoor heb ik twee scriptjes gemaakt om te testen of mijn idee werkt.
Het eerste script in init.d is gebaseerd op:
http://www.stuffaboutcode...-program-at-start-up.html
Script 1 staat in /etc/init.d en heet StartUpScript.
Script 2 staat in /home/pi en heet test.py:
De StartUpScript start automatisch op wanneer ik de Pi aanzet en zorgt er voor dat het tweede script start. Het tweede script zal ik later vervangen worden door verschillende commando's om de camera te besturen. Het probleem is nu echter dat dit tweede script (test.py) anders reageert wanneer ik hem handmatig start of via het andere script mee laat starten tijdens het booten.
Wanneer ik test.py via de commandline start kan ik hem stoppen via ctrl c, echter wanneer ik hem open via mijn andere script dan werkt mijn interurrupt niet meer. Met als gevolg dat ik niet door kan starten naar mijn user loginscherm van de pi. hij blijft dus in de testing loop hangen.
Het eerste script in init.d is gebaseerd op:
http://www.stuffaboutcode...-program-at-start-up.html
Script 1 staat in /etc/init.d en heet StartUpScript.
Bash: StartUpScript
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
| #! /bin/sh # /etc/init.d/StartUpScript ### BEGIN INIT INFO # Provides: StartupPAI # Required-Start: $remote_fs $syslog # Required-Stop: $remote_fs $syslog # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: Script to start PAI Cameraprogram at boot # Description: Startup script that allows the Pi to load the camerasettings and timeframe for capturing hemispherical photos for calculating PAI of a forrest. ### END INIT INFO # Carry out specific functions when asked to by the system case "$1" in start) echo "Starting PAI timeseries" # run application you want to start sudo python /home/pi/test.py & ;; stop) echo "Stopping noip" # kill application you want to stop killall test.py ;; *) echo "Usage: /etc/init.d/timeseries.py {start|stop}" exit 1 ;; esac exit 0 |
Script 2 staat in /home/pi en heet test.py:
Python: test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
| test = True try: while test == True: testtekst = "test complete" print "testing" except KeyboardInterrupt: test = False print "loop Stopped" |
De StartUpScript start automatisch op wanneer ik de Pi aanzet en zorgt er voor dat het tweede script start. Het tweede script zal ik later vervangen worden door verschillende commando's om de camera te besturen. Het probleem is nu echter dat dit tweede script (test.py) anders reageert wanneer ik hem handmatig start of via het andere script mee laat starten tijdens het booten.
Wanneer ik test.py via de commandline start kan ik hem stoppen via ctrl c, echter wanneer ik hem open via mijn andere script dan werkt mijn interurrupt niet meer. Met als gevolg dat ik niet door kan starten naar mijn user loginscherm van de pi. hij blijft dus in de testing loop hangen.
"Each event is preceded by Prophecy. But without the hero, there is no Event." - Zurin Arctus, the Underking | "Ad Nocendum Potentes sumus." - Me, 30 November 1999