Serial Communication permissions from Qt on Android



  • Hi everybody,
    I'm trying to connect an Arduino device to my Qt Android App.
    When I run it from ubuntu, first I'm not able to connect to my serial port because I need to give permissions, it's easy solved typing this on Ubuntu terminal:

    sudo chmod a+rw /dev/ttyACM0
    

    When I connect Arduino on the App running on Android Device, I'm not able to connect and I don't know what I have to do (if it's possible I would like to solve it without having to root my Android device).
    There is a way to give permissions inside Qt Code?

    I've tried with:

    mySerialPort->open(QSerialPort::ReadWrite);
    

    And then to see the permissions:

    if(mySerialPort->isWritable())
          qInfo("Is writable");
    else
          qInfo("Is not writable");
    if(mySerialPort->isReadable())
          qInfo("Is readable");
    else
          qInfo("Is not readable");
    

    And until I set permissions through Ubuntu terminal, I haven't got Read/Write permissions. So on my Android device, I'm not able to connect.

    Any help will be very appreciated,
    Thank you very much.


  • Lifetime Qt Champion

    Hi,

    Take a look at this thread it contains some interesting pointers.

    Warning: your "easy solution" on Ubuntu is just opening a security hole on your system. Now everybody can read and write on the serial port. The correct way to get the permissions to the serial port is to make you user member of the group that has access to the device.



  • @SGaist
    "The correct way to get the permissions to the serial port is to make you user member of the group that has access to the device".
    I don't understand what it really means.
    And refering to the thread you linked, I saw before, but I don't really understand it. (I don't know either which comment is the good one).
    My purpose is connecting with Arduino, and I'm afraid that it doesn't use FTDI chip.
    Thanks.


  • Moderators

    @carles.sole.grau You should read about user and groups on UNIX/Linux. You just need to add your user to the group which has access rights for the serial port.
    Use

    ls -lh /dev/ttyACM0
    

    to see what the group is. Then add your user to that group:

    useradd -G {group-name} username
    


  • So, anybody has tried to send serial data with Qt on Android?
    I've found this: https://www.allaboutcircuits.com/projects/communicate-with-your-arduino-through-android/
    But it's in pure Java, so I think that is not the way.


Log in to reply
 

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