Logically connect/reconnect USB device

Derek Broughton news at pointerstop.ca
Sat Jun 21 19:38:18 UTC 2008


NoOp wrote:

> On 06/21/2008 07:13 AM, Oliver Grawert wrote:
>> hi,
>> Am Samstag, den 14.06.2008, 16:53 -0700 schrieb NoOp:
>>> Anyone know of a way to logically connect and reconnect a USB device
>>> without unplugging/plugging or turning off/on?
>>> 
>> the kernel offers a sysfs switch for that called bind/unbind, i used to
>> use it in the classmate PC installation and builder tool, you can have a
>> look at the script on my launchpad branch under
>> http://tinyurl.com/3lwe7v
> 
> Thanks oli. My eyes glazed over a bit, but I'll check out bind/unbind
> and see if I can figure it out.

Looks surprisingly straightforward - a USB device should have bind and
unbind sockets in the appropriate drivers directory, and you just write
into those.  Sure enough, the only usb device currently attached, my
webcam, has:

$ ls  /sys/bus/usb/drivers/uvcvideo/
1-4:1.0  1-4:1.1  bind  module  new_id  unbind

So he looks for those things that are not named "bind", "unbind" or "uevent"
and considers those to be devices (unfortunately this example shows there
may be other things that aren't devices, & I have no idea why there are
actually two devices, here as I only have one webcam).  Then you just echo
the name of the device you want to bind or unbind (e.g. 1-4:1.0) to the
bind/unbind socket.  

Actually finding your device driver from the device name is quite a bit
harder :-)  Oli's example assumes it's always /dev/sd*, and the drivers are
in /sys/bus/scsi/drivers/sd
-- 
derek





More information about the ubuntu-users mailing list