User55412
User55412

Reputation: 940

libusb_submit_transfer no callback

I'm setting up my first libusb asynchronous transfer but never receive a callback.

I have connected to the library and can enumerate and open devices successfully.

The functions that are being used to set up the transfer (in this order) are as follows:

libusb_alloc_transfer()
libusb_fill_bulk_transfer()
libusb_submit_transfer()

libusb_submit_transfer returns a successful result so I would expect to see receive a callback even if it returns an error, but none is received.

Any suggestions as to what could be wrong?

Upvotes: 4

Views: 2141

Answers (1)

user6523747
user6523747

Reputation:

libusb documentation states:

In the interest of being a lightweight library, libusb does not create threads and can only operate when your application is calling into it. Your application must call into libusb from it's main loop when events are ready to be handled, or you must use some other scheme to allow libusb to undertake whatever work needs to be done.

Two integration levels are proposed:

  • Simple : you use a blocking call as your application's main loop content
  • Advanced : you can either request libusb for its descriptors and mix them with yours, or register callbacks (libusb_set_pollfd_notifiers()) to get notified of added/removed descriptors.

An example usage of the later can be found in the libmaru project

Upvotes: 4

Related Questions