-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathxtionUsbReset.sh
executable file
·61 lines (48 loc) · 1.52 KB
/
xtionUsbReset.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/bin/bash
# Copyright (C) JDE DEVELOPERS
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see http://www.gnu.org/licenses/.
#
# Authors : Roberto Calvo <rocapal at gmail dot com>
idVendor="1d27"
idProduct="0601"
XTION_USB_DEVICE=""
XTION_BUS=""
function check_result {
if [ "$?" != "0" ]; then
echo "Error"
exit
else
echo "OK"
fi
}
IFS=$(echo -en "\n\b")
for X in /sys/bus/usb/devices/*; do
vendor=`cat "$X/idVendor" 2>/dev/null`
product=`cat "$X/idProduct" 2>/dev/null`
if [ "${vendor}" = "${idVendor}" ] && [ "${product}" = "${idProduct}" ]; then
XTION_USB_DEVICE=$X
break
fi
done
echo "Found Xtion in $XTION_USB_DEVICE"
XTION_BUS=$(basename `echo $XTION_USB_DEVICE | cut -d"." -f-2`)
echo "Found Xtion Bus in $XTION_BUS"
echo -n "Unbind Xtion ... "
echo $XTION_BUS | sudo tee /sys/bus/usb/drivers/usb/unbind &>/dev/null
check_result
sleep 1
echo -n "Bind Xtion ... "
echo $XTION_BUS | sudo tee /sys/bus/usb/drivers/usb/bind &>/dev/null
check_result