Bent Bisballe Nyeng wrote:
> In the time I have been using libusb there has always been a single
> feature that I was missing: The ability to get a notification when a new
> device is connected (or disconnected for that matter), and thereby
> remove the need for continuous rescans of the usb bus.
>
> In a specific project that I once made a rescan actually interrupted an
> active filetransfer on a MSD. Probably due to a bug in the MSD (some
> custom thiny, not made by me) but it still points to the fact tha a bus
> rescan is a quite "agrssive" thing to do in order to simply find out if
> a device has been connected.

Well, I guess this depends on your level of abstraction.  SOMEONE has to
rescan the bus.  In Windows, for example, you can subscribe to a 
"device changed" event from the PnP provider.  However, that merely
tells you that, somewhere in the system, some bus driver has reported a
change in its set of child devices.  The only way to find out WHICH
devices came or went is to go rescan the bus you're interested in and
compare the current list to your own list.

Further, the notion of reattaching to a lost device is a tricky one. 
You're talking to a driver.  That driver happens to be assigned to a
particular hardware device.  When that hardware device goes away, that
driver instance is unloaded (or at least orphaned).  When that hardware
device comes back, it's seen as a brand-new device, and gets a brand-new
driver set, with absolutely no connection to the orphaned driver you
were talking to before.  Certainly at the kernel level, there is simply
no way to move those old driver connections to the new driver.  Someone
in user mode has to be using heuristics to make that connection.  Some
apps wouldn't want to be automatically reconnected.  Thus, this ends up
being an application-specific process.

This is why hotplug has not already been added to libusb/libusbx.  You
have suggested a mechanism that would work for your application, but
it's not at all clear that it is the right solution for every
application.  It's a very tricky problem.

-- 
Tim Roberts, t...@probo.com
Providenza & Boekelheide, Inc.


------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_mar
_______________________________________________
libusbx-devel mailing list
libusbx-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libusbx-devel

Reply via email to