Diddyborg with PS3 and camera as its own wifi server on autorun at boot

I've got DiddyRed with Jessie on board to become its own wifi server so I can view the camera output and run MetalJoy.py or DiddyRedJoy without a problem away from home, I can SSH in and run DiddyRedJoy, use the Bluetooth PS3 etc all without issue.

My version runs just fine when started nmanually but not when set to run a boot

I have tried to get it to run my own version of DiddyRedJoy.py (mower02.py) at boot using systemd following the instructions at http://www.raspberrypi-spy.co.uk/2015/10/how-to-autorun-a-python-script-... and it starts at boot but seems to get stuck or stop before starting the Bluetooth loop

The PS3 still connects to the Pi but the python script seems to exit or stop?

Here is what I get when I run sudo systemctl status myscript.service after it boots

$ sudo systemctl status myscript.service
â myscript.service - My Script Service
   Loaded: loaded (/lib/systemd/system/myscript.service; enabled)
   Active: inactive (dead) since Wed 2016-11-09 20:06:32 GMT; 58s ago
  Process: 721 ExecStart=/usr/bin/python /home/pi/MBORG/mower02.py > /home/pi/mower02.log 2>&1 (code=killed, signal=HUP)
 Main PID: 721 (code=killed, signal=HUP)

Nov 09 20:06:26 Mower2 systemd[1]: Started My Script Service.
Nov 09 20:06:32 Mower2 python[721]: Loading PicoBorg Reverse on bus 1, address 0A
Nov 09 20:06:32 Mower2 python[721]: Found PicoBorg Reverse at 0A
Nov 09 20:06:32 Mower2 python[721]: PicoBorg Reverse loaded on bus 1
Nov 09 20:06:32 Mower2 python[721]: Loading PicoBorg Reverse on bus 1, address 0B
Nov 09 20:06:32 Mower2 python[721]: Found PicoBorg Reverse at 0B
Nov 09 20:06:32 Mower2 python[721]: PicoBorg Reverse loaded on bus 1
pi@Mower2:~ $

The code that runs at boot is

[Unit]
Description=My Script Service
#After=multi-user.target
After=bluetooth.service
Requires=bluetooth.service

[Service]
Type=idle
ExecStart=/usr/bin/python /home/pi/MBORG/mower02.py > /home/pi/mower02.log 2>&1

[Install]
WantedBy=multi-user.target
piborg's picture

I am not sure why this would not be working for you, but getting things to run correctly at boot can be tricky.

Have you tried adding the script to /etc/rc.local instead?

No, how do I add it to rc.local ?

piborg's picture

Open rc.local using a text editor, such as nano:
sudo nano /etc/rc.local

Look for this line at the bottom of the file:
exit 0

Add the script you want to run above the exit line.
You will probably want to use both sudo and end the line with &.
e.g.

...

sudo /home/pi/diddyred/diddyRedJoy.py &
exit 0

This line should now be run just before the login prompt appears.
If the & is left out then the login prompt will not appear until the script finishes.

Thank you, I tried that and it did not work as

...

sudo /home/pi/folder/myscript.py &
exit 0

But when I added

...

sudo  /usr/bin/python  /home/pi/folder/mysscript.py &
exit 0

It worked perfectly!
So once again thank you for getting me started.

Subscribe to Comments for "Diddyborg with PS3 and camera as its own wifi server on autorun at boot"