OpenWrt Forum Archive

Topic: Hotplug: Same Product/Vendor ID

The content of this topic has been archived on 23 Apr 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

I have OpenWrt on a Raspberry Pi,on which I plug two Arduino Uno boards.

I run lsusb to get the Product/Vendor IDs and get this:

Bus 001 Device 005: ID 2341:0043 Arduino SA Uno R3 (CDC ACM)
Bus 001 Device 006: ID 2341:0043 Arduino SA Uno R3 (CDC ACM)

I have made this in hotplug.d,but it only works if there is only one Arduino plugged:

#!/bin/sh

ARD_PRODID="2341/43/1"
SYMLINK="arduino_sensors"

if[ "${PRODUCT}" = "${ARD_PRODID}" ];
    then if [ "${ACTION}" = "add" ];
        then
        DEVICE_NAME = $(ls /sys/$DEVPATH | grep tty)
        if [ -z ${DEVICE_NAME} ];
            then logger -t Hotplug Warning DEVICE_NAME is empty
            exit
        fi
        logger -t Hotplug Device name of ARD is $DEVICE_NAME
        ln -s /dev/$DEVICE_NAME /dev/${SYMLINK}
        logger -t Hotplug Symlink from /dev/$DEVICE_NAME to /dev/${SYMLINK} created
    fi
fi

if [ "${PRODUCT}" = "${ARD_PRODID}" ];
    then if [ "${ACTION}" = "remove" ];
        then
        rm /dev/${SYMLINK}
        logger -t Hotplug Symlink /dev/${SYMLINK} removed
    fi
fi

How could I use the Serial Numbers of the boards instead of just the IDs to distinguish between them?

Check out /sys/bus/usb/devices/$chain_device/serial

Example: cat /sys/bus/usb/devices/1-1.2.6.7/serial delivers "F1B615A0" for a Logitech Webcam.

The problem I have is not the part of getting the serial number.

The problem I have is how to use the serial ID in my hotplug rule.

(Last edited by gxypo on 12 May 2015, 16:43)

The discussion might have continued from here.