<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Need some help with serial port on Android]]></title><description><![CDATA[<p dir="auto">Hello, everybody!</p>
<p dir="auto">I am writing application for Android on Qt. It must communicate with device which is connected to tablet's USB via FTDI usb-uart chip.</p>
<p dir="auto">Firstly i've tried to build QtSerialPort module using android qt toolchain and i've found that it doesn't work.<br />
Than i've tried to build QtSerialPort from here <a href="https://codereview.qt-project.org/#/c/84338/" target="_blank" rel="noopener noreferrer nofollow ugc">https://codereview.qt-project.org/#/c/84338/</a> and it looks like it doesn't work too. Here is a piece of java-code which used in QSerialPortInfo::availableDevices:</p>
<p dir="auto">@////////////////////////////////////////////////////////////////////////////////////////////////<br />
//<br />
//  Constructor.  Only used once to create the initial instance for the static functions.<br />
//<br />
////////////////////////////////////////////////////////////////////////////////////////////////<br />
public UsbDeviceJNI()<br />
{<br />
m_instance = this;<br />
m_openedDevices = new HashMap&lt;Integer, UsbSerialDriver&gt;();<br />
m_userData = new HashMap&lt;Integer, Integer&gt;();<br />
m_ioManager = new HashMap&lt;Integer, UsbIoManager&gt;();<br />
}</p>
<pre><code>/////////////////////////////////////////////////////////////////////////////////////////////////////////
//
//  Find all current devices that match the device filter described in the androidmanifest.xml and the
//  device_filter.xml
//
/////////////////////////////////////////////////////////////////////////////////////////////////////////
private static boolean getCurrentDevices()
{
    if (m_instance == null)
        return false;
    

    if (m_manager == null)
        m_manager = (UsbManager)m_instance.getSystemService(Context.USB_SERVICE);

    if (m_devices != null)
        m_devices.clear();

    m_devices = UsbSerialProber.findAllDevices(m_manager);

    return true;
}


/////////////////////////////////////////////////////////////////////////////////////////////////////////
//
//  List all available devices that are not already open.  It returns the serial port info
//  in a : separated string array.  Each string entry consists of the following:
//
//  DeviceName:Company:ProductId:VendorId
//
/////////////////////////////////////////////////////////////////////////////////////////////////////////
public static String[] availableDevicesInfo()
{


    //  GET THE LIST OF CURRENT DEVICES
    if (!getCurrentDevices())
        return null;

    //  MAKE SURE WE HAVE ENTRIES
    if (m_devices.size() &lt;= 0)
        return null;

    if (m_openedDevices == null)
        return null;

    int countL = 0;
    int iL;

    //  CHECK FOR ALREADY OPENED DEVICES AND DON"T INCLUDE THEM IN THE COUNT
    for (iL=0; iL&lt;m_devices.size(); iL++)
    {
        if (m_openedDevices.get(m_devices.get(iL).getDevice().getDeviceId()) != null)
        {
            countL++;
            break;
        }
    }

    if (m_devices.size() - countL &lt;= 0)
        return null;

    String[] listL = new String[m_devices.size() - countL];
    UsbSerialDriver driverL;
    String tempL;

    //  GET THE DATA ON THE INDIVIDUAL DEVICES SKIPPING THE ONES THAT ARE ALREADY OPEN
    countL = 0;
    for (iL=0; iL&lt;m_devices.size(); iL++)
    {
        driverL = m_devices.get(iL);
        if (m_openedDevices.get(driverL.getDevice().getDeviceId()) == null)
        {
            UsbDevice deviceL = driverL.getDevice();
            tempL = deviceL.getDeviceName() + ":";

            if (driverL instanceof FtdiSerialDriver)
                tempL = tempL + "FTDI:";
            else if (driverL instanceof CdcAcmSerialDriver)
                tempL = tempL + "Cdc Acm:";
            else if (driverL instanceof Cp2102SerialDriver)
                tempL = tempL + "Cp2102:";
            else if (driverL instanceof ProlificSerialDriver)
                tempL = tempL + "Prolific:";
            else
                tempL = tempL + "Unknown:";

            tempL = tempL + Integer.toString(deviceL.getProductId()) + ":";
            tempL = tempL + Integer.toString(deviceL.getVendorId()) + ":";
            listL[countL] = tempL;
            countL++;
        }
    }

    return listL;
}@
</code></pre>
<p dir="auto">UsbDeviceJNI::availableDevicesInfo method always returns null, and QSerialPortInfo::availableDevices is always empty. It happens because getCurrentDevices() calls from static method and m_instance is null. Actualy i have no idea of how to fix it.</p>
<p dir="auto">So maybe someone could help me?<br />
Or maybe there is another more simple way to implement data exchange between Android tablet and FTDI usb-uart chip?</p>
<p dir="auto">P.S. Sorry for my english.</p>
]]></description><link>https://forum.qt.io/topic/45764/need-some-help-with-serial-port-on-android</link><generator>RSS for Node</generator><lastBuildDate>Mon, 11 May 2026 02:16:24 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/45764.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 09 Sep 2014 12:55:38 GMT</pubDate><ttl>60</ttl></channel></rss>