From 5a0e79b3b34d22b9b60941ff20d205bb55a31ab7 Mon Sep 17 00:00:00 2001 From: Roman Yeryomin Date: Sat, 6 Oct 2012 16:47:03 +0300 Subject: add query3g package Signed-off-by: Roman --- package/query3g/files/query3g.sh | 42 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 package/query3g/files/query3g.sh (limited to 'package/query3g/files/query3g.sh') diff --git a/package/query3g/files/query3g.sh b/package/query3g/files/query3g.sh new file mode 100644 index 000000000..b591d61a3 --- /dev/null +++ b/package/query3g/files/query3g.sh @@ -0,0 +1,42 @@ +#!/bin/sh + +reset=/usr/bin/usbreset +comgt=/usr/bin/gcom +script=/usr/share/query3g.gcom + +last_reset="x" + +wan_proto="$(uci -q get network.wan.proto)" + +if [ "$wan_proto" = "3g" ]; then + ifdown wan +fi + +for port in 0 1 2 3 4 5 6 7 8 9; do + for tty in $(find /sys/devices/ -name "ttyUSB$port" -type d | sort -u); do + [ -f "$tty/../../idProduct" ] || continue + + local dir="$(cd "$tty/../.."; pwd)" + local uid="$(basename "$dir")" + local dev="/dev/$(basename "$tty")" + local vid="$(cat "$tty/../../idVendor")" + local pid="$(cat "$tty/../../idProduct")" + + if [ "$last_reset" != "$vid:$pid" ]; then + last_reset="$vid:$pid" + $reset "$vid:$pid" >/dev/null + + local try=0 + while [ $((try++)) -lt 5 ] && [ ! -e "$dev" ]; do sleep 1; done + fi + + if $comgt -s "$script" -d "$dev" 2>/dev/null; then + echo "PORT:$dev" + echo "VID:$vid" + echo "PID:$pid" + echo "UID:$uid" + exit 0 + fi + done +done +exit 1 -- cgit v1.2.3