Automatically start PiCan

In the description of the PiCan manual you'll read that you have to activate the canbus manually .

Fortunately Raspbian contains a location / file being called during bootup. This file is located at:
[nano /etc/rc.local]

At the bottom of this file (just above ' exit 0 ') I call a manual stored python file (python_can.py):
sudo python /home/pi/python_can.py

clipping

And in this python_can.py file contains the following code:

import os

#os.system("sudo ip link set can0 up type can bitrate 100000 restart-ms 100 loopback on")
os.system("ip link set can0 up type can bitrate 100000 restart-ms 100")
os.system("kodi")

This automatically when you start your Raspberry Pi the ' ip link set ' command.

The first line is passive (#). Here is the same command, but with the addition ' walking back on '. This addition makes that the Canbus not phisicly works, but echo't to itself. For testing purposes this is a practical addition. Think of it as a ' localhost ' principle.
So when I would like to test, then I move the (#) to the second line.
[whohit]Automatically start PiCan[/whohit]

Subscribe
Email me at:
1 Comment
oldest
latest most voted
Inline feedbacks
View all comments