> You have a basic misunderstanding about how USB works. USB is entirely
> host-driven; a device cannot send anything on its own. (Indeed, the
> term "interrupt pipe" has caused many people to reach the wrong
> conclusion. The device cannot "interrupt" the bus. Perhaps "scheduled
> pipe" would have been better term.)
> So, unless you have a read request outstanding, there will NEVER be any
> activity on the file descriptor (or on the bus, for that matter). In
> order to do what you ask, you have to keep submitting requests. The
> host controller will keep polling the device until your request is
> satisfied. This is exactly how your USB mouse and keyboard work.
> Now, you can certainly submit a request with an infinite timeout, so
> that you don't have to keep resubmitting every second.
Ah, ok, thanks. So a usb has no way to indicate it has data then?
For now I do a interrupt read with timeout 0. :-)
In my case this works, because after printing the welcome screen it can just wait for a button to be pushed.
But to do such a read, it's really better to use an asynchronous read, using libusb 1.0.3 :-)
So i'll scramble converting, because right now, during the read with infinite timeout I can't do anything at all.
I am wondering what the preferred way to open the usb device is:
devh = libusb_open_device_with_vid_pid(NULL, VENDOR_ID, PRODUCT_ID);
Or isn't it better to traverse the device list and use libusb_open when i encounter my device?
Reading through the best way to handle events i read this:
"The recommended option is to integrate libusb with your application main event loop. libusb exposes a set of file descriptors which allow you to do this. Your main loop is probably already calling poll() or select() or a variant on a set of file descriptors for other event sources (e.g. keyboard button presses, mouse movements, network sockets, etc). You then add libusb's file descriptors to your poll()/select() calls, and when activity is detected on such descriptors you know it is time to call libusb_handle_events()."
But if there will be no activity on the fd, then I cannot use poll or select and the whole thing doesn't work?
With Windows Live, you can organize, edit, and share your photos.