[SOLVED] Hotplug example not working

I see getting two hotplug events for each add or remove with some different environment variables on either of two events

trying to use modified example from here that caters for multiple messages, installed in the usb directory, I see that scripts are getting called by logging env variables

https://openwrt.org/docs/guide-user/base-system/hotplug_lede

GMC300_PRODID="1a86/7523/254"
SYMLINK="GMC300"
     
if [ "${PRODUCT}" = "${GMC300_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 GMC300 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}" = "${GMC300_PRODID}" ];
    then if [ "${ACTION}" = "remove" ];
      then 
        rm /dev/${SYMLINK}
        logger -t Hotplug Symlink /dev/${SYMLINK} removed
  fi
fi

however seems the workaround it is out of date as no tty file exists in the usb device directory searched

Might try logging/dumping env and the variables of interest to a file (on /tmp/, perhaps) so that you can confirm what is being passed to the script

yeah, done that and the script is looking for presence of a tty file in
/sys/devices/platform/soc/3f980000.usb/usb1/1-1/1-1.4/1-1.4:1.0
the directory exists but no tty file exists

wondering if I need kmod-usb-serial-simple, and kmod-usb-serial

installed both of them and no change, dnfw!

the device is usb geiger counter with a tty interface when used set up by udev on raspbian, perhaps need some underlying op sys suppport on openwrt for a specific device???

I was just checking if could run node software of my raspbian product on an openwrt host as a good way to connect a network of my devices to a customers lan with some network protection and be able to get dual function out of the openwrt gateway, mqtt server and some local sensors running on openwrt as well as nodes connected through openwrt.

this is output of dump of environment from a boot up

cat /tmp/envs_log.log
**************************************\n
DEVNAME=bus/usb/001/001
USER=root
OF_NAME=usb
ACTION=add
SHLVL=1
HOME=/
SEQNUM=604
OF_COMPATIBLE_0=brcm,bcm2708-usb
BUSNUM=001
MAJOR=189
HOTPLUG_TYPE=usb
DEVPATH=/devices/platform/soc/3f980000.usb/usb1
LOGNAME=root
DEVICENAME=usb1
TERM=linux
SUBSYSTEM=usb
PATH=/usr/sbin:/usr/bin:/sbin:/bin
MINOR=0
DRIVER=usb
TYPE=9/0/1
kgdboc=ttyS0,115200
DEVNUM=001
PRODUCT=1d6b/2/409
PWD=/
DEVTYPE=usb_device
OF_FULLNAME=/soc/usb@7e980000
OF_COMPATIBLE_N=1
**************************************\n
DEVNAME=bus/usb/001/003
USER=root
OF_NAME=usbether
ACTION=add
SHLVL=1
HOME=/
SEQNUM=605
OF_COMPATIBLE_0=usb424,ec00
BUSNUM=001
MAJOR=189
HOTPLUG_TYPE=usb
DEVPATH=/devices/platform/soc/3f980000.usb/usb1/1-1/1-1.1
LOGNAME=root
DEVICENAME=1-1.1
TERM=linux
SUBSYSTEM=usb
PATH=/usr/sbin:/usr/bin:/sbin:/bin
MINOR=2
OF_ALIAS_0=ethernet0
DRIVER=usb
TYPE=255/0/1
kgdboc=ttyS0,115200
DEVNUM=003
PRODUCT=424/ec00/200
PWD=/
DEVTYPE=usb_device
OF_FULLNAME=/soc/usb@7e980000/usb1@1/usbether@1
OF_COMPATIBLE_N=1
**************************************\n
DEVNAME=bus/usb/001/002
USER=root
OF_NAME=usb1
ACTION=add
SHLVL=1
HOME=/
SEQNUM=606
OF_COMPATIBLE_0=usb424,9514
BUSNUM=001
MAJOR=189
HOTPLUG_TYPE=usb
DEVPATH=/devices/platform/soc/3f980000.usb/usb1/1-1
LOGNAME=root
DEVICENAME=1-1
TERM=linux
SUBSYSTEM=usb
PATH=/usr/sbin:/usr/bin:/sbin:/bin
MINOR=1
DRIVER=usb
TYPE=9/0/2
kgdboc=ttyS0,115200
DEVNUM=002
PRODUCT=424/9514/200
PWD=/
DEVTYPE=usb_device
OF_FULLNAME=/soc/usb@7e980000/usb1@1
OF_COMPATIBLE_N=1
**************************************\n
DEVNAME=bus/usb/001/004
USER=root
ACTION=add
SHLVL=1
HOME=/
SEQNUM=607
BUSNUM=001
MAJOR=189
HOTPLUG_TYPE=usb
DEVPATH=/devices/platform/soc/3f980000.usb/usb1/1-1/1-1.4
LOGNAME=root
DEVICENAME=1-1.4
TERM=linux
SUBSYSTEM=usb
PATH=/usr/sbin:/usr/bin:/sbin:/bin
MINOR=3
DRIVER=usb
TYPE=255/0/0
kgdboc=ttyS0,115200
DEVNUM=004
PRODUCT=1a86/7523/254
PWD=/
DEVTYPE=usb_device

Looks to me a possibly a change in the way the device is bought up and the state/location of files or need op-sys support for the tty chipset of the device...

(i.e. the hassle of cheap chinese arduino clone on windoze, but works straight away on modern linux as built-in support for whatever clone ftdi chipset)

I guess essence of problem is openwrt is designed for tight resource hardware like old routers, whereas raspberry has loads of ram, loads of SD space and so a whole base distro could be derived but then all the backport problem thing, need people to maintain it.

1 Like

If you mean "Node.js" you're probably better off with a device with more RAM than most all-in-one routers have. If you mean "software for a sensor node" then you may be OK. The mosquitto package builds cleanly and I have the client running with the OpenSSL TLS package.

Have you installed the various USB packages that might support the connection to the device?

https://openwrt.org/packages/table/start?dataflt[Name_pkg-dependencies*~]=usb

not looked at node.js, my nodes are an assortment of esp8266 using arduino and raspberry pi with raspbian/python/c, basically wanted a way to separate out iot devices from direct connection to my own or a customers network, so they do not need to know the client wifi network password but run on their own network. OpenWRT has luci, kind of user friendly, so would enable the customer to configure the interface/wlan-bridge to their liking. The PI3 has ethernet and wifi built in so has everything needed except perhaps signal strength and looks to me like it will be ok to also run the management software for the wifi iot node network from the openwrt interface and provide an MQTT server to both the clients lan and the wifi iot lan, and function as an IOT node in its own right. I have tested mosquitto already, works great, probably be back for help on setting it up to use ssh LOL

once you get the hang of the ideosyncracies (for a reason) of OpenWRT it seems excellent!

Thanks for help!

1 Like

Answer was in another post and in the troubleshooting USB document

install usbutils
lsusb
Bus 001 Device 005: ID 1a86:7523 QinHeng Electronics HL-340 USB-Serial

install general usb support for the usb chipset your router has
for raspberry pi
install general usb2 support
opkg install kmod-usb2

then figure what driver module works for that chip, google of course

opkg install kmod-usb-serial-ch341

sorted, my hotplug script now pops up my device!

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.