-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcanable_start.sh
More file actions
executable file
·31 lines (26 loc) · 938 Bytes
/
canable_start.sh
File metadata and controls
executable file
·31 lines (26 loc) · 938 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/bin/bash
echo "Enter the name of the can interface (can0, e.g.):"
read interface
# Check if the interface exists
if ! ip link show "$interface" &> /dev/null; then
echo "Interface $interface does not exist."
echo "If you have a physical CAN adapter, make sure it's connected."
echo "If you want to create a virtual CAN interface for testing, use:"
echo "sudo ip link add dev $interface type vcan"
exit 1
fi
# Try to set the interface type and bitrate
if sudo ip link set $interface type can bitrate 1000000; then
echo "Set $interface type to CAN with 1Mbps bitrate."
else
echo "Failed to set $interface type and bitrate."
echo "If this is a virtual CAN interface, you can skip this step."
fi
# Bring up the interface
if sudo ip link set $interface up; then
echo "Brought up $interface."
else
echo "Failed to bring up $interface."
exit 1
fi
echo "CAN interface $interface setup complete."