Re: Programatic disconnect and reconnect of USB device

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

 



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