In colord, I need to do cancellable asynchronous interrupt transfers to talk to spectrophotometer devices like the X-Rite ColorMunki, and connect up libusb1 with a GMainLoop. It turned out Hans de Goede also needed to do the same kind of integration with his spice work. So, we want to share code to minimize bugs as the GSource code gets kinda hairy.
I’ve created a new project GUsb that wraps libusb1 with several high level wrappers that makes it easy to use in GLib programs. See the README for more details.
Go here if you want to look at the pre-release code — although we’ve not yet had a single tarball release yet, and any applications using GUsb have to define G_USB_API_IS_SUBJECT_TO_CHANGE before they can include gusb.h
If you’re interested in helping out please email either Hans or myself. There’s no mailing list just yet. It works for me; If it breaks for you, you get to keep both pieces (or send patches). There are no Fedora or Ubuntu packages at this point, although after the pending 0.1.0 release I’ll submit the package for Fedora package review for F16+.
Note, nothing depends on this library just yet; it’s too late in the GNOME 3.2 cycle to add new low level deps, and it’s also not even slightly API stable. Comments welcome.
Maybe merge this in glib?
Nahh, it’s way too low level. It might make sense to merge this with gudev in the future, but USB is actually quite specialized and well contained, and probably only needed by a handful of processes on the system. You don’t want to bloat the library for everyone else.
Did you forget to remove the GCancellable argument from gusb_device_open()? It doesn’t seem to be used.
No, it’s deliberately there. libusb_claim_interface is currently sync (and fairly slow at that) and I’m hoping to do something clever there (a thread, perhaps). I’m not sure. Ideas welcome.
Good stuff, I was using libusb directly for a usb gadget of mine, maybe I’ll try gusb instead and see if it works out ok.
A nice glib+gasync+gcancellable example is always welcome.
Yell if there’s anything missing. It’s still work in progress so expect a few WTFs.
Good stuff!
Is there any plans to provide gobject introspection for managing GUsb? I’d really like to handle GUsb from python.
It would be trivial to add the gobject introspection stuff and fix up some of the annotations. Patch please! :-)