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.
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.
- 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?
- 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
Comments
Post a Comment