-
Notifications
You must be signed in to change notification settings - Fork 13
Socketcan Setup Raspberry Pi
jakka351 edited this page Nov 4, 2022
·
3 revisions
- Raspberry Pi Board
- SD Card Flashed with a fresh copy of Raspbian
- Generic mcp2515 can/spi board (or)
- Raspberry Pi Specific can-bus hat
- an actual Controller Area Network (CAN)-bus to connect to
sudo apt install -y can-utils libsocketcan2 libsocketcan-dev
# CAN-BUS Overlay
dtoverlay=mcp2515-can0,oscillator=16000000,interrupt=25
dtparam=spi=on
auto can0
iface can0 inet manual
pre-up /sbin/ip link set can0 type can bitrate 125000 on restart-ms 100
up /sbin/ifconfig can0 up txqueuelen 65535
down /sbin/ifconfig can0 down
auto can1 # Optional
iface can1 inet manual
pre-up /sbin/ip link set can1 type can bitrate 500000 triple-sampling on restart-ms 100
up /sbin/ifconfig can1 up txqueuelen 500
down /sbin/ifconfig can1 down
sudo reboot
dmesg | grep mcp && ifconfig | grep can
[ 3.139428] mcp251x spi0.1 can0: MCP2515 successfully initialized.
[ 3.150549] mcp251x spi0.0 can1: MCP2515 successfully initialized.
can0: flags=193<UP,RUNNING,NOARP> mtu 16
can1: flags=193<UP,RUNNING,NOARP> mtu 16
sudo apt install -y can-utils libsocketcan2 libsocketcan-dev
auto slcan0
iface can0 inet manual
pre-up /bin/slcand -o -s 500000 /dev/ttyACM0 && sbin/ip link set up slcan0
up /sbin/ifconfig slcan0 up
down /sbin/ifconfig slcan0 down
Note: to use a different device, like bluetooth or UART, just match the device from /dev
and interchange names
sudo reboot
ifconfig | grep can
slcan0: flags=193<UP,RUNNING,NOARP> mtu 16
g