QSerialPort alternative for Android?



  • Hello,

    I've done a lot of searching and it seems there's no easy way to get [QSerialPort] to work on the Android platform. I have a rooted Android device with a built in RS-232/485 port that I would like to use. Is it possible to use something other than the [QSerialPort]? I was thinking that perhaps I could just do a File Open (/Dev/tty) to read/write to the serial port. Sadly, I'm not too sure on the appropriate method of this idea. Any helpful guidance would be greatly appreciated.

    Thanks to all for their assistance!



  • I have a rooted Android device with a built in RS-232/485 port that I would like to use.

    If you have a rooted device, then there are no problem (I think) to use QSerialPort (in this case need to run application with the root privileges, or, give a rights for open the tty device for any(?) user).

    Otherwise (if you have not rooted device && you have an USB/Serial converter) you can try to use this patch: https://codereview.qt-project.org/#/c/84338/



  • Hi Kuzulis,

    Thanks very much for your response. Let me explain the situation a bit better. I created an application that uses [QSerialPort], but when I try to compile the application for [Android for armeabi-v7a (GCC 4.9, Qt 5.4.1)] I get an error: [Project ERROR: Unknown module(s) in QT: serialport].
    This means my line [QT += core gui serialport] in the .pro file isn't acceptable. When I Google search this error, I find that Qt doesn't support the [QSerialPort] class with Andriod.

    Now, I'm looking to see if there's an alternative to the [QSerialPort] that I could use instead.

    I appreciate your suggestion, to use the git library of [QSerialPort] for non-rooted/USB serial communication. But sadly, I don't think that applies to my needs, or am I mistaken?

    Thanks again!



  • I find that Qt doesn't support the [QSerialPort] class with Andriod.

    You can compile and install QtSerialPort manually into your Android's Qt instance (it is better to use QtCreator for this purpose). For more info see WIKI: https://wiki.qt.io/QtSerialPort



  • Hi kuzulis,

    Thank you very much for your suggestion. That is exactly what I did - compiled and installed [QtSerialPort] manually and now I have the class available for my Android application. For some odd reason, the building stage didn't complete exactly, so I manually copied over the compiled files to the Qt directory.

    1. {From} ...\QtSerialPort\build\include => Copied [QtSerialPort] to <Qt dir>\android_armv7\include
    2. {From} ...\QtSerialPort\build\lib => Copied [libQt5SerialPort.la; libQt5SerialPort.prl; libQt5SerialPort.so] to <Qt dir>\android_armv7\lib
    3. {From} ...\QtSerialPort\build\mkspecs\modules => Copied [qt_lib_serialport.pri] to <Qt dir>\android_armv7\mkspecs\modules

    Even though the working solution doesn't answer my initial question, I do believe this thread has been solved. I am interested to know if I am neglecting something by manually copying over the build files - let me know if you could.

    Thanks again!


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.