0
votes

I am using MAX232 device for UART(Raspberry Pi) to RS232 communication(Other Board). But I want to use USB to Serial cable for this. I have attached the image of a cable. How can I use this in Android Things?

Can anyone tell this.

enter image description here

1
I can point you to the Android USB host documentation although can't provide additional guidance. - Nick Felker

1 Answers

0
votes

You can use libraries like this or that. And in case of FTDI-based USB<->UART converters you can use FTDI's solution for Android like d2xx driver with Java wrapper. And you can find many examples (like this) of it's use:

...
private static D2xxManager ftD2xx = null;
private FT_Device ftDev;
...

try {
    ftD2xx = D2xxManager.getInstance(this);

    int devCount = 0;
    devCount = ftD2xx.createDeviceInfoList(this);

    Log.d(TAG, "Device number : "+ Integer.toString(devCount));

    D2xxManager.FtDeviceInfoListNode[] deviceList = new D2xxManager.FtDeviceInfoListNode[devCount];
    ftD2xx.getDeviceInfoList(devCount, deviceList);

    if(devCount <= 0) {
        return;
    }

    if(ftDev == null) {
        ftDev = ftD2xx.openByIndex(this, 0);
    } else {
        synchronized (ftDev) {
            ftDev = ftD2xx.openByIndex(this, 0);
        }
    }
    ...

} catch (D2xxManager.D2xxException ex) {
    Log.e(TAG,ex.toString());
}