RE: Programatic disconnect and reconnect of USB device

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I found the post that Greg mentioned about turning power off to ports (http://article.gmane.org/gmane.linux.usb.general/30383) but it doesn't seem to make any difference to the attached device until I use Simon's command for unbinding the driver:

echo -n '1-7' > /sys/bus/usb/drivers/usb/unbind

The post mentions that the 'hubpower' program should cause the driver to be unbound when issuing ioctl requests so I'm not sure what the difference is between that kind of unbind and whatever the above 'echo' command does.

However, I did notice that using the above command, even without 'hubpower' will cause 'lsusb -t' to segfault when run afterward. Is there something unsavoury about using the above echo command? Could you offer some insight into the behaviour I'm seeing?

-----Original Message-----
From: Alan Stern [mailto:stern@xxxxxxxxxxxxxxxxxxx] 
Sent: Thursday, December 01, 2011 8:09 PM
To: Vane, Edwin
Cc: linux-usb@xxxxxxxxxxxxxxx
Subject: Re: Programatic disconnect and reconnect of USB device

On Thu, 1 Dec 2011, Vane, Edwin wrote:

> Forgive me if I've got the wrong list. Please suggest an alternative if so.
> 
> I'm a complete USB newb. I have a device that has software expecting 
> me to manually disconnect and reconnect a USB cable for it to proceed. 
> Is it possible to programmatically tell the linux host to 'turn off' 
> the usb to that device to simulate a disconnect and then 'turn on' the 
> connection back on as if I had plugged the cable back in? I'm not 
> above making local modifications to the USB subsystem on the host so 
> if that's necessary, fine. I welcome your advice.

It depends on what the device wants.  Unplugging the USB cable will, of course, remove the +5 V power going to the device.  If that's what it wants then as Greg said, you're probably out of luck -- the USB hardware on most PCs is not capable of turning off the +5 V power programatically.

On the other, unplugging the cable also eliminates the USB data signals.  If that's all the device wants then you can achieve the desired result by forcing it to suspend.  Doing this requires two simple steps:

	echo auto >/sys/bus/usb/devices/.../power/control
	echo 0 >/sys/bus/usb/devices/.../bConfigurationValue

Then to un-suspend the device:

	echo 1 >/sys/bus/usb/devices/.../bConfigurationValue

(1 might not be the right number; you can read the correct value from that file before you suspend the device.)  Fill in the "..."s with the correct path for your device.

Alan Stern

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux