title: Cannot Read Bytes from an FTDI Serial I2C to Android Eclipse Java app
body: <p>I have an FTDI UMFT201XB (I2C serial USB Interface) connected to an android 4.2 tablet through a OTG cable. The FTDI is connected to a PIC MCU. I have run the example TN-147 from FTDI and the device is recognized correctly.</p>
  
  <p>I have modded the TN-147 example to read 12 bytes that the MCU has send to UMFT201XB.</p>
  
  <p>The code is:</p>
  
  <pre><code>public void ReNew() {
          byte [] databuf = new byte[5] ;
          byte [] databuf1 = new byte[20];
          device_time=0;
          databuf1[0]= 0x64;
          databuf1[2]= 0x64;
          databuf[0]= 0x09;
  
  
          if(ftdid2xx.createDeviceInfoList(Device_ControlFragmentContext) &lt;= 0)
              return;
          ftDevice = ftdid2xx.openByIndex(Device_ControlFragmentContext, 0);
  
          if (ftDevice == null) {
              Toast.makeText(Device_ControlFragmentContext, "Not supported device",Toast.LENGTH_SHORT).show();
              } else {
                  //ftDevice.setLatencyTimer((byte)240);
                  ftDevice.purge((byte) (D2xxManager.FT_PURGE_TX | D2xxManager.FT_PURGE_RX));
                  ftDevice.setBitMode((byte)0x33 , (byte)0x20);
                  iavailable1 = ftDevice.getQueueStatus();
                  ftDevice.write(databuf , 1);
                  ftDevice.restartInTask();
                  iavailable2 = ftDevice.getQueueStatus();
                  lenght_ = ftDevice.read(databuf1,iavailable2);
                  iavailable3 = ftDevice.getQueueStatus();
                  ftDevice.setBitMode((byte)0x32 , (byte)0x20);
                  ftDevice.close();
  
                  device_time=databuf1[0]+databuf1[1]+databuf1[2]+databuf1[3]+databuf1[4]+databuf1[5]+databuf1[6]+databuf1[7]+databuf1[8]+databuf1[9]+databuf1[10]+databuf1[11]+databuf1[12]+databuf1[13]+databuf1[14]+databuf1[16]+databuf1[17]+databuf1[18]+databuf1[15]+databuf1[19];
                  DEVICE_TIME.setText(String.valueOf(device_time));
                  days_view.setText(String.valueOf(iavailable1));
                  hours_view.setText(String.valueOf(iavailable2));
                  minutes_view.setText(String.valueOf(iavailable3));
                  seconds_view.setText(String.valueOf(lenght_));
                  SYSTEM_TIME.setText(String.valueOf(593));
          /////////////////////////////////////////////////////////////////////////////////           
      }
      ftDevice.close();
  
      }
  </code></pre>
  
  <p>My problem is that on execution, <code>device_time = 200 (dec)</code>, <code>iavailable1 = 00</code>, <code>iavailable2 = 12(Dec)</code>, and <code>iavailable3 = 12(Dec)</code>.</p>
  
  <p>Obviously, the 200 came from   </p>
  
  <pre><code>databuf1[0]= 0x64;
  databuf1[2]= 0x64; 
  </code></pre>
  
  <p>The <code>ftDevice.read(databuf1,iavailable2)</code> does not fetch any bytes to <code>databuf1</code>. And the available bytes remains <code>12(Dec)</code> (<code>iavailable3 = 12</code>).</p>
  
  <p>Please help.</p>