Results 1 to 18 of 18

Thread: Windows programming in Qt (serial communication)

  1. #1
    Join Date
    Jan 2008
    Posts
    155
    Thanks
    4
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default 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
    Last edited by bnilsson; 28th June 2008 at 17:32.
    MacOSX user dabbling with Linux and Windows.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,363
    Thanks
    3
    Thanked 5,012 Times in 4,791 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Windows programming in Qt (serial communication)

    How about using QExtSerialPort instead?

  3. #3
    Join Date
    Jan 2008
    Posts
    155
    Thanks
    4
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Windows programming in Qt (serial communication)

    How about using QExtSerialPort instead?
    I would love to.
    Where is it documented? There is nothing about it in my Assistant.
    MacOSX user dabbling with Linux and Windows.

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,363
    Thanks
    3
    Thanked 5,012 Times in 4,791 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

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

  5. #5
    Join Date
    Jan 2008
    Posts
    155
    Thanks
    4
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default 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
    MacOSX user dabbling with Linux and Windows.

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,363
    Thanks
    3
    Thanked 5,012 Times in 4,791 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Windows programming in Qt (serial communication)

    I assure you it works fine on Windows.

  7. #7
    Join Date
    Jan 2008
    Posts
    155
    Thanks
    4
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Windows programming in Qt (serial communication)

    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:
    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:

    ################################################## ####################
    # 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

    unixEFINES = _TTY_POSIX_
    win32EFINES = _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
    MacOSX user dabbling with Linux and Windows.

  8. #8
    Join Date
    Jan 2008
    Posts
    155
    Thanks
    4
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Windows programming in Qt (serial communication)

    I found the problem.

    After changing
    unixEFINES = _TTY_POSIX_
    win32EFINES = _TTY_WIN_ QWT_DLL QT_DLL
    to
    unixEFINES = _TTY_POSIX_
    win32EFINES = _TTY_WIN_
    it worked.

    BN
    MacOSX user dabbling with Linux and Windows.

  9. #9
    Join Date
    Jan 2008
    Posts
    155
    Thanks
    4
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default 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
    Last edited by bnilsson; 3rd July 2008 at 21:39.
    MacOSX user dabbling with Linux and Windows.

  10. #10
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,363
    Thanks
    3
    Thanked 5,012 Times in 4,791 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

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

  11. #11
    Join Date
    Sep 2009
    Posts
    39
    Thanks
    3
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Question 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

  12. #12
    Join Date
    Jan 2008
    Posts
    155
    Thanks
    4
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default 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
    MacOSX user dabbling with Linux and Windows.

  13. #13
    Join Date
    Sep 2009
    Posts
    39
    Thanks
    3
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

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

  14. #14
    Join Date
    Sep 2009
    Location
    UK
    Posts
    2,447
    Thanks
    6
    Thanked 348 Times in 333 Posts
    Qt products
    Qt4
    Platforms
    Windows

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

  15. The following user says thank you to squidge for this useful post:

    Rajeshsan (29th October 2009)

  16. #15
    Join Date
    Sep 2009
    Posts
    39
    Thanks
    3
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: Windows programming in Qt (serial communication)

    thank you....

  17. #16
    Join Date
    Sep 2009
    Location
    UK
    Posts
    2,447
    Thanks
    6
    Thanked 348 Times in 333 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Windows programming in Qt (serial communication)

    No error messages or anything, it just didn't build the library?

  18. #17
    Join Date
    Jan 2009
    Location
    Russia
    Posts
    308
    Thanks
    2
    Thanked 43 Times in 42 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Windows programming in Qt (serial communication)


  19. #18
    Join Date
    Apr 2009
    Posts
    58
    Thanks
    3
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default 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.
    Qt Code:
    1. Running build steps for project QESPTA...
    2. Starting: /usr/bin/qmake /Users/admin/Desktop/QT/qextserialport/examples/qespta/QESPTA.pro -spec macx-g++ -r CONFIG+=debug_and_release -win32
    3. Exited with code 0.
    4. Starting: /usr/bin/make debug -w
    5. make: *** No rule to make target `\usr\local\Qt4.6\mkspecs\macx-g++\qmake.conf', needed by `Makefile'. Stop.
    6. make: Entering directory `/Users/admin/Desktop/QT/qextserialport/examples/qespta'
    7. make: Leaving directory `/Users/admin/Desktop/QT/qextserialport/examples/qespta'
    8. Exited with code 2.
    9. Error while building project QESPTA
    10. When executing build step 'Make'
    To copy to clipboard, switch view to plain text mode 
    Last edited by anupamgee; 9th February 2010 at 18:19. Reason: wrong use of CODE tag

Similar Threads

  1. Windows not appearing in XP.
    By beardybloke in forum Qt Programming
    Replies: 7
    Last Post: 24th October 2007, 17:32
  2. converting unix exe to windows binary
    By deekayt in forum General Programming
    Replies: 2
    Last Post: 17th September 2006, 01:00
  3. Experience using KDevelop with Cygwin under windows
    By high_flyer in forum General Discussion
    Replies: 4
    Last Post: 11th September 2006, 16:50
  4. Programming in Windows
    By kroenecker in forum General Programming
    Replies: 9
    Last Post: 4th July 2006, 18:49
  5. MDI windows without QWorkspace
    By Big Duck in forum Newbie
    Replies: 2
    Last Post: 16th June 2006, 17:15

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.