From 2ee673e2238b9002cdb1d40ab3bd3f73af0782ca Mon Sep 17 00:00:00 2001 From: Christian Pointner Date: Thu, 20 Mar 2014 18:19:29 +0000 Subject: fixed hotplug script for USB serial converter diff --git a/openwrt/rhctl/Makefile b/openwrt/rhctl/Makefile index ee4ae97..8f26b35 100644 --- a/openwrt/rhctl/Makefile +++ b/openwrt/rhctl/Makefile @@ -14,7 +14,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=rhctl PKG_REV:=108 PKG_VERSION:=r$(PKG_REV) -PKG_RELEASE:=1 +PKG_RELEASE:=2 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2 PKG_SOURCE_URL:=https://svn.helsinki.at/rhctl/trunk diff --git a/openwrt/rhctl/files/rhctl-usbserial.hotplug b/openwrt/rhctl/files/rhctl-usbserial.hotplug index 5da2fd1..8d2f7bc 100755 --- a/openwrt/rhctl/files/rhctl-usbserial.hotplug +++ b/openwrt/rhctl/files/rhctl-usbserial.hotplug @@ -2,9 +2,11 @@ # # Persistent naming for usb serial devices. # -# Copyright 2013 Christian Pointner +# Copyright 2013-2014 Christian Pointner # +logger="logger -p daemon.info -t rhctl-usbserial" + idVendor=`echo $PRODUCT | awk -F '/' '{ print($1) }'` idProduct=`echo $PRODUCT | awk -F '/' '{ print($2) }'` bcdDevice=`echo $PRODUCT | awk -F '/' '{ print($3) }'` @@ -14,61 +16,63 @@ if [ "$idVendor" != "403" ] || [ "$idProduct" != "6011" ]; then fi DEVPATH="/sys$DEVPATH" -if [ ! -e "$DEVPATH/bInterfaceNumber" ]; then - exit 0 -fi +if [ $ACTION == "add" ]; then + if [ ! -e "$DEVPATH/bInterfaceNumber" ]; then + exit 0 + fi -PARENT=`dirname "$DEVPATH` -SERIAL=`cat $PARENT/serial` + PARENT=`dirname "$DEVPATH` + SERIAL=`cat $PARENT/serial` -if [ "$SERIAL" != "FTVSOXJP" ]; then - exit 0 + if [ "$SERIAL" != $(uci -q get rhctl.@global[0].ftdi_serial) ]; then + exit 0 + fi 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"` + add) + ttydir=`echo "$DEVPATH/ttyUSB*` + tty=`basename $ttydir` + interface=`cat "$DEVPATH/bInterfaceNumber"` - device="$interface" + device="$interface" - case "$interface" in - 00) device="ttyMasterCtl" - ;; - 01) device="ttyMasterHB" - ;; - 02) device="ttyStandbyCtl" - ;; - 03) device="ttyStandbyHB" - ;; - *) exit 0 - ;; - esac + 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 - ;; + 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 [ -h "$token" ]; then + device=$(ls -l $token | sed 's/.*-> //;/ /s/.*//') + case "$device" in + "") # no symlink + $logger "failed: token=$token device=$device" + ;; + *) + rm -f $token $device + $logger "removed: $device" + ;; + esac + fi + ;; esac +exit 0 diff --git a/openwrt/rhctl/files/rhctl.config b/openwrt/rhctl/files/rhctl.config index ffec5ab..c59074e 100644 --- a/openwrt/rhctl/files/rhctl.config +++ b/openwrt/rhctl/files/rhctl.config @@ -1,8 +1,12 @@ +config 'global' + option ftdi_serial 'FTVSOXJP' +# option ftdi_serial 'FTVRIHVY' + config 'switchctl' option log 'syslog:3,switchctl,daemon' option command_sock '/var/run/rhctl/switchctl.sock' option baudrate '19200' - option device '/dev/audioswitch' + option device '/dev/ttyS1' option config '/etc/rhctl/switchctl.conf' option mode 'master' option channel 'main' -- cgit v0.10.2