title: Android USB Host API: bulk transfer buffer size
body: <p>I am writing software to <strong>communicate between tablet</strong> (Motorola Xoom with Android version 4.0.3 and Kernel version 2.6.39.4) <strong>and a peripheral device using USB Host API</strong> provided by Android. I use only two types of communication:</p>
  
  <ul>
  <li><strong>control</strong>: <code>controlTransfer(int requestType, int request, int value, int index, byte[] buffer, int length, int timeout)</code></li>
  <li><strong>bulk</strong>: <code>bulkTransfer(UsbEndpoint endpoint, byte[] buffer, int length, int timeout)</code></li>
  </ul>
  
  <p>Control transfer works fine, but I have <strong>a problem with bulk transfer. I can use only 32768 as a size of the buffer for bulkTransfer function. It is not possible to use less or more. I know that I cannot use more because of the limit of the buffer pipe (size: 32769 bytes).</strong></p>
  
  <p>This peripheral device streams data which is not correctly read by bulkTranfer function. I suppose that some data is lost.</p>
  
  <p>I find this: <a href="http://www.kernel.org/doc/man-pages/online/pages/man7/pipe.7.html" rel="nofollow noreferrer"><em>In Linux If a process attempts to read from an empty pipe (buffer), then read(2) will block until data is available. If a process attempts to write to a full pipe , then write(2) blocks until sufficient data has been read from the pipe to allow the write to complete.</em></a></p>
  
  <p>And based on that, my explanation of the problem is that some data is not written to pipe (buffer) because of blocking flag made by write(2) function. Am I correct? If this is true I could change pipe buffer.</p>
  
  <ol>
  <li>My first solution for this problem is greater buffer. <a href="https://stackoverflow.com/questions/4739348/is-it-possible-to-change-the-size-of-a-named-pipe-on-linux">For
  kernel >= 2.6.35, you can change the size of a pipe with <code>fcntl(fd, F_SETPIPE_SZ, size)</code></a> but how can I find <code>fd</code> (file descriptor) for
  USB pipes? </li>
  <li>Second option is to use <code>ulimit -p SIZE</code> but parameter <code>p</code> for my kernel is not for pipe but process.</li>
  </ol>
  
  <p>Has anyone faced the same problem, any solutions?</p>