Hallo,
ich habe einen Raspberry B und einen Raspberry Zero W und diese kommunizieren
miteinander über UDP. Das funktioniert auch einwandfrei, allerdings bekomme ich es nicht
hin, das Programm auf dem Zero per Autostart zu starten.
Ich habe es genau so gemacht wie auf dem Raspberry B:
Erste Zeile im Programm: #!/usr/bin/env python
Der Eintrag in der rc.local: /bin/sleep 180 && /home/pi/LS_s.py &
Und die Datei startbar gemacht: sudo chmod +x /home/pi/LS_s.py
Starte ich die rc.local kommen folgende Fehlermeldungen:
Code
pi@raspberrypi:~ $ sudo sh -vx /etc/rc.local
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.
# Print the IP address
_IP=$(hostname -I) || true
+ hostname -I
+ _IP=192.168.178.51
if [ "$_IP" ]; then
printf "My IP address is %s\n" "$_IP"
fi
+ [ 192.168.178.51 ]
+ printf My IP address is %s\n 192.168.178.51
My IP address is 192.168.178.51
#python /home/pi/LS_s.py &
/bin/sleep 180 && /home/pi/LS_s.py &
exit 0
+ exit 0
+ /bin/sleep 180
pi@raspberrypi:~ $ + /home/pi/LS_s.py
/home/pi/LS_s.py: 1: /home/pi/LS_s.py: #!/usr/bin/env: not found
/home/pi/LS_s.py: 2: /home/pi/LS_s.py: import: not found
/home/pi/LS_s.py: 3: /home/pi/LS_s.py: import: not found
/home/pi/LS_s.py: 4: /home/pi/LS_s.py: import: not found
/home/pi/LS_s.py: 6: /home/pi/LS_s.py: Syntax error: "(" unexpected
pi@raspberrypi:~ $
Alles anzeigen
Das ist das Programm:
Code
#!/usr/bin/env python
import telepot
import picamera
import socket
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
bot = telepot.Bot('XXXXXXXXXXXXXXXXXXXXXXXX')
chat_id = 481869349
BUFSIZE = 1024
s.bind(("", 50000))
cam = picamera.PiCamera()
cam.resolution = (1280, 1024)
cam.start_preview()
try:
while True:
daten, addr = s.recvfrom(1024)
#print "[%s] %s" % (addr[0], daten)
#cam = picamera.PiCamera()
#cam.resolution = (1280, 1024)
#cam.start_preview()
cam.capture('bild.jpg')
#cam.close()
#bot.sendMessage(chat_id, 'Hier ist der Zero!')
image_path = open('/home/pi/bild.jpg', 'rb')
bot.sendPhoto(chat_id, image_path)
finally:
s.close() # Socket schließen
cam.close()
Alles anzeigen
Ist nicht schön, läuft aber tagelang ohne Probleme und tut, was es soll.
Woran könnte das liegen?
Gruß Reinhard