PDA

View Full Version : Serial Port in Android



Girish1483
4th February 2014, 05:51
Hi,
I am using QT5.2 Android
How to use read & write serial port data in android?

ChrisW67
4th February 2014, 06:06
What have you found already? What have you tried?

Girish1483
4th February 2014, 06:17
I used QtSerial port API for Windows & Ubuntu 12.04 (i.e Desktop based Application as well as embedded linux).It's working fine.
But i don't know how to do in Qt5.2 Android.

kuzulis
4th February 2014, 06:59
But i don't know how to do in Qt5.2 Android.

Same as in others OS. The only thing it is correct to build and to install of QtSerialPort manually from the source codes. For this purpose I recommend to use QtCreator. Details see in WIKI (http://qt-project.org/wiki/QtSerialPort).

Girish1483
10th February 2014, 05:54
Thanks,I done it.

abin
1st November 2014, 12:59
Hi,
I am also able to build my code with serial port print in android platform. When I run the application in android I can read port names with help of QSerialPortInfo. But I am unable to open the port as error "Permission denied" is thrown.

I've read that I need to root the android on my device with permission to port folders. I am not clear about the steps not even practical to me to root all devices on which I install my application.

Is there a way to do it?

Thanks in advance. :)

kuzulis
2nd November 2014, 21:03
Is there a way to do it?

No. Android has not a public API to use of serial port. You should root each of your device to start application from the root rights (or to set desired acces to /dev/ttyXX devices when reboot).
This option are available (make sense) if you is a developer of custom Android's firmware (e.g. provide a ready made devices as vendor).

Also it is possible to use the "USB host mode" (in case if you planns to use USB/Serial converters as serial ports role).
In this case there are a patch: https://codereview.qt-project.org/#/c/84338/ . But this patch is incomplete and you should to fix it himself.
Or to write a JAVA wrapper manually, using https://github.com/mik3y/usb-serial-for-android project (since this patch based on this project).

So, no other ways available (unfortunately).

phyatt
2nd April 2015, 18:53
I put some time into getting Qt + Android + QtSerialPort to work from a windows computer.

I used the referenced patch and got it working! It wasn't as straight forward as I thought it would be so I documented the steps somewhat.

I wrote a blog post about how I went about it. It works really well when it was all done.

I also needed to do my own JNI calls, too, so I ended up copying the UsbJNIActivity and inserting my own code.

http://phyatt.t15.org/wp/2015/04/qt-android-serial-port/

Hope that helps.

tang
8th May 2015, 15:55
hi,I have tried your way,but it didn't work. In your way ,i download the QtSerialPort for android by Mike Goza ttps://codereview.qt-project.org/#/c/84338/.Then when I try to open it,it makes mistakes.
" ç³»ç»Ÿæ‰¾ä¸åˆ°æŒ‡å®šçš è·¯å¾„ã€‚
Project MESSAGE: perl -w F:\Android\5.4\android_armv7\bin\syncqt.pl -module QtSerialPort -version 5.5.0 -outdir F:/code/build-qtserialport-Android_for_armeabi_v7a_GCC_4_9_Qt_5_4_1-Debug F:/code/qtserialport
ç³»ç»Ÿæ‰¾ä¸åˆ°æŒ‡å®šçš è·¯å¾„ã€‚
Project MESSAGE: cmake executable not found. Not running CMake unit tests
Project MESSAGE: perl -w F:\Android\5.4\android_armv7\bin\syncqt.pl -module QtSerialPort -version 5.5.0 -outdir F:/code/build-qtserialport-Android_for_armeabi_v7a_GCC_4_9_Qt_5_4_1-Debug F:/code/qtserialport
ç³»ç»Ÿæ‰¾ä¸åˆ°æŒ‡å®šçš è·¯å¾„ã€‚
Project MESSAGE: cmake executable not found. Not running CMake unit tests "
I don't know how to fix it.Can you help me ? thank you.

d_stranz
8th May 2015, 16:03
Project MESSAGE: cmake executable not found.

You need to download and install CMake and ensure that the cmake executable is in your system path.