-
-
Save Leo-PL/b5ee737e49b34c1551dba6c182707c8e to your computer and use it in GitHub Desktop.
[ "${ACTION}" = "add" -o "${ACTION}" = "remove" ] || exit 0 | |
[ "${SUBSYSTEM}" = "tty" ] || exit 0 | |
[ -n "${DEVNAME}" -a -n "${DEVPATH}" ] || exit 1 | |
if [ "${ACTION}" = "add" ]; then | |
subsystem="$(basename $(readlink /sys${DEVPATH}/../../../subsystem))" | |
[ "$subsystem" = "usb" ] || exit 0 | |
manufacturer="$(cat /sys${DEVPATH}/../../../../manufacturer)" || manufacturer="$(cat /sys${DEVPATH}/../../../../idVendor)" | |
product="$(cat /sys${DEVPATH}/../../../../product)" || product="$(cat /sys${DEVPATH}/../../../../idProduct)" | |
serial="$(cat /sys${DEVPATH}/../../../../serial)" | |
interface="$(cat /sys${DEVPATH}/../../../bInterfaceNumber)" | |
port="$(cat /sys${DEVPATH}/device/port_number)" | |
id_link=$(echo "${subsystem}"-"${manufacturer}"_"${product}${serial:+_}${serial}"-if"${interface}${port:+-port}${port}" | s/[^\.\:0-9A-Za-z-]/_/g) | |
path_link=$(echo "${DEVPATH}${port:+-port}${port}" | sed s%/devices/%% | sed s%/${DEVNAME}/tty/${DEVNAME}%%g | sed s/[^\.\:0-9A-Za-z-]/_/g) | |
mkdir -p /dev/serial/by-id /dev/serial/by-path | |
ln -sf "/dev/${DEVNAME}" "/dev/serial/by-id/${id_link}" | |
ln -sf "/dev/${DEVNAME}" "/dev/serial/by-path/${path_link}" | |
elif [ "${ACTION}" = "remove" ]; then | |
for link in $(find /dev/serial -type l); do | |
[ -L ${link} -a "$(readlink ${link})" = "/dev/$DEVNAME" ] && rm ${link} | |
done | |
fi |
Do you have links under /dev/serial/by-path
? Symlinks for by-id
won't work with CH340, because it lacks iSerialNumber
attribute in USB descriptor. Also it's possible there is some copy-paste error, check if you can execute the script manually by passing required environment variables. Run set -x
to enable shell debug.
@naseef Also use the version from the linked repository. One posted here is deprecated.
Seems like I have narrowed down the issue. The devices are directly soldered in to the board and not hotplugged
, so openwrt won't initiate any hotplug events. I am still new this, correct me if I am wrong
And yes, I was using the code from the linked repo.
Still, bind events should work for coldplugged devices. Unless there is a bug in hotplugd which prevents this somehow.
Hi. Thank you for the script. I have an issue. My ch341 UART converter is not triggering an event in hotplug.d. Can you please help me to troubleshoot this issue?
As mentioned in wiki, I have created a file
/etc/hotplug.d/tty/99-logger
as mentioned in openwrt wiki withlogger -t hotplug $(env)
output of
logread -e hotplug
which does not contain my devicettyUSB0
dmesg
outputttyUSB1
also not triggering the event