save
This commit is contained in:
26
scripts/setup_can.sh
Normal file
26
scripts/setup_can.sh
Normal file
@@ -0,0 +1,26 @@
|
||||
#!/usr/bin/env bash
|
||||
# Configure two SocketCAN interfaces to the same bitrate for a benchmark run.
|
||||
# Usage: sudo ./setup_can.sh <bitrate> [master_if] [slave_if]
|
||||
# e.g. sudo ./setup_can.sh 500000 can_com3 can_com4
|
||||
set -euo pipefail
|
||||
|
||||
BITRATE="${1:?usage: setup_can.sh <bitrate> [master_if] [slave_if]}"
|
||||
MASTER_IF="${2:-can_com3}"
|
||||
SLAVE_IF="${3:-can_com4}"
|
||||
|
||||
configure() {
|
||||
local ifc="$1"
|
||||
echo ">> configuring $ifc @ ${BITRATE} bit/s"
|
||||
ip link set "$ifc" down || true
|
||||
ip link set "$ifc" type can bitrate "$BITRATE" restart-ms 100
|
||||
ip link set "$ifc" txqueuelen 1000
|
||||
ip link set "$ifc" up
|
||||
}
|
||||
|
||||
configure "$MASTER_IF"
|
||||
configure "$SLAVE_IF"
|
||||
|
||||
echo
|
||||
echo "== interface state =="
|
||||
ip -details -brief link show "$MASTER_IF"
|
||||
ip -details -brief link show "$SLAVE_IF"
|
||||
Reference in New Issue
Block a user