Solved FTDI with Android (Odroid XU4)
-
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.
-
@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(); } }
-
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' ?
-
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.
-
@kuzulis You now can buy laptops with Android :-)
-
@jsulm whoever want's to do so ;)
-
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.
-
@kuzulis how can i access serial port? i can send in 'Terminal console' but not work with application (apk)
-
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. ))
-
-
Thank you for all who gave answers and who read this topic. May be useful
follow this link : FTDI