If you have an Asus Xtion pro live and usually you work under GNU/Linux, perhaps you notice than sometimes you can’t read from Asus Xtion because the usb bus has a problem. Unfortunately the only way to solve this problem is disconnect and connect (physically) the USB connector of the Asus Xtion. But what happens if you don’t have physical access to the machine? Well, I want to show you how you can reset the usb bus of Xtion with a simple script.
The first thing you need to know is that every usb devices connected in your computer are represented in the /sys/bus/usb/devices/ folder:
rocapal@vega:~$ ls /sys/bus/usb/devices/ 1-0:1.0 1-1.2 1-1.2.1:1.0 1-1.4 1-1.4:1.2 1-1.5:1.0 2-1 2-1.8:0.0 3-2 3-2.1:1.0 3-2.3.2 3-2.3.3 usb1 usb4 1-1 1-1.2.1 1-1.2.1:1.1 1-1.4:1.0 1-1.4:1.3 1-1.5:1.1 2-1:1.0 2-1.8:0.1 3-2.1 3-2.3 3-2.3.2:1.0 3-2.3.3:1.0 usb2 1-1:1.0 1-1.2:1.0 1-1.2.1:1.2 1-1.4:1.1 1-1.5 2-0:1.0 2-1.8 3-0:1.0 3-2:1.0 3-2.3:1.0 3-2.3.2:1.1 4-0:1.0 usb3
Now, you have to know where is represented the Asus Xtion device. We know that Asus Xtion device has the following metadata (you notice that your devices can have different idVendor and idProduct, please check it with dmesg command):
Then, you have to look all directories looking the idVendor and idProduct corrects. In my example I found the correct id’s in the bus /sys/bus/usb/devices/1-1.2.1
rocapal@vega:~$ cat /sys/bus/usb/devices/1-1.2.1/idVendor 1d27 rocapal@vega:~$ cat /sys/bus/usb/devices/1-1.2.1/idProduct 0601
Once we have located the bus where the Asus Xtion is connected, we can see with more details the information about all the bus.
rocapal@vega:~$ lsusb -t /: Bus 01.Port 1: Dev 1, Class=root_hub, Driver=ehci-pci/2p, 480M |__ Port 1: Dev 2, If 0, Class=Hub, Driver=hub/6p, 480M |__ Port 2: Dev 40, If 0, Class=Hub, Driver=hub/4p, 480M |__ Port 1: Dev 43, If 0, Class=Vendor Specific Class, Driver=, 480M |__ Port 1: Dev 43, If 1, Class=Audio, Driver=snd-usb-audio, 480M |__ Port 1: Dev 43, If 2, Class=Audio, Driver=snd-usb-audio, 480M
As you can see, the port 1-1.2.1 is a part of the Asus Xtion, not the whole Xtion. So, we have to reset the port 1-1.2 that it contains all the parts of the device.
Ok, we have now the correct bus that we have to reset but how can we do it? Easy, just type the following commands to unbind and bind the usb port
# Disabled echo 1-1.2 | sudo tee /sys/bus/usb/drivers/usb/unbind #Enabled echo 1-1.2 | sudo tee /sys/bus/usb/drivers/usb/bind
You can check that the usb port has successfully restarted with the dmesg command. You should see something like this.
rocapal@vega:~$ dmesg [...] [38035.658351] hub 1-1.2:1.0: USB hub found [38035.658507] hub 1-1.2:1.0: 4 ports detected [38035.929828] usb 1-1.2.1: new high-speed USB device number 45 using ehci-pci [38037.051092] usb 1-1.2.1: New USB device found, idVendor=1d27, idProduct=0601 [38037.051100] usb 1-1.2.1: New USB device strings: Mfr=5, Product=4, SerialNumber=0 [38037.051103] usb 1-1.2.1: Product: PrimeSense Device [38037.051106] usb 1-1.2.1: Manufacturer: PrimeSense [38037.725214] usb_audio: Warning! Unlikely big volume range (=4181), cval->res is probably wrong. [38037.725218] usb_audio:  FU [Mic Capture Volume] ch = 2, val = 0/12544/3usb_audio: Warning! Unlikely big volume range (=4181), cval->res is probably wrong. [38037.730314] usb_audio:  FU [Mic Capture Volume] ch = 1, val = 0/12544/3
The whole process described here, you can execute automatically as a script. You can download the script xtionUsbReset.sh and execute with root or sudo permissions:
rocapal@vega:~$ sudo ./xtionUsbReset.sh Found Xtion in /sys/bus/usb/devices/1-1.2.1/ Found Xtion Bus in 1-1.2 Unbind Xtion ... OK Bind Xtion ... OK