Files
Cnomicon/sbin-scripts/peak_usb_device_namer

19 lines
522 B
Bash
Executable File

#!/bin/sh
#
# External Udev program to rename peak_usb CAN interfaces according to the flashed device numbers.
#
# (C) 2023 PEAK-System GmbH by Stephane Grosjean
#
[ -z "$1" ] && exit 1
CAN_ID="/sys/class/net/$1/peak_usb/can_channel_id"
if [ -f $CAN_ID ]; then
devid=`cat $CAN_ID`
# PCAN-USB specific: use "000000FF" instead of "FFFFFFFF" below
if [ "$devid" != "00000000" -a "$devid" != "FFFFFFFF" ]; then
printf "can%d\n" 0x${devid}
exit 0
fi
fi
echo $1