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. FTDI with Android (Odroid XU4)
Forum Updated to NodeBB v4.3 + New Features

FTDI with Android (Odroid XU4)

Scheduled Pinned Locked Moved Solved Mobile and Embedded
13 Posts 6 Posters 2.5k 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.
  • SGaistS Offline
    SGaistS Offline
    SGaist
    Lifetime Qt Champion
    wrote on last edited by
    #2

    Hi and welcome to devnet,

    Did you check that your user on the board has read/write permission for the device ?

    For classic Linux, it's usually a matter of adding the user to the dialout group but I don't know if Android follows the same principles.

    Interested in AI ? www.idiap.ch
    Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

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

      What can i do?

      AFAIK, you need in root rights to access to the serial ports (for that you need a rooted device).

      Also, maybe you can create a some boot-script (but you need a root rights to change a system files and so on) which gives an appropriate permissions for your serial port device (e.g. changes chmod ...). Then you can access to the serial port as usual user, I guess... But it is just my assumption, I never did it.

      CaktozzC 1 Reply Last reply
      1
      • K kuzulis

        What can i do?

        AFAIK, you need in root rights to access to the serial ports (for that you need a rooted device).

        Also, maybe you can create a some boot-script (but you need a root rights to change a system files and so on) which gives an appropriate permissions for your serial port device (e.g. changes chmod ...). Then you can access to the serial port as usual user, I guess... But it is just my assumption, I never did it.

        CaktozzC Offline
        CaktozzC Offline
        Caktozz
        wrote on last edited by
        #4

        @kuzulis Thanks for your response, i have tried to access root and change the permissions with chmod. But, when i check in Terminal Emulator, actually the code for access root and change the permissions doesn't work well. This is my code for access root and change the permissions..

        MySerialPort::MySerialPort()
        {
           QProcess serialProcess;
                    serialProcess.start("su");
                    serialProcess.waitForStarted(10000);
                    serialProcess.execute("chmod 777 /dev/ttyUSB0");
                    serialProcess.waitForFinished();
        }
        
        void MySerialPort::openSerialPort()
        {
            serialAvailable = false;
            serialPortName = "";
            serial = new QSerialPort(this);
            connect(serial, &QSerialPort::readyRead, this, &MySerialPort::readData);
        
            qDebug() << "Number of available ports : " << QSerialPortInfo::availablePorts().length();
        
            foreach (const QSerialPortInfo &serialPortInfo, QSerialPortInfo::availablePorts()) {
                if(serialPortInfo.hasVendorIdentifier() && serialPortInfo.hasProductIdentifier()) {
                            serialPortName = serialPortInfo.portName();
                            serialAvailable = true;
                }
            }
         if(serialAvailable){
                //open and configure serial port
                serial->setBaudRate(QSerialPort::Baud9600);
                serial->setDataBits(QSerialPort::Data8);
                serial->setParity(QSerialPort::NoParity);
                serial->setStopBits(QSerialPort::OneStop);
                serial->setFlowControl(QSerialPort::NoFlowControl);
                serial->setPortName(serialPortName);
                serial->open(QIODevice::ReadWrite);
                qDebug() << "Connected to : " << serialPortName;
            }else{
                //give message error
                qCritical() << "Serial Port error : " << serial->errorString();
            }
        }
        
        1 Reply Last reply
        0
        • K Offline
          K Offline
          kuzulis
          Qt Champions 2020
          wrote on last edited by
          #5

          Did you check that your 'chmod' worked correctly?

          What happens if you try to use 'chmod' from the busybox (terminal console?) and then just call 'cat /dev/ttyUSB0' ?

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

            WOW, it is surprised to me, that seems an Android now has UART support. Also, seems, it is possible now to use the native C/C++ code to get access to the Peripheral I/O.

            UPD: Seems, all these features were added recently (in 2018 year) to Android Things Library.

            jsulmJ CaktozzC 2 Replies Last reply
            1
            • K kuzulis

              WOW, it is surprised to me, that seems an Android now has UART support. Also, seems, it is possible now to use the native C/C++ code to get access to the Peripheral I/O.

              UPD: Seems, all these features were added recently (in 2018 year) to Android Things Library.

              jsulmJ Offline
              jsulmJ Offline
              jsulm
              Lifetime Qt Champion
              wrote on last edited by
              #7

              @kuzulis You now can buy laptops with Android :-)

              https://forum.qt.io/topic/113070/qt-code-of-conduct

              aha_1980A 1 Reply Last reply
              0
              • jsulmJ jsulm

                @kuzulis You now can buy laptops with Android :-)

                aha_1980A Offline
                aha_1980A Offline
                aha_1980
                Lifetime Qt Champion
                wrote on last edited by
                #8

                @jsulm whoever want's to do so ;)

                Qt has to stay free or it will die.

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

                  UPD: Sadly, but, as I understand, it will work only on future "Android Things" devices (IoT). So, it is impossible to use it on any smartphone or a pad.

                  1 Reply Last reply
                  1
                  • K kuzulis

                    WOW, it is surprised to me, that seems an Android now has UART support. Also, seems, it is possible now to use the native C/C++ code to get access to the Peripheral I/O.

                    UPD: Seems, all these features were added recently (in 2018 year) to Android Things Library.

                    CaktozzC Offline
                    CaktozzC Offline
                    Caktozz
                    wrote on last edited by
                    #10

                    @kuzulis how can i access serial port? i can send in 'Terminal console' but not work with application (apk)

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

                      I don't know, seems you need to run your app as superuser. Or to use other tricks. Please search an answer in google, because this is not an Qt issue.

                      PS: QSP does not supported on Android anyway..

                      UPD2: At first, you can check that serial port permissions really changes. Just from your app run:

                                  serialProcess.start("su");
                                  serialProcess.waitForStarted(10000);
                                  serialProcess.execute("chmod 777 /dev/ttyUSB0");
                                  serialProcess.waitForFinished();
                      

                      and then from busy-box emulator try to check, using 'ls' command that now the serial port permissions stays as '777'.

                      If this will not help, then, maybe, you need to look on something like 'udev' analog on Android. Which can start required rule/action, e.g. when you insert/remove the USB/serial converter. E.g. it can change device permissions when you insert your USB/serial converter. But I'm not sure if this possible on Andrid, you need find it homself. ))

                      1 Reply Last reply
                      2
                      • Eremite88E Offline
                        Eremite88E Offline
                        Eremite88
                        wrote on last edited by
                        #12

                        https://github.com/olena-anufriieva/usb-serial-for-android

                        1 Reply Last reply
                        0
                        • CaktozzC Offline
                          CaktozzC Offline
                          Caktozz
                          wrote on last edited by
                          #13

                          Thank you for all who gave answers and who read this topic. May be useful
                          follow this link : FTDI

                          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