По работе приходится использовать usb модемы, как правило работают долго и не виснут. Но бывает когда модем нужно перезагрузить, т.к. он залип.
Решается все утилитой usbreset
Запсукается так ./usbreset /dev/bus/usb/001/070
В иделае вывод должен быть Reset successful, но не понятно перезагрузилось устройство или нет. На сервере с астериском будет сообщение
[Aug 20 15:19:47] ERROR[18338]: chan_dongle.c:414 do_monitor_phone: [dongle0] Lost connection to Dongle
— [dongle0] Dongle has disconnected
— [dongle0] Trying to connect on /dev/ttyUSB2…
— [dongle0] Dongle has connected, initializing…
— [dongle0] Dongle initialized and ready
Астериск и сам может перегрузить модем dongle restart now dongle0
Альтернативный вариант, скриптом (взят от сюда). Данный вариант выдвал ошибку ругался на grep, внес правки в него
Spoiler |
SelectПоказать> |
echo "Searching for $1"
devPath=`lsusb | grep -i $1 | sed -r 's/Bus ([0-9]{3}) Device ([0-9]{3}).*/bus\/usb\/\1\/\2/g;'`
echo "Found $1 @ $devPath"
echo "Searching for sysPath"
for sysPath in /sys/bus/usb/devices/*; do
echo "$sysPath/uevent"
devName=`cat "$sysPath/uevent" | grep $devPath`
#echo devName=$devName
if [ ! -z $devName ]
then
break
fi
done
if [ ! -z $devName ]
then
echo "Found $1 @ $sysPath, Resetting"
echo "echo 0 > $sysPath/authorized"
echo 0 > $sysPath/authorized
echo "echo 1 > $sysPath/authorized"
echo 1 > $sysPath/authorized
else
echo "Could not find $1"
fi
|
Если скрипт отработал, то в логе должно быть
Spoiler |
SelectПоказать> |
[786858.747478] option1 ttyUSB0: GSM modem (1-port) converter now disconnected from ttyUSB0
[786858.747498] option 1-3:1.0: device disconnected
[786858.747819] option1 ttyUSB1: usb_wwan_indat_callback: resubmit read urb failed. (-2)
[786858.750667] option1 ttyUSB1: usb_wwan_indat_callback: resubmit read urb failed. (-2)
[786858.753499] option1 ttyUSB1: usb_wwan_indat_callback: resubmit read urb failed. (-2)
[786858.757595] option1 ttyUSB1: GSM modem (1-port) converter now disconnected from ttyUSB1
[786858.757610] option 1-3:1.1: device disconnected
[786858.757945] option1 ttyUSB2: usb_wwan_indat_callback: resubmit read urb failed. (-2)
[786858.760806] option1 ttyUSB2: usb_wwan_indat_callback: resubmit read urb failed. (-2)
[786858.763651] option1 ttyUSB2: usb_wwan_indat_callback: resubmit read urb failed. (-2)
[786858.766855] option1 ttyUSB2: GSM modem (1-port) converter now disconnected from ttyUSB2
[786858.766872] option 1-3:1.2: device disconnected
[786858.770039] usb-storage 1-3:1.0: USB Mass Storage device detected
[786858.770298] option 1-3:1.0: GSM modem (1-port) converter detected
[786858.770425] usb 1-3: GSM modem (1-port) converter now attached to ttyUSB0
[786858.770558] usb-storage 1-3:1.1: USB Mass Storage device detected
[786858.770659] option 1-3:1.1: GSM modem (1-port) converter detected
[786858.770762] usb 1-3: GSM modem (1-port) converter now attached to ttyUSB1
[786858.770879] usb-storage 1-3:1.2: USB Mass Storage device detected
[786858.774235] option 1-3:1.2: GSM modem (1-port) converter detected
[786858.774383] usb 1-3: GSM modem (1-port) converter now attached to ttyUSB2
[786858.774446] usb 1-3: authorized to connect
|