BeagleBone Blue DroneCAN GPS etc. - how to autostart CAN bus?

OK so I went back to the beginning to ensure I hadn’t made a mistake along the way. I’ve adopted the suggestion to create a script ‘aphw’ to set up the hardware as detailed here: GitHub - imfatant/test (step 18).

In my case, ‘aphw’ is:

#!/bin/bash
/sbin/ip link set up can0 type can bitrate 1000000

But of course the way is now open to add more hardware setup as required.

Then I have the service:

[Unit]
Description=ArduRover Service
After=networking.service
StartLimitIntervalSec=0
Conflicts=arducopter.service arduplane.service antennatracker.service

[Service]
ExecStartPre=-/usr/bin/ardupilot/aphw
ExecStart=/usr/bin/ardupilot/ardurover -C /dev/ttyO1 -A udp:192.168.7.1:14550 -B /dev/ttyS2
Restart=on-failure
RestartSec=1

[Install]
WantedBy=multi-user.target

If you look at the line ‘ExecStartPre’ there is a ‘-’ appended to the call to ‘aphw’, this ensures any error thrown by ‘aphw’ is ignored and the service continues to start. I found this to be necessary, not yet sure why but I will investigate further.

Anyway, I hope this helps anyone else struggling with this.

1 Like