Skip to content

Instantly share code, notes, and snippets.

@Lauszus
Last active February 19, 2025 15:20
Show Gist options
  • Save Lauszus/733c4c4c6abacd19a0b5dad099fab172 to your computer and use it in GitHub Desktop.
Save Lauszus/733c4c4c6abacd19a0b5dad099fab172 to your computer and use it in GitHub Desktop.
Ubuntu 20.04 auto configure CAN bus interfaces using systemd
[Match]
Name=can*
[CAN]
BitRate=250000
RestartSec=100ms
# Put this file in: "/etc/systemd/network/" and then run "sudo systemctl enable systemd-networkd" to enable systemd-networkd
# Now start systemd-networkd: "sudo systemctl start systemd-networkd"
# Credit: https://github.com/linux-can/can-utils/issues/68#issuecomment-584505426
SUBSYSTEM=="net", KERNEL=="can*", ACTION=="add|change", ATTR{tx_queue_len}="1000"
# Add this to "/etc/udev/rules.d/80-can.rules" to increase the "txqueuelen" to 1000
# Then run to trigger an update:
# sudo udevadm control --reload-rules
# sudo udevadm trigger --subsystem-match=net --action=change
@vibnwis
Copy link

vibnwis commented Oct 15, 2020

Would you mind sharing what CAN-controller board do you use? what file is it you put in "/etc/systemd/network/"

@vibnwis
Copy link

vibnwis commented Oct 15, 2020

Okie, I resolved the file issue. May I know what CAN-Controller board do you use, please?

@Lauszus
Copy link
Author

Lauszus commented Oct 15, 2020

@lucasgolino
Copy link

This work as intend! Thanks for sharing!
I'm using those configuration with Mainsail OS with a CanBus over serial from a STM32 MCU w/ CAN Chain

  • A Raspberry Pi Custom purpose distro for 3d printers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment