HowTo use QextSerialPort classes
As I've said I'm providing here more one howto
How to build attach and use in your QT application [ Qt 4.6.3 ( latest ) ]
External serial port classes:
1. Download qextserialport-1.2win-alpha archive
2. Unpack the archive to <serport classes path>
3. Open .pro file that in the unpacked folder
4. Make it next:
PROJECT = qextserialport
TEMPLATE = lib
CONFIG += debug_and_release
CONFIG += qt
CONFIG += warn_on
CONFIG += thread
CONFIG += dll
CONFIG += staticlib
QT -= gui
OBJECTS_DIR = build/obj
MOC_DIR = build/moc
DEPENDDIR = .
INCLUDEDIR = .
HEADERS = qextserialbase.h \
qextserialport.h \
qextserialenumerator.h
SOURCES = qextserialbase.cpp \
qextserialport.cpp \
qextserialenumerator.cpp
unix: HEADERS += posix_qextserialport.h
unix: SOURCES += posix_qextserialport.cpp
unix: DEFINES += _TTY_POSIX_
win32:HEADERS += win_qextserialport.h
win32:SOURCES += win_qextserialport.cpp
win32: DEFINES += _TTY_WIN_
win32:LIBS += -lsetupapi
DESTDIR = build
DESTDIR = examples/enumerator/debug
DESTDIR = examples/qespta/debug
DESTDIR = examples/event/debug
CONFIG(debug, debug|release) {
TARGET = qextserialportd
} else {
TARGET = qextserialport
}
unix: VERSION = 1.2.0
5. build the serial port classes project assosiated with the .pro file in debug and in release mode
6. building process should produce next files: qextserialportd.dll, qextserialport.dll,libqextserialport.a in /build directory of the project
7. Each time you create new Qt project add next lines to the .pro file:
INCLUDEPATH += <serport classes path>qextserialport-1.2win-alpha
QMAKE_LIBDIR += <serport classes path>qextserialport-build-desktop\build
CONFIG(debug, debug|release):LIBS += -lqextserialportd
else:LIBS += -lqextserialport
unix: DEFINES = _TTY_POSIX_
win32: DEFINES = _TTY_WIN_
in appropriated positions in your application .pro file
8. Enjoy using RS232 with Qt
Pavel
pmazniker@gmail.com
Re: HowTo use QextSerialPort classes
I've tried this but I haven't had any luck on win7.
I get the following error with both QextSerialPort and QSerialDevice:
:: error: cannot find -lqextserialportd
Neither can I manage to access the serial port using straightforward winapi, it gives the error file not found when I'm trying to open the port COM1.
Right now I can only manage to make it work on visual basic, I need help :confused:
EDIT: actually, I've managed to build a project now by following your steps more throughly (there were some problems with directories) but whenever I'm trying to run the program, it crashes with error code -1073741515. I've tried both the enumerator and event programs provided in the examples.
Re: HowTo use QextSerialPort classes
<< I get the following error with both QextSerialPort and QSerialDevice:
:: error: cannot find -lqextserialportd
>>is there extserialportd.dll in build directory? Did you build in release or in debug? What .pro file did you use?
<<EDIT: actually, I've managed to build a project now by following your steps more throughly (there were some problems with directories) but whenever I'm trying to run the program, it crashes with error code -1073741515. I've tried both the enumerator and event programs provided in the examples.
>>Try Linux hhh
Re: HowTo use QextSerialPort classes
Ok, I finally managed to make it work.
I'm new to Qt, so I still don't know very well how .pro files behave.
If you are having problems to make the examples work in windows 7 do the following:
1 - Create a new Qt project (Qt Console Application) in the folder myQext (you can put it anywhere)
2 - copy all the .h and .cpp files from the "qextserialport-1.2win-alpha" folder to the myQext folder. That should be 10 files.
3 - copy the PortListener.h and PortListener.cpp files from "qextserialport-1.2win-alpha/examples/event/"
4 - Add all those 12 files to your project.
5 - replace the contains of your main.cpp file by the main.cpp file in the event folder.
6 - Save all. Run qmake. Build all. Execute.
*note: you do not need to edit the .pro file.
Re: HowTo use QextSerialPort classes
Great!
It is good way to use QextSerialPort
Actually you can build your project in different ways - you can attach classes to your project or you can build classes separeted into static or dynamica library and then attach them to your project by editing .pro file and using the libraries
What if you need to attach more weighted third party project to your one?
For example QWT?
1 Attachment(s)
Re: HowTo use QextSerialPort classes
From my experience, I've got those errors either when a pointer wasn't initialized properly or when there was a mess in a .pro file.
If you are using Qext as a dll I don't know what to advise you. Anyway I've attached a serial console I've made, it might help. It is very straightforward.
Re: HowTo use QextSerialPort classes
Also, I've tried QSerialDevice but I didn't have any luck compiling it so I gave up on it.
Re: HowTo use QextSerialPort classes
Hey people.
first off all, i will say that, im building a program in QT creator 2 (4.7) on win 7, a part of the program should could control the RTS and DTR or just turn the port on off.
after following concret instructions from handi (and others), i get tons off errors (139 to be specific) trying to build it.
Most off the errors or in/regarding posix.serialport.h and .cpp
its errors like, termios.h no such file...
and Posix_CommConfig not declared in this scope.
and so on.
thanks you so far.
Re: HowTo use QextSerialPort classes
Okay i finaly got it all working.
I followd freely's guide. im working on a windows 7 ultimate 32 bit.
thank you.
Re: HowTo use QextSerialPort classes
Hello.
Im trying to make a simple program to turn a com port on/off with a button.
also a button to turn DTR on/of , and a button for the RTS on/off, but im having a hard time understanding the documentation to qext. (its by the way working like a charm)
hope you guys can help me a little.
Re: HowTo use QextSerialPort classes
Hi
You are right
It is possible to have such errors.
I've tried to build all QextSerialPort classes to external dll or .lib and use them in next projects as nessesary
BUT!
Because of possible erorrs as from feedback here and from my personal exp. using classes DIRECTLY in you project will minimize possible errors to zero and 'll help you to understand how such serial port driver works
So unless thie you have conditional compilation directives in QextSerialPort classes ( such as #ifdef etc.) you should have no problems with crossplatform use
You can delete by hand all POSIX includes ( that are for LINUX) as I made in my project
Re: HowTo use QextSerialPort classes
I've begun new project using QExtSerialPort
I use QExtSerialPort classes directly without build them to .dll or to .lib as one guy adviced me here and it works pretty good at least in WinXP
I've maid some custom changed to QExtSerialPort classes to work only for Windows
I still have small drawbacks in how that classes work. ( It takes to much time to read for example)
Lets discuss.
Re: HowTo use QextSerialPort classes
I was able to use Handi's instructions without any problems.
Thanks.
Re: HowTo use QextSerialPort classes
hello,
I am using QT4,
I did not find posix* files in this archive
where could I get this Class for Linux?
thank you in advice
Re: HowTo use QextSerialPort classes
This is full code (Windows, Linuks, Mac) of QExtSerialPort.