Results 1 to 17 of 17

Thread: HowTo use QextSerialPort classes

  1. #1
    Join Date
    Jul 2010
    Posts
    72
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4 Qt/Embedded Qt Jambi
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default 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

  2. #2
    Join Date
    Jul 2010
    Posts
    13
    Thanks
    1
    Thanked 2 Times in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default 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


    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.
    Last edited by Handi; 29th July 2010 at 05:19.

  3. #3
    Join Date
    Jul 2010
    Posts
    72
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4 Qt/Embedded Qt Jambi
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default 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

  4. #4
    Join Date
    Jul 2010
    Posts
    13
    Thanks
    1
    Thanked 2 Times in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default 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.

  5. #5
    Join Date
    Jul 2010
    Posts
    72
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4 Qt/Embedded Qt Jambi
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default 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?

  6. #6
    Join Date
    Jul 2010
    Posts
    72
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4 Qt/Embedded Qt Jambi
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default QSerialDevice

    I've found other classes developed in 2009 by some Russian developer to work with Serial Port in Qt:
    http://qt-apps.org/content/show.php?content=112039

    this is alternative to QextSerialPort

    what do you think about it?
    Did you try to use it?
    What is more reliable and robust QextSerialPort or QSerialDevice?

  7. #7
    Join Date
    Jul 2010
    Posts
    72
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4 Qt/Embedded Qt Jambi
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: QSerialDevice

    Today I have the same problem with mingw when I try to compile QextSerialPort
    mingw32-make: *** [makefile] Error -1073741819

    why?

  8. #8
    Join Date
    Jul 2010
    Posts
    13
    Thanks
    1
    Thanked 2 Times in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default 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.
    Attached Files Attached Files

  9. The following 2 users say thank you to Handi for this useful post:

    amits (17th September 2011), misiekse1 (5th May 2012)

  10. #9
    Join Date
    Jul 2010
    Posts
    13
    Thanks
    1
    Thanked 2 Times in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default 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.

  11. #10
    Join Date
    Aug 2010
    Posts
    3
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default 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.

  12. #11
    Join Date
    Aug 2010
    Posts
    3
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default 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.
    Last edited by cazc; 23rd August 2010 at 11:00.

  13. #12
    Join Date
    Aug 2010
    Posts
    3
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default 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.

  14. #13
    Join Date
    Jul 2010
    Posts
    72
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4 Qt/Embedded Qt Jambi
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default 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

  15. #14
    Join Date
    Jul 2010
    Posts
    72
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4 Qt/Embedded Qt Jambi
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default 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.

  16. #15
    Join Date
    Jul 2011
    Posts
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: HowTo use QextSerialPort classes

    I was able to use Handi's instructions without any problems.

    Thanks.
    Last edited by mssue; 15th July 2011 at 19:11.

  17. #16
    Join Date
    Oct 2014
    Posts
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default 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

  18. #17
    Join Date
    Mar 2008
    Location
    Kraków, Poland
    Posts
    1,536
    Thanked 284 Times in 279 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: HowTo use QextSerialPort classes

    This is full code (Windows, Linuks, Mac) of QExtSerialPort.

Similar Threads

  1. Howto: Qt and RSA crypto
    By jonks in forum Qt Programming
    Replies: 15
    Last Post: 21st April 2010, 16:15
  2. Howto use Qt with Boost ?
    By bilgenratte in forum Qt Programming
    Replies: 3
    Last Post: 1st October 2009, 15:12
  3. HowTo Debug
    By SenSej in forum Newbie
    Replies: 0
    Last Post: 17th October 2008, 13:45
  4. Plugins HowTo?
    By Royceybaby in forum Qt Programming
    Replies: 4
    Last Post: 18th October 2006, 16:55
  5. QTreeWidgetItemIterator howto
    By seneca in forum Qt Programming
    Replies: 4
    Last Post: 17th January 2006, 09:26

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.