Android USB host to FTDI chip - how to set connection settings via ControlTransfer

Hello, I deal with communication Android (tablet android 4.4.2) with our special hardware with FTDI chip via a USB port. I can actually detect the connected devices to the tablet and try to receive data via BulkTransfer. For testing purposes, I use a timer continuously read data through BulkTransfer. As the return value should be the number of received Bytes and I get 2 or 10 or 64 Bytes which seems to be OK. The problem is that in the buffer is only bytes 1 and 96 and others are 0 (or 1 and 98 and others are 0). I guess the problem is in setting of the baudrate of link and I wanted to use a method ControlTransfer to setting it. I come from the example in Java like this :

conn.controlTransfer(0x40, 0x03, 0x001A, 0, null, 0, 0);

and try use :

usbConnection.ControlTransfer(UsbAddressing.XferTypeMask, 3, 26, 0, null, 0, 0);

I have a problem with first paremeter of method. In .net the UsbAddressing not enum with a value of 40 and do not know which value is correct. Or is the problem somewhere else?

Thank you for the info


  • crossplatformercrossplatformer CAMember
    edited June 2015

    Or is the problem somewhere else?

    I have not worked with the UsbHost on Xamarin.Android, only with Java Android (but obviously, they should be 1:1), so this is more a general comment:

    From earlier experience, I can say that it could also depend on the Android device and/or the chip/driver you are using - with some FTDI chips there was no other solution than to root the Android device and to include/implement some further driver support for the chip.
    Otherwise, the chip could not be detected and/or could not be communicated with in a stable manner etc.
    So it could depend on the Android device and/or the chip.

    Also, it seemed that the OTG cable itself plays an important role, it needs to be quality enough and also the current/voltage was sometimes an issue (5V vs. 3.3V etc.).

    Here seems to be some related discussion:


  • MichalFrantaMichalFranta CZMember ✭✭

    I found that Xamarin has not UsbAddressing value for FTDI chip, but I can bypass it by simply recasts numerical value on UsbAddressing

    UsbServiceUnit.USBConn.ControlTransfer((UsbAddressing)64, 0, 0, 0, null, 0, 0);// reset  mConnection.controlTransfer(0×40, 0, 1, 0, null, 0, 0);//clear Rx
    UsbServiceUnit.USBConn.ControlTransfer((UsbAddressing)64, 0, 1, 0, null, 0, 0);// clear Rx
    UsbServiceUnit.USBConn.ControlTransfer((UsbAddressing)64, 0, 2, 0, null, 0, 0);// clear Tx
    UsbServiceUnit.USBConn.ControlTransfer((UsbAddressing)64, 3, 26, 0, null, 0, 0);// baudrate  57600 115200-0x001A-26, 9600-0x4138-16696, 19200-0x809C-32924, 230040-0x000D-13
    UsbServiceUnit.USBConn.ControlTransfer((UsbAddressing)64, 2, 0, 0, null, 0, 0);// flow  control none                                                            
    UsbServiceUnit.USBConn.ControlTransfer((UsbAddressing)64, 4, 8, 0, null, 0, 0);// data bit  8, parity  none,  stop bit 1, tx off
Sign In or Register to comment.