Android USB Host API: bulk transfer buffer size -


i writing software communicate between tablet (motorola xoom android version 4.0.3 , kernel version 2.6.39.4) and peripheral device using usb host api provided android. use 2 types of communication:

  • control - controltransfer(int requesttype, int request, int value, int index, byte[] buffer, int length, int timeout)
  • bulk - bulktransfer(usbendpoint endpoint, byte[] buffer, int length, int timeout)

control transfer works fine, have a problem bulk transfer. can use 32768 size of buffer bulktransfer function. not possible use less or more. know cannot use more because of limit of buffer pipe (size: 32769 bytes).

this peripheral device streams data not correctly read bulktranfer function. suppose data lost.

i find this: in linux if process attempts read empty pipe (buffer), read(2) block until data available. if process attempts write full pipe , write(2) blocks until sufficient data has been read pipe allow write complete.

and based on that, explanation of problem data not written pipe (buffer) because of blocking flag made write(2) function. correct? if true change pipe buffer.

  1. my first solution problem greater buffer. for kernel >= 2.6.35, can change size of pipe fcntl(fd, f_setpipe_sz, size) how can find fd (file descriptor) usb pipes?
  2. second option use "ulimit -p size" parameter p kernel not pipe process.

has faced same problem, solutions?

you should usb data analyzer, im using one: http://www.ellisys.com/products/usbex200/index.php

using helped me when doing same type of thing, found had type of while loop.

for device had 64 bytes of data coming in packets me, packet 2 control bytes , 62 data, transfer had

stringbuilder sb = new stringbuilder(); while(bulktransfer(usbendpoint endpoint, byte[] buffer, int length, int timeout) > 2){     for(int = 2; < buffer.length(); i++){         sb.append((char) buffer[i]);     } } 

something long these lines worked me, had same issue , how fixed it. have more information if need it. comment :). know frustrating me to. im using acer iconia a500 android 4.0.3 btw


transferring larger amounts of data usb

transferring data usb


Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -