Windows programming in Qt (serial communication)
Hello!
I want to write a Qt application that will use serial communication on WinXP hardware.
Qt is cross-platform while serial communication programming is not.
I have VERY little knowledge about Windows programming in general, while I have made som working stuff for Mac and WinXP using Qt, where you never see the platform specific calls.
I have written a serial "driver" a long time ago using another cross-platform framework, but it does of course not compile in Qt, but I have the basic functionality. I was using Codewarrior and CPLAT, which are both more or less dead nowadays. Qt seems to be a worthy successor, I like it very much.
Now, how do I write a Windows-specific class inside a Qt project?
What headers should I include to have access to HANDLE and DCB structures, hComPort, etc? What Windows libraries do I need?
Any help is appreciated.
BN
Re: Windows programming in Qt (serial communication)
How about using QExtSerialPort instead?
Re: Windows programming in Qt (serial communication)
Quote:
How about using QExtSerialPort instead?
I would love to.
Where is it documented? There is nothing about it in my Assistant.
Re: Windows programming in Qt (serial communication)
It's not part of Qt distribution but an external class. It's at sourceforge. If you can't find it, google for it.
Re: Windows programming in Qt (serial communication)
Found it and downloaded it.
It built and ran on MacOSX and Linux, but surprisingly enough it did not build on Windows.
In Version 1.1 the library built but not the example.
In Version 1.2 (newer, tuned for windows) it did not even build the library.
I have worked with it only a few hours so far, but not so good.
On Mac and Linux I only did a dryrun without actual ports attached, I will try it out tomorrow.
I am using Qt.4.4.0.
BN
Re: Windows programming in Qt (serial communication)
I assure you it works fine on Windows.
Re: Windows programming in Qt (serial communication)
Quote:
I assure you it works fine on Windows.
I am happy to hear that it works for you.
I just unpacked it, did "qmake" at the directory root, and then "qmake" at ./examples/qespta.
Here is a small part of the errors, I had to expand the WinXP Command Tool to 2000 lines:
Quote:
C:\Documents and Settings\bnilsson\My Documents\Qt\qextserialport\examples\qespta>make
make -f Makefile.Debug
make[1]: Entering directory `C:/Documents and Settings/bnilsson/My Documents/Qt/qextserialport/examp
les/qespta'
g++ -enable-stdcall-fixup -Wl,-enable-auto-import -Wl,-enable-runtime-pseudo-reloc -mthreads -Wl -Wl
,-subsystem,windows -o debug\qespta.exe obj/main.o obj/MainWindow.o obj/MessageWindow.o obj/QespTest
.o obj/moc_MainWindow.o obj/moc_MessageWindow.o obj/moc_QespTest.o -L"..\..\build" -L"c:\Qt\4.4.0\l
ib" -lmingw32 -lqtmaind -lqextserialport -lQtGuid -lgdi32 -lcomdlg32 -loleaut32 -limm32 -lwinmm -lwi
nspool -lmsimg32 -lQtCored -lkernel32 -luser32 -lshell32 -luuid -lole32 -ladvapi32 -lws2_32
obj/main.o(.text+0x161): In function `Z5qMainiPPc':
C:/Documents and Settings/bnilsson/My Documents/Qt/qextserialport/examples/qespta/main.cpp:19: undef
ined reference to `_imp___ZN12QApplicationC1ERiPPci'
obj/main.o(.text+0x179):C:/Documents and Settings/bnilsson/My Documents/Qt/qextserialport/examples/q
espta/main.cpp:21: undefined reference to `_imp___Z18qInstallMsgHandlerPFv9QtMsgTypePKcE'
obj/main.o(.text+0x217):C:/Documents and Settings/bnilsson/My Documents/Qt/qextserialport/examples/q
espta/main.cpp:25: undefined reference to `_imp___ZN12QApplication4execEv'
obj/main.o(.text$_ZN10MainWindowD1Ev[MainWindow::~MainWindow()]+0x22): In function `ZN7QStringC1EPKc
':
c:/Qt/4.4.0/include/QtCore/../../src/corelib/arch/qatomic_windows.h: undefined reference to `_imp___
ZN11QMainWindowD2Ev'
I guess this has nothing to do with the serial port code, it looks like it does not link to Qt itself(?)
I have other Qt projects that works, so my installation seems to be ok.
Here is the .pro file:
Quote:
################################################## ####################
# QextSerialPort Test Application (QESPTA)
################################################## ####################
PROJECT = QESPTA
TEMPLATE = app
DEPENDPATH += .
INCLUDEPATH += ../..
QMAKE_LIBDIR += ../../build
OBJECTS_DIR = obj
MOC_DIR = moc
UI_DIR = uic
CONFIG += qt thread warn_on
HEADERS += MainWindow.h \
MessageWindow.h \
QespTest.h
SOURCES += main.cpp \
MainWindow.cpp \
MessageWindow.cpp \
QespTest.cpp
LIBS += -lqextserialport
unix:DEFINES = _TTY_POSIX_
win32:DEFINES = _TTY_WIN_ QWT_DLL QT_DLL
I know this is not your stuff, but it will probably take longer for me to contact the authors themselves, and you may have a simple solution.
It will be essential for me to have access to a working example.
Thanks,
BN
Re: Windows programming in Qt (serial communication)
I found the problem.
After changing
Quote:
unix:DEFINES = _TTY_POSIX_
win32:DEFINES = _TTY_WIN_ QWT_DLL QT_DLL
to
Quote:
unix:DEFINES = _TTY_POSIX_
win32:DEFINES = _TTY_WIN_
it worked.
BN
Re: Windows programming in Qt (serial communication)
Having looked through the latest version of QextSerialPort-1.2, it seems a very important feature, the QextSerialEnumerator, is not implemented for POSIX systems.
Is this not done because of any thecnical difficulties?
Or just lack of interest or time?
I would like to ecourage anybody with the required skill to do this, since without it this class may be a bit difficult to use.
BN
Re: Windows programming in Qt (serial communication)
I'm gathering time and motivation to take the ext serial port code and continue its development as it seems the original maintainer is not interested in it. Enumerating ports in POSIX systems is harder as there is no single way of determining what is and what is not a serial port. Even if you do it on one system (like Linux) it can be completely different on another (like Solaris).
Re: Windows programming in Qt (serial communication)
HI in working on Qt. I have installed QT SDK on my PC(WINDOWS XP).Plz i need a assistance from all those who worked on Qt serial port communication. How to do it on windows PC i ahve Windows XP OS. From where i can download code, wat must be done to to start serial port communication, Plz its urgent for me. I hope some can assist me for my problem waiting for your reply soon..
Mainly what is the procedure to be once i got Zip file of Qtextserail,then how to work on it to get serial port communication on My PC. I need assistance its urgent for me. Or mail me to vinay_sjcit@yahoo.com. I need help. PLz
Thanking in advance:(
Re: Windows programming in Qt (serial communication)
Please check http://code.google.com/p/qextserialport/
This project is actually alive, while the one on sourceforge is not.
I was able to us it successfully with the help of the examples.
BN
Re: Windows programming in Qt (serial communication)
Hi......... Thank you bnilsson I saw your link. I need help like what i want to do now. like whether there is any code dierectly i can build on my Windows PC and check out Serial port on COM 1... Im very happy atleast you replied and gave some ideas. thank you. Plz can you give your gmail or yahoo ID.. i need to Discuss with you more still i get my port communication starts. Plz kindly provide me help from experience on this.:(
Re: Windows programming in Qt (serial communication)
qextserialport comes with lots of example which should get you started.
It's bad etiquette to ask for someones private email/IM address to discuss your problems.
Re: Windows programming in Qt (serial communication)
Re: Windows programming in Qt (serial communication)
No error messages or anything, it just didn't build the library?
Re: Windows programming in Qt (serial communication)
Re: Windows programming in Qt (serial communication)
thanks for doing that i think the repository on google projects is getting updated for other platforms like MAC OS X, the serial port lib on sourceforge compiles successfully, but I am facing problems in compiling the QESPTA example from the QT Creator, gives the following compiler output:
make: *** No rule to make target `\usr\local\Qt4.6\mkspecs\macx-g++\qmake.conf', needed by `Makefile'. Stop.
Code:
Running build steps for project QESPTA...
Starting: /usr/bin/qmake /Users/admin/Desktop/QT/qextserialport/examples/qespta/QESPTA.pro -spec macx-g++ -r CONFIG+=debug_and_release -win32
Exited with code 0.
Starting: /usr/bin/make debug -w
make: *** No rule to make target `\usr\local\Qt4.6\mkspecs\macx-g++\qmake.conf', needed by `Makefile'. Stop.
make: Entering directory `/Users/admin/Desktop/QT/qextserialport/examples/qespta'
make: Leaving directory `/Users/admin/Desktop/QT/qextserialport/examples/qespta'
Exited with code 2.
Error while building project QESPTA
When executing build step 'Make'