As a die-hard old-school unix programmer, I want to be able to grab data
from a USRP-like device, under control of a main loop based on
select(2). The comments in the source code of fusb are not encouraging.
Quoting from gnuradio-3.0/usrp/host/lib/fusb_linux.cc:
// Totally evil and fragile extraction of file descriptor from
// guts of libusb. They don’t install usbi.h, which is what we’d need
// to do this nicely.
// FIXME if everything breaks someday in the future, look here…
fd_from_usb_dev_handle (usb_dev_handle *udh)
return *((int *) udh);
… and of course this function is not exported via the public class
interface. Worse, what I want is to know when I can read from an
endpoint, not the raw device. And when I go to read from an endpoint
marked as having something, it still doesn’t have a nonblocking read,
that will return as many bytes as are available.
I don’t think my desires are unreasonable. Has anyone else tried
to multitask[*] with USB I/O? I’ll hack up fusb if I have to.
[*] Not counting threads. Quoting Alan Cox: “Computers are state
machines. Threads are for people who can’t program state machines.”