Setup CAN BUS Configurations

Hi,

I am using RPI3 to read data from the sensor using CAN bus and send it to balenaCloud for visualization.

I am not sure how can I configure the system to do the following:
1- change config.txt

#CAN bus controllers
dtoverlay=mcp2515-can0,oscillator=16000000,interrupt=25
dtoverlay=mcp2515-can1,oscillator=16000000,interrupt=24

dtoverlay=spi-bcm2835

2- Setup the can (Enabling the CAN bus)

ip link set up can0 type can bitrate 500000

3- make them start at boot

auto can0
iface can0 inet manual
   pre-up /sbin/ip link set can0 type can bitrate 500000 triple-sampling on
   up /sbin/ifconfig can0 up
   down /sbin/ifconfig can0 down

auto can1
iface can1 inet manual
    pre-up /sbin/ip link set can1 type can bitrate 500000 triple-sampling on
    up /sbin/ifconfig can1 up
    down /sbin/ifconfig can1 down

4- Setup the can module

pip install python-can

Can someone help me step by step what should be done? I am new to the balenaCloud.

Thanks!

Hi @Moe and welcome to the community!

I do not have a lot of experience with a CAN bus, but I will do my best to answer your questions in order:

  1. There are a few various ways to change config.txt either before the first boot or remotely.
  2. This setup can be performed in your container (perhaps in the CMD entry script).
  3. These look to me like interface files, which you can copy into your container at build time in your Dockerfile
  4. Again, this dependency can be installed in the container (I suggest using a Python base image of some sort, maybe.

Moreover, we have some sample projects that may help you along!