Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. QSerialPort alternative for Android?
Forum Updated to NodeBB v4.3 + New Features

QSerialPort alternative for Android?

Scheduled Pinned Locked Moved Mobile and Embedded
5 Posts 2 Posters 2.7k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    DoughBoy
    wrote on last edited by
    #1

    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!

    1 Reply Last reply
    0
    • K Offline
      K Offline
      kuzulis
      Qt Champions 2020
      wrote on last edited by kuzulis
      #2

      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/

      1 Reply Last reply
      0
      • D Offline
        D Offline
        DoughBoy
        wrote on last edited by
        #3

        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!

        1 Reply Last reply
        0
        • K Offline
          K Offline
          kuzulis
          Qt Champions 2020
          wrote on last edited by
          #4

          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

          1 Reply Last reply
          0
          • D Offline
            D Offline
            DoughBoy
            wrote on last edited by
            #5

            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!

            1 Reply Last reply
            0

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved