Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save grodansparadis/16e010326dc1ceedb0dcd162ac6c153e to your computer and use it in GitHub Desktop.

Select an option

Save grodansparadis/16e010326dc1ceedb0dcd162ac6c153e to your computer and use it in GitHub Desktop.
Autostart socketcan channels using systemd on Linux
# Create service file
```bash
[Unit]
Description=can0
[Service]
ExecStartPre=/sbin/ip link set can0 type can bitrate 125000 restart-ms 100
ExecStart=/sbin/ip link set can0 up txqueuelen 128
Restart=on-failure
RestartSec=1
[Install]
WantedBy=multi-user.target
```
# Install service
```bash
sudo cp can0.service /etc/systemd/system
sudo systemctl start can0
sudo systemctl enable
```
Can do this with virtual channels as well.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment