Notifications
Clear all

[Solved / Archived] PiGear Nano: CAN configuration

1 Posts
1 Users
0 Likes
251 Views
(@admin)
Posts: 338
Member Admin
Topic starter
 

You will need to install the can-utils first:

sudo apt install can-utils

If you would like to control can-bus with Python program, you can install python-can:

pip install python-can

Please copy the mcp2515-can2.dtbo file (in “bin” sub-folder in software installation directory) to /boot/overlays:

sudo chown root:root mcp2515-can2.dtbo

sudo chmod 755 mcp2515-can2.dtbo

sudo cp mcp2515-can2.dtbo /boot/overlays/

Then you add these lines in /boot/config.txt file:

#spi-can
dtoverlay=spi1-1cs
dtoverlay=mcp2515-can2,oscillator=16000000,interrupt=10

Reboot your PiGear Nano and then check the CAN device with this command:

ls /sys/bus/spi/devices/spi1.0/net

If configuration is correct you should see can0 device.

You can then make loopback test:

sudo ip link set can0 up type can bitrate 500000 loopback on

If you run ifconfig you will see the can0 device is there:

 

 

You can also test data sending and receiving. You run “can dump can0” to wait for data, and open another shell window and run “cansend can0 111#010203” to send out data.

 

 

Then you can connect PiGear Nano to real CAN device for further testing.

 
Posted : 25/04/2023 5:03 pm
Topic Tags
Join Waitlist We will inform you when the product arrives in stock. Please leave your valid email address below.