You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# 2. Setup udev rules for automatic CAN configuration on USB connection
24
-
echo""
25
-
echo"Setting up automatic CAN configuration..."
20
+
echo"Setting up systemd-networkd CAN configuration..."
21
+
22
+
sudo tee /etc/systemd/network/can0.network > /dev/null <<'EOF'
23
+
[Match]
24
+
Name=can0
25
+
26
+
[CAN]
27
+
BitRate=1000000
28
+
DataBitRate=5000000
29
+
FDMode=yes
30
+
RestartSec=100ms
31
+
EOF
26
32
27
-
sudo tee /etc/udev/rules.d/99-openarm-can.rules> /dev/null <<'EOF'
28
-
# OpenArm CAN interfaces - auto-configure when USB devices are connected
29
-
# This triggers whenever can0 or can1 interface is added to the system
33
+
sudo tee /etc/systemd/network/can1.network> /dev/null <<'EOF'
34
+
[Match]
35
+
Name=can1
30
36
31
-
ACTION=="add", SUBSYSTEM=="net", KERNEL=="can0", RUN+="/bin/bash -c 'sleep 1 && /usr/bin/ip link set can0 type can bitrate 1000000 dbitrate 5000000 fd on && /usr/bin/ip link set up can0'"
37
+
[CAN]
38
+
BitRate=1000000
39
+
DataBitRate=5000000
40
+
FDMode=yes
41
+
RestartSec=100ms
42
+
EOF
43
+
44
+
sudo tee /etc/systemd/network/can2.network > /dev/null <<'EOF'
45
+
[Match]
46
+
Name=can2
32
47
33
-
ACTION=="add", SUBSYSTEM=="net", KERNEL=="can1", RUN+="/bin/bash -c 'sleep 1 && /usr/bin/ip link set can1 type can bitrate 1000000 dbitrate 5000000 fd on && /usr/bin/ip link set up can1'"
48
+
[CAN]
49
+
BitRate=1000000
50
+
DataBitRate=5000000
51
+
FDMode=yes
52
+
RestartSec=100ms
34
53
EOF
35
54
36
-
# Reload udev rules
37
-
sudo udevadm control --reload-rules
38
-
sudo udevadm trigger
55
+
sudo tee /etc/systemd/network/can3.network > /dev/null <<'EOF'
56
+
[Match]
57
+
Name=can3
39
58
40
-
echo"✓ udev rules installed - CAN interfaces will auto-configure on USB connection"
59
+
[CAN]
60
+
BitRate=1000000
61
+
DataBitRate=5000000
62
+
FDMode=yes
63
+
RestartSec=100ms
64
+
EOF
41
65
42
-
# 3. Configure CAN now (for current session)
43
-
echo""
44
-
echo"Configuring CAN interfaces for current session..."
45
-
sudo ip link set can0 type can bitrate 1000000 dbitrate 5000000 fd on 2>/dev/null ||true
46
-
sudo ip link set up can0 2>/dev/null ||true
47
-
sudo ip link set can1 type can bitrate 1000000 dbitrate 5000000 fd on 2>/dev/null ||true
48
-
sudo ip link set up can1 2>/dev/null ||true
66
+
echo"Enabling systemd-networkd..."
67
+
sudo systemctl enable systemd-networkd
68
+
sudo systemctl start systemd-networkd
69
+
70
+
echo"Reloading networkd config..."
71
+
sudo networkctl reload
49
72
50
-
# Check status
51
73
echo""
52
74
echo"=== CAN Interface Status ==="
53
-
ip link show can0 2>/dev/null &&echo"✓ can0 is up"||echo"⚠ can0 not found (plug in USB adapter)"
54
-
ip link show can1 2>/dev/null &&echo"✓ can1 is up"||echo"⚠ can1 not found (plug in USB adapter)"
75
+
forifacein can0 can1 can2 can3;do
76
+
ip link show $iface2>/dev/null &&echo"$iface is up"||echo"$iface not found (plug in USB adapter)"
77
+
done
55
78
56
79
echo""
57
-
echo"✓ System setup complete!"
80
+
echo"Setup complete! CAN interfaces will now auto-configure on every boot and USB plug."
58
81
echo""
59
82
echo"Next steps:"
60
-
echo" 1. Plug in OpenArm USB-CAN adapters (if not already connected)"
0 commit comments