PDA

View Full Version : Serial communication program in QT



pupqt
22nd March 2011, 08:35
Hello frnz,

am new to QT and am supposed to build an application in linux QT for serial communication. As Trolltech has not provided any class to facilitate serial communication, I have downloaded "qextserialport-1.1.tar.gz" from http://qextserialport.sourceforge.net.

Now I want to know the procedure to compile in linux qt and make use of the classes just similar to other classes of QT.

Please help me
Thank u

mcosta
22nd March 2011, 08:50
QextSerialPort must be compiled using qmake



qmake qextserialport.pro
make

BalaQT
22nd March 2011, 08:53
hi,
if u hav a pro file in the source, just compile as normal qt program.
u need to create the lib from the downloaded source. and then link this lib in ur application.

hope it helps
Bala

pupqt
22nd March 2011, 09:07
Hii

Im working in QT 4, with linux and developing serial communication prog in QT. So i down loaded "qextserialport-1.1.tar.gz" from http://qextserialport.sourceforge.net

Please dictate me the procedure to install it in QT of linux, So that I can access those classes as same as other classes of QT.

Thank u

mcosta
22nd March 2011, 09:35
please don't post in multiple Forum http://www.qtcentre.org/threads/39897-Serial-communication-program-in-QT

littletux
22nd March 2011, 09:40
Hi,

there has been a similar thread recently, see http://www.qtcentre.org/threads/39408-making-GUI-for-serial-port-communication-using-qt-creator?p=180873#post180873

In any case, if you need to use the qextserialport library, you should use the code from http://code.google.com/p/qextserialport. There are some examples in the "examples" directory.

Thanks,
Andreas

kuzulis
22nd March 2011, 09:49
2 pupqt,

If you're new and are not afraid of the GPL license, use QSerialDevice: http://gitorious.org/qserialdevice/qserialdevice/trees/master
Direct download: http://gitorious.org/qserialdevice/qserialdevice/archive-tarball/master

This library is better than QExtSerialPort.
It has good documentation, many examples, it is simple and is developing at the current time (Unlike other libraries).

PS: Although use any library that you like.

pupqt
24th March 2011, 06:12
hi,
if u hav a pro file in the source, just compile as normal qt program.
u need to create the lib from the downloaded source. and then link this lib in ur application.

hope it helps
Bala


Hii,

I tried the method u explained, I came with some errors so I think clarification is required.

The downloaded source is "qextserialport-1.1.tar.gz" from "http://qextserialport.sourceforge.net/qextserialport-1.0.x/" website.

I followed the following steps:
1. Extracted archive
2. I got qextserialport folder containing these files:
examples
Doxyfile
html
Doc
CHANGES
posix_qextserialport.cpp
posix_qextserialport.h
qextserialport.pro
qextserialport.cpp
win_qextserialport.cpp
win_qextserialport.h
qextserialbase.cpp
qextserialbase.h

3. Copied this qextserialport folder in the src folder of QT software running in linux.
4. gave command qmake qextserialport.pro
5. Then gave command make

then list of errors came saying:

[root@w2kserver qextserialport]# qmake qextserialport.pro


[root@w2kserver qextserialport]# make


g++ -c -pipe -Wall -W -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32 -march=i386 -mtune=generic -fasynchronous-unwind-tables -D_REENTRANT -fPIC -D_TTY_POSIX_ -DQT_NO_DEBUG -DQT_THREAD_SUPPORT -DQT_SHARED -I/usr/lib/qt-3.3/mkspecs/default -I. -I/usr/lib/qt-3.3/include -Ibuild/moc/ -o build/obj/qextserialbase.o
qextserialbase.cpp
In file included from qextserialbase.cpp:2:


qextserialbase.h:5:21: error: QIODevice: No such file or directory
qextserialbase.h:6:17: error: QFile: No such file or directory
qextserialbase.h:9:19: error: QThread: No such file or directory
qextserialbase.h:10:18: error: QMutex: No such file or directory
qextserialbase.h:137: error: ‘ulong’ does not name a type

qextserialbase.h:138: error: ‘ulong’ does not name a type

qextserialbase.h:141: error: expected class-name before ‘{’ token
qextserialbase.h:144: error: expected ‘,’ or ‘...’ before ‘&’ token

qextserialbase.h:144: error: ISO C++ forbids declaration of ‘QString’ with no type
qextserialbase.h:147: error: expected ‘,’ or ‘...’ before ‘&’ token


Have I followed the correct method. Before giving qmake command, *.pro file needs to be configured??????

marcvanriet
24th March 2011, 12:34
Do you have QtCreator on your system ?
If so, create a simple 'hello world' application and try to run and compile that. If this is OK, then your Qt installation is (probably) OK.
Then, open the qextserialport.pro file using Qt Creator and do a 'build all'

By the way, you didn't put the qextserialport source under the src directory of Qt itself did you ? You should put things like this in your own personal folder where you keep your Qt projects.

Regards,
Marc

high_flyer
24th March 2011, 12:51
g++ -c -pipe -Wall -W -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32 -march=i386 -mtune=generic -fasynchronous-unwind-tables -D_REENTRANT -fPIC -D_TTY_POSIX_ -DQT_NO_DEBUG -DQT_THREAD_SUPPORT -DQT_SHARED -I/usr/lib/qt-3.3/mkspecs/default -I. -I/usr/lib/qt-3.3/include -Ibuild/moc/ -o build/obj/qextserialbase.o
qextserialbase.cpp
In file included from qextserialbase.cpp:2:


qextserialbase.h:5:21: error: QIODevice: No such file or directory
You don't have Qt4 installed.
You need Qt4.
Install Qt4 first.
Or get a previous version of QextSerialPort which is based on Qt3.

schnitzel
24th March 2011, 21:59
The downloaded source is "qextserialport-1.1.tar.gz" from "http://qextserialport.sourceforge.net/qextserialport-1.0.x/" website.


qextserialport is no longer hosted on sourceforge - please go to http://code.google.com/p/qextserialport like littletux suggested. Plus, you should follow the suggestion by high_flyer and install Qt4 (if possible).

qextserialport has been discussed many times in this forum. It is a library and it comes with examples. If you study and understand how the examples use the library then you are well on your way.

pupqt
25th March 2011, 11:49
Do you have QtCreator on your system ?
If so, create a simple 'hello world' application and try to run and compile that. If this is OK, then your Qt installation is (probably) OK.
Then, open the qextserialport.pro file using Qt Creator and do a 'build all'

By the way, you didn't put the qextserialport source under the src directory of Qt itself did you ? You should put things like this in your own personal folder where you keep your Qt projects.

Regards,
Marc




Hi Marc,

great!!! I cud get .so files :)
Now i will copy those files to usr/lib folder to access qextserial port as global class.

anything else i need to be consider before doing so?? I mean to tell setting path or changing .pro file?