On Mon, Nov 29, 2004 at 04:12:24PM -0800, Lan, Oliver wrote: > We have experienced data packet lost by using user space application to > read usb device. > The problem seems to me is how to submit multiple URB requests at the > user level? > > Please see the attached the test program and your feedback is > appreciated.
Looks like your use of USBDEVFS_REAPURBNDELAY is not correct. This ioctl does not take the URB pointer as input - it _returns_ a pointer to an URB which was previously passed to USBDEVFS_SUBMITURB. You should also check the status field of the returned URB - it will contain a negative error code if something went wrong. BTW, if you plan to use multiple threads or processes to work with the same device, look at the nearby thread "USB ioctl problem in 2.4.28" in this list - there are some problems introduced by the recently added locking which are not yet solved. However, most of the problem is avoided by not using USBDEVFS_REAPURB (a blocking version of USBDEVFS_REAPURBNDELAY). Also, the signal handling in your test program does not seem safe - only async-signal-safe functions should be used in a signal handler, and the set of such functions is rather small (in particular, no malloc(), no stdio - only raw read()/write()). Programs using unsafe functions in signal handlers will "mostly work", but may sometimes crash or deadlock in hard-to-trace ways.
pgpD5A6iAWr7K.pgp
Description: PGP signature