Hi list I have been made aware of the libusbx project recently, and there were much rejoicing...
I found many bugs (especially on windows) that were fixed compared with libusb so the choice of changeover was an easy one - thank you for that. 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. I looked into a solution on the win32 side and found this: http://msdn.microsoft.com/en-us/library/windows/desktop/aa363432(v=vs.85).aspx The implementation would either require libusb to run with a background thread (not good...) or have function that needs to be called by the hos in regular intervals (much more acceptable). I believe a linux implementation could be made using libudev: http://www.freedesktop.org/software/systemd/libudev/libudev-udev-queue.html I propose the following API (inspired by the libusb_get_device_list function): /** * libusb_get_connection_events returns a list of devices that were * connected since the last call to this function. Devices that were * connected and disconnected again before this call will not be * present on the list. * Parameters: * ctx: The context to operate on, or NULL for the default context. * list: Output location for a list of devices. Must be later freed * with libusb_free_device_list(). * Returns: * The number of devices in the outputted list, or any libusb_error * according to errors encountered by the backend. */ ssize_t libusb_get_connection_events(libusb_context *ctx libusb_device ***list); The function should probably be preceeded by some kind of "start_listening_for_events" call and terminated by a "stop_listening_for_events" call in order to set up the native event callbacks. A similar function should be introduced in order to handle deisconnect events, but what exactly should be the contents of this list is not clear to me at this point. Should this interface be considered too complex I propose an alternative and much simpler interface that allows the user to ask if there has been any bus changes before doing a bus rescan: /** * libusb_get_bus_changes is used to detect if any devices has been * connected or disconnected since tha last call to this function. * Parameters: * ctx: The context to operate on, or NULL for the default context. * Returns: * 1 if bus changes has occurred, 0 if no bus changes has occurred, * or any libusb_error according to errors encountered by the backend. */ int libusb_get_bus_changes(libusb_context *ctx); This function could be tied with the libusb_get_device_list so that only changes since last call to libusb_get_device_list OR libusb_get_bus_changes are reported. Again a "start" and "stop" function should probably be made. I am willing to help out with the actual implementation of this feature should you decide to embrace my suggestion. I am however not able to help with other platforms than linux (udev) and windows. Kind regards Bent Bisballe Nyeng ------------------------------------------------------------------------------ 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