title: ioctl returns -1 in android USB bulk transfer
body: <p>I have an android app which creates a connection to a USB device and have to receive data through a particular endpoint. I am handling the data transfer part in native code. The app is able to find the device, open connection and find the required endpoint. 
  The data reading part is in the native code, where an ioctl call is made inside a while loop. </p>
  
  <pre><code>int bytesTransferred = ioctl(g_fileDescriptor, USBDEVFS_BULK, &amp;ctrl);
  </code></pre>
  
  <p>This g_fileDescriptor is the descriptor for the USB connection.</p>
  
  <p>Second parameter is to indicate that it is bulk transfer. </p>
  
  <p>The third parameter has the structure usbdevfs_bulktransfer (which has the endpoint address, bufferlength - 16KB, data placeholder, timeout-1000msec)</p>
  
  <p>I tried this using two USB devices. 
  First device works good. Data is being read successfully.</p>
  
  <p>Second device seems to give some problem. My app finds the device, connects to it, finds the required endpoint. But the ioctl call always returns -1. And I noted that the time interval between two successive ioctl calls is 0.99 sec on an average (which is approximately equal to the timeout value I set). </p>
  
  <p>So I have three questions here.</p>
  
  <ol>
  <li><p>Can I conclude that timeout is the reason for ioctl returning -1 ? </p></li>
  <li><p>Can strerror(errorno) find what is exactly the problem ? (Because I read that ioctl returns -1 on error and sets the corresponding errorcode in system's 'errno' variable)</p></li>
  <li><p>What are the situations in which Timeout occurs in case of bulk transfer ? </p></li>
  </ol>