Skip to content

Instantly share code, notes, and snippets.

@royratcliffe
Last active June 2, 2025 07:04
Show Gist options
  • Save royratcliffe/b95b10027b2a9cb625a83e98fb680958 to your computer and use it in GitHub Desktop.
Save royratcliffe/b95b10027b2a9cb625a83e98fb680958 to your computer and use it in GitHub Desktop.
raspberrypi
# /etc/systemd/network/80-can.network
# sudo systemctl enable systemd-networkd
# https://www.freedesktop.org/software/systemd/man/latest/systemd.network.html
[Match]
Name=can*
[CAN]
# ip -d link show can0
BitRate=500K
# /etc/udev/rules.d/80-can.rules
ACTION=="add", SUBSYSTEM=="net", KERNEL=="can0", ATTR{tx_queue_len}="65536"
ACTION=="add", SUBSYSTEM=="net", KERNEL=="can1", ATTR{tx_queue_len}="65536"
sudo ip link set can0 up type can bitrate 1000000
sudo ip link set can1 up type can bitrate 1000000
sudo ifconfig can0 txqueuelen 65536
sudo ifconfig can1 txqueuelen 65536
# https://www.waveshare.com/wiki/2-CH_CAN_HAT+
dtparam=spi=on
dtoverlay=i2c0
dtoverlay=spi1-3cs
dtoverlay=mcp2515,spi1-2,oscillator=16000000,interrupt=13
dtoverlay=mcp2515,spi1-1,oscillator=16000000,interrupt=22
# ### Accessing the AMA0 serial port on Raspberry Pi 5
#
# Connect TX, RX and GND to pins 8, 10 and 12 on the 40-pin header. Do not
# forget to cross RX and TX. The pins run at TTL 3V3 levels with no level
# shifting.
#
# Configure the pins using `sudo raspi-config` and navigate to Interface
# Options, Serial Port. Say "yes" to enabling the serial port hardware.
# Say "yes" or "no" to the login shell. The configurator adds the
# following to the `/boot/firmware/config.txt` file.
#
# ```
# dtparam=uart0=on
# ```
#
# After reboot, the UART appears at `/dev/ttyAMA0`. Connect using
# `minicom -D /dev/ttyAMA0 -b 115200` or similarly using other tools.
# full load test with polling, 10ms timeout
# -g <ms> for gap in milliseconds
# -p <ms> for polling timeout in milliseconds
# -x to disable local loopback
cangen can0 -g 0 -p 10 -x
# -r for redraw
# -t for current time
# -b for bar graph
# -c for colour
canbusload can0@500000 can1@500000 -r -t -b -c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment