I have searched through numerous posts such as this one: Using Android to Communicate with a USB HID Device
but i am still not getting how do you determine requestType in controlTransfer calls?
public int controlTransfer (int requestType, int request, int value, int index, byte[] buffer, int length, int timeout)
i need to set EVEN parity for my device and it does not seem to work. here's my 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 << 8); //even parity
config |= (0x00 << 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
requestType 0x40 does not make any sense to me and some examples have it at 0x21 or 0x81 or 0xA1...
What would be the best way of getting the correct requestType?
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 expected data, so i have concluded that the controlTransfer calls i make to the device are not working.
this is my USB to Serial device i am trying to configure from Android:
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
Thanks for your help.