Reputation: 342
I am working with Blackberry 10 os (Q5 mobile),trying to write and read over USB (/dev/aap0) file,I could not transfer packets of size 512 bytes but successfully transferred 16KB (512*8*4) both from and to Blackbery(its purely experimental, transfer'd 512 bytes packet 32 times and read once at the phone side,so changed the packet size to 16KB(32*512) and everything worked),but still couldn't figure out why this thing is happening ,why i can communicate with 16KB packets and not with 512 bytes packet,any links in this field would be highly appreciated.
thanks, sumit
Upvotes: 0
Views: 283
Reputation: 653
I found a similar problem while working with USB communication from a Linux machine to my Nexus 5. I found out that a bulk transfer from the Linux machine to my Nexus would only work if I used a buffer of 16KB to read on the Java side. Then I found this:
When you ask libusb to submit a bulk transfer larger than 16kb in size, libusb breaks it up into a number of smaller subtransfers. This is because the usbfs kernel interface only accepts transfers of up to 16kb in size. The subtransfers are submitted all at once so that the kernel can queue them at the hardware level, therefore maximizing bus throughput.
On legacy platforms, this caused problems when transfers completed early. Upon this event, the kernel would terminate all further packets in that subtransfer (but not any following ones). libusb would note this event and immediately cancel any following subtransfers that had been queued, but often libusb was not fast enough, and the following subtransfers had started before libusb got around to cancelling them.
Supposedly, this is fixed with recent Linux kernel and libusb releases.
Link (libusb caveats): http://www.cs.unm.edu/~hjelmn/libusb_hotplug_api/caveats.html
Upvotes: 1