title: Android communication with USB to Serial Device and controlTransfers
body: <p>I have searched through numerous posts such as this one: 
  <a href="https://stackoverflow.com/questions/13280581/using-android-to-communicate-with-a-usb-hid-device">Using Android to Communicate with a USB HID Device</a></p>
  
  <p>but i am still not getting how do you determine <strong>requestType</strong> in <strong>controlTransfer</strong> calls?</p>
  
  <pre><code>public int controlTransfer (int requestType, int request, int value, int index, byte[] buffer, int length, int timeout)
  </code></pre>
  
  <p>i need to set <strong>EVEN</strong> parity for my device and it does not seem to work.
  here's my code:</p>
  
  <pre><code>        UsbDeviceConnection conn = mUsbManager.openDevice(mDevice);
          l("Device opened...");
  
          l("Trying to open interface on 0");
          UsbInterface deviceInterface = mDevice.getInterface(0);
          if (!conn.claimInterface(deviceInterface, true)) {
              l("Could not claim interface on 0");
              return;
          }
  
          int defaultDataBits = 8;
          int config = defaultDataBits;
          config |= (0x02 &lt;&lt; 8); //even parity
          config |= (0x00 &lt;&lt; 11); //stop bits
  
          conn.controlTransfer(0x40, 0, 0, 0, null, 0, 0);// reset
          conn.controlTransfer(0x40, 0, 1, 0, null, 0, 0);// clear Rx
          conn.controlTransfer(0x40, 0, 2, 0, null, 0, 0);// clear Tx
          conn.controlTransfer(0x40, 0x04, config, 0, null, 0, 0);// set even parity
          conn.controlTransfer(0x40, 0x03, 0x4138, 0, null, 0, 0);// set 9600 baud rate
  </code></pre>
  
  <p>requestType 0x40 does not make any sense to me and some examples have it at 0x21 or 0x81 or 0xA1... </p>
  
  <p>What would be the best way of getting the correct requestType?</p>
  
  <p>I should also mention that i expect to receive the data on the PC with EVEN parity and if i set the parity of the serial port on the PC to NONE - i receive the <em>expected data</em>, so i have concluded that the controlTransfer calls i make to the device are not working.</p>
  
  <p>this is my USB to Serial device i am trying to configure from Android:</p>
  
  <pre><code>Device Info 
  Device Path: /dev/bus/usb/001/002
  Device Class: Use class information in the Interface Descriptors (0x0)
  Vendor ID:  067b
  Vendor Name:  Prolific Technology, Inc.
  Product ID:  03ea
  
  
  Interfaces 
      Interface #0 
      Class: Vendor Specific (0xff)
  Endpoint: #0
      Address        : 129 (10000001)
      Number         : 1
      Direction      : Inbound (0x80)
      Type           : Intrrupt (0x3)
      Poll Interval  : 1
      Max Packet Size: 10
      Attributes     : 000000011
  Endpoint: #1
      Address        : 2 (000000010)
      Number         : 2
      Direction      : Outbound (0x0)
      Type           : Bulk (0x2)
      Poll Interval  : 0
      Max Packet Size: 64
      Attributes     : 000000010
  Endpoint: #2
      Address        : 131 (10000011)
      Number         : 3
      Direction      : Inbound (0x80)
      Type           : Bulk (0x2)
      Poll Interval  : 0
      Max Packet Size: 64
      Attributes     : 000000010
  </code></pre>
  
  <p>Thanks for your help.</p>