diff options
author | Christian Pointner <equinox@helsinki.at> | 2013-09-16 14:19:15 (GMT) |
---|---|---|
committer | Christian Pointner <equinox@helsinki.at> | 2013-09-16 14:19:15 (GMT) |
commit | 9decd47e14165e159e70829a5dd71cd076cde700 (patch) | |
tree | de760836c1d147830f5f1f719277e3a64c86afb9 /openwrt/rhctl/files/rhctl-usbserial.hotplug | |
parent | 549acaede7b62e4fcbb7c0bbc8b5e8f5ac420d9b (diff) |
added hotplug script for usb-serial converter
Diffstat (limited to 'openwrt/rhctl/files/rhctl-usbserial.hotplug')
-rwxr-xr-x | openwrt/rhctl/files/rhctl-usbserial.hotplug | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/openwrt/rhctl/files/rhctl-usbserial.hotplug b/openwrt/rhctl/files/rhctl-usbserial.hotplug new file mode 100755 index 0000000..5da2fd1 --- /dev/null +++ b/openwrt/rhctl/files/rhctl-usbserial.hotplug @@ -0,0 +1,74 @@ +#!/bin/sh +# +# Persistent naming for usb serial devices. +# +# Copyright 2013 Christian Pointner <equinox@helsinki.at> +# + +idVendor=`echo $PRODUCT | awk -F '/' '{ print($1) }'` +idProduct=`echo $PRODUCT | awk -F '/' '{ print($2) }'` +bcdDevice=`echo $PRODUCT | awk -F '/' '{ print($3) }'` + +if [ "$idVendor" != "403" ] || [ "$idProduct" != "6011" ]; then + exit 0 +fi + +DEVPATH="/sys$DEVPATH" +if [ ! -e "$DEVPATH/bInterfaceNumber" ]; then + exit 0 +fi + +PARENT=`dirname "$DEVPATH` +SERIAL=`cat $PARENT/serial` + +if [ "$SERIAL" != "FTVSOXJP" ]; then + exit 0 +fi + +logger="logger -p daemon.info -t rhctl-usbserial" + +hotplug=/dev/.hotplug +token=$hotplug/`echo $PRODUCT$DEVPATH | sed 's/\//=/g'` + +case "$ACTION" in +add) + ttydir=`echo "$DEVPATH/ttyUSB*` + tty=`basename $ttydir` + interface=`cat "$DEVPATH/bInterfaceNumber"` + + device="$interface" + + case "$interface" in + 00) device="ttyMasterCtl" + ;; + 01) device="ttyMasterHB" + ;; + 02) device="ttyStandbyCtl" + ;; + 03) device="ttyStandbyHB" + ;; + *) exit 0 + ;; + esac + + mkdir -p "$hotplug" + rm -f "/dev/$device" "$token" + ln -s "/dev/$device" "$token" + ln -s "/dev/$tty" "/dev/$device" + $logger "added: tty=$tty device=$device" + ;; +remove) + if [ -e "$token" ]; then + device=`ls -l $token | sed 's/.*-> //;/ /s/.*//'` + case "$device" in + "") # no symlink + $logger "failed: token=$token device=$device" + ;; + *) $debug rm -f $token $device + $logger "removed: $device" + ;; + esac + fi + ;; +esac + |