Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Create a simple RS232 interface

Create a simple RS232 interface

Scheduled Pinned Locked Moved General and Desktop
23 Posts 5 Posters 16.0k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Q Offline
    Q Offline
    qt52
    wrote on 14 Nov 2012, 08:16 last edited by
    #1

    Dear All,

    I'm beginner in this Qt programming and also first time doing windows programming. But this couple of week i did tried some basic tutorial from youtube and learn some basic QObject function like horizontalSlider, spinbox, comboBox, pushButton, Edit Signal/Slot, Edit buddies, and so on...

    Now i would like to try some simple RS232 interface with my uC board but I'm lose when doing testing. Following is one of my tutorials, i able to compile the library using Command Prompt then after this I’m not sure how to continue already...
    http://www.instructables.com/id/Control-your-arduino-from-your-PC-with-the-Qt-Gui/step2/Installation-of-the-library/
    I have followed the instruction put the libqextserialportd.a in correct directory (mention in portcomsender.pro)

    @This are the to line you have to add
    INCLUDEPATH += C:/Qt/qextserialport-1.2win-alpha/
    LIBS += C:\Qt\qextserialport-1.2win-alpha\build\libqextserialportd.a@

    but when run the sample code it show the error

    Error while building project portcomsender (target: Bureau)
    When executing build step 'qmake'

    "qextserialport":http://docs.qextserialport.googlecode.com/git/1.2/index.html
    I also found one QextSerialPort Manual from Qt and this tutorial i also stuff up at "2. Goto qextserialport/buildlib, and run following command to generate library. (Yes, config.pri is not needed.)"
    I have try this 2 library qextserialport-1.2beta2 and qextserialport-1.2win-alpha.

    Now i'm very confusing and don't know how to move forward.. Can anyone kindly show me the step how to do it?

    Thank you,..

    1 Reply Last reply
    0
    • J Offline
      J Offline
      jalomic
      wrote on 14 Nov 2012, 08:43 last edited by
      #2

      Try to include lib like this:
      LIBS += -L"C:/Qt/qextserialport-1.2win-alpha/build/" -lqextserialport

      1 Reply Last reply
      0
      • Q Offline
        Q Offline
        qt52
        wrote on 14 Nov 2012, 08:49 last edited by
        #3

        Hello Jalomic,

        Thanks for your reply.

        do you mean include the lib like following?
        #This are the to line you have to add
        INCLUDEPATH += C:/Qt/qextserialport-1.2win-alpha/
        LIBS += -L“C:/Qt/qextserialport-1.2win-alpha/build/” -libqextserialportd.a

        The result still the same.

        Actually is C:/ or C:\ ? normally the format is C:\Qt\qextserialport-1.2win-alpha\build from our pc.
        The sample given is a bit confuse ya..

        1 Reply Last reply
        0
        • J Offline
          J Offline
          jalomic
          wrote on 14 Nov 2012, 08:56 last edited by
          #4

          No ! Just copy and paste this:
          LIBS += -L“C:/Qt/qextserialport-1.2win-alpha/build/” -lqextserialport

          or like this:
          LIBS += -L“C:/Qt/qextserialport-1.2win-alpha/build/” -llibqextserialportd.a

          -L - it is prefix for path to library folder
          -l - prefix for lib file

          1 Reply Last reply
          0
          • Q Offline
            Q Offline
            qt52
            wrote on 14 Nov 2012, 09:00 last edited by
            #5

            Now my code look like this way:

            @#-------------------------------------------------

            Project created by QtCreator 2011-06-18T12:45:21

            #-------------------------------------------------

            QT += core gui

            TARGET = portcomsender
            TEMPLATE = app

            This are the to line you have to add

            INCLUDEPATH += C:/Qt/qextserialport-1.2win-alpha/
            LIBS += -L“C:/Qt/qextserialport-1.2win-alpha/build/” -llibqextserialportd.a

            SOURCES += main.cpp
            widget.cpp

            HEADERS += widget.h@

            after compiled the result still show

            Error while building project portcomsender (target: Bureau)
            When executing build step ‘qmake’

            1 Reply Last reply
            0
            • J Offline
              J Offline
              jalomic
              wrote on 14 Nov 2012, 09:02 last edited by
              #6

              Replace:
              LIBS += -L“C:/Qt/qextserialport-1.2win-alpha/build/” -libqextserialportd.a
              by this:

              LIBS += -L"C:/Qt/qextserialport-1.2win-alpha/build/" -lqextserialport

              1 Reply Last reply
              0
              • Q Offline
                Q Offline
                qt52
                wrote on 14 Nov 2012, 09:04 last edited by
                #7

                In my build folder have 2 files (libqextserialportd.a and qextserialportd.dll) and 2 folder (moc and obj)

                1 Reply Last reply
                0
                • Q Offline
                  Q Offline
                  qt52
                  wrote on 14 Nov 2012, 09:05 last edited by
                  #8

                  After replace, still the same :(

                  1 Reply Last reply
                  0
                  • Q Offline
                    Q Offline
                    qt52
                    wrote on 14 Nov 2012, 09:23 last edited by
                    #9

                    I found the build setting on left corner, is it something wrong with my build setting? I did tried 4 difference setting but result still the same.

                    4.7.0 Debug
                    4.7.0 Release
                    Qt 4.7.3 for Desktop - MinGW 4.4 (Qt SDK) Debug
                    Qt 4.7.3 for Desktop - MinGW 4.4 (Qt SDK) Release

                    1 Reply Last reply
                    0
                    • J Offline
                      J Offline
                      jalomic
                      wrote on 14 Nov 2012, 09:28 last edited by
                      #10

                      Delete LIBS += -L“C:/Qt/qextserialport-1.2win-alpha/build/” -llibqextserialportd.a
                      and post here output.

                      1 Reply Last reply
                      0
                      • Q Offline
                        Q Offline
                        qt52
                        wrote on 14 Nov 2012, 09:36 last edited by
                        #11

                        http://imageshack.us/photo/my-images/203/buildn.jpg/
                        ok, Can you see the image? I think a bit too small for you.

                        !http://i.imgur.com/0av0q.jpg(Build1)!

                        1 Reply Last reply
                        0
                        • J Offline
                          J Offline
                          jalomic
                          wrote on 14 Nov 2012, 10:06 last edited by
                          #12

                          strange behavior

                          Recreate project

                          1 Reply Last reply
                          0
                          • Q Offline
                            Q Offline
                            qt52
                            wrote on 14 Nov 2012, 10:09 last edited by
                            #13

                            Should i put the build folder ( .a and .dll) inside the project folder?

                            1 Reply Last reply
                            0
                            • Q Offline
                              Q Offline
                              qt52
                              wrote on 14 Nov 2012, 10:20 last edited by
                              #14

                              When i unzip the file and double click the portcomsender.pro project file it prompt out this dialog.

                              !http://i.imgur.com/H1iY5.jpg(Build2)!

                              Is it this the issue?

                              How can i use his .cpp and .h file to create my own project environmental?

                              1 Reply Last reply
                              0
                              • sierdzioS Offline
                                sierdzioS Offline
                                sierdzio
                                Moderators
                                wrote on 14 Nov 2012, 10:39 last edited by
                                #15

                                You should not use old .user files. Delete this file before opening a copied project.

                                (Z(:^

                                1 Reply Last reply
                                0
                                • sierdzioS Offline
                                  sierdzioS Offline
                                  sierdzio
                                  Moderators
                                  wrote on 14 Nov 2012, 10:40 last edited by
                                  #16

                                  You can also consider testing the official Qt Playground project: "QtSerialPort":https://qt.gitorious.org/qtplayground/qtserialport.

                                  (Z(:^

                                  1 Reply Last reply
                                  0
                                  • Q Offline
                                    Q Offline
                                    qt52
                                    wrote on 14 Nov 2012, 11:29 last edited by
                                    #17

                                    Hello Sierdzio,

                                    Thanks for your advice. Ya, in the folder i found this portcomsender.pro.user file. After deleted and open the project file again the dialog never prompt out anymore.

                                    After this will ask for Target setup. I configured:
                                    Desktop - Tick
                                    Create Build Configurations: For Each Qt Version One Debug And One Release
                                    Use Shadow Building - Tick
                                    Click Finish

                                    http://i.imgur.com/fUYLq.jpg
                                    I try compile and there are few error prompt out. The image shows the error message.

                                    emmm...The program look not so complicated but when compile that time is not that easy.

                                    Is it possible to help me to create a sample project so that i can have a reference and easy for me to check where's the error?
                                    This sample tutorial i get it from http://www.instructables.com/id/Control-your-arduino-from-your-PC-with-the-Qt-Gui/step3/Lets-program/

                                    Thank you very much, I will test QtSerialPort later. It's quite interested to have working sample to test. This sample code is not a tutorial i guess it should be least explanation, hopefully i can understand the coding. I have C programming knowledge but lack C++ and this the first time i try windows programming. :)

                                    Let me have a try first ya...Any question i will come back again..

                                    Best Regards,
                                    Qt52

                                    1 Reply Last reply
                                    0
                                    • sierdzioS Offline
                                      sierdzioS Offline
                                      sierdzio
                                      Moderators
                                      wrote on 14 Nov 2012, 11:35 last edited by
                                      #18

                                      You have got some missing includes - this is still all about LIBS and INCLUDEPATH in .pro file. I know it's hard to get right the first time you try. Maybe if you are new to this all, it would be better to try something using Qt classes only? You can take a look at example of including custom libs in my "QEasyShell":https://github.com/sierdzio/qeasyshell/blob/master/examples/basic/basic.pro project, but I'm using .pri so I'm not sure it will make it easier for you... although it might. Just be sure to read the global.pri in addition to the one I've linked.

                                      (Z(:^

                                      1 Reply Last reply
                                      0
                                      • H Offline
                                        H Offline
                                        harshit_smart
                                        wrote on 3 Jun 2014, 10:05 last edited by
                                        #19

                                        Hey bro ..m a newbie trying exactly the same program from instructables..
                                        In the desktop prompt as mentioned in step 2 for controlling arduino using qt gui... i am getting the following error..please help if you have fixed the isse you were facing..thnx

                                        C:\Qt\qextserialport-1.2win-alpha>C:\Qt\Qt5.3.0\Tools\mingw482_32\bin\mingw32-ma
                                        ke.exe
                                        C:/Qt/Qt5.3.0/Tools/mingw482_32/bin/mingw32-make -f Makefile.Release
                                        mingw32-make[1]: Entering directory 'C:/Qt/qextserialport-1.2win-alpha'
                                        g++ -c -pipe -fno-keep-inline-dllexport -O2 -Wall -Wextra -frtti -fexceptions -m
                                        threads -DUNICODE -D_TTY_WIN_ -DQT_NO_DEBUG -DQT_CORE_LIB -I. -I'../Qt5.3.0/5.3/
                                        mingw482_32/include' -I'../Qt5.3.0/5.3/mingw482_32/include/QtCore' -I'build/moc'
                                        -I'../Qt5.3.0/5.3/mingw482_32/mkspecs/win32-g++' -o build/obj/win_qextserialpor
                                        t.o win_qextserialport.cpp
                                        win_qextserialport.cpp: In member function 'virtual bool Win_QextSerialPort::ope
                                        n(QIODevice::OpenMode)':
                                        win_qextserialport.cpp:187:37: error: 'class QString' has no member named 'toAsc
                                        ii'
                                        Win_Handle=CreateFileA(port.toAscii(), GENERIC_READ|GENERIC_WRITE,
                                        ^
                                        win_qextserialport.cpp: At global scope:
                                        win_qextserialport.cpp:431:6: warning: unused parameter 'c' [-Wunused-parameter]

                                        void Win_QextSerialPort::ungetChar(char c) {
                                        ^
                                        win_qextserialport.cpp:948:6: warning: unused parameter 'msecs' [-Wunused-parame
                                        ter]
                                        bool Win_QextSerialPort::waitForReadyRead(int msecs)
                                        ^
                                        win_qextserialport.cpp: In member function 'void Win_QextSerialPort::monitorComm
                                        Event()':
                                        win_qextserialport.cpp:988:6: warning: suggest explicit braces to avoid ambiguou
                                        s 'else' [-Wparentheses]
                                        if (eventMask & EV_DSR)
                                        ^
                                        Makefile.Release:538: recipe for target 'build/obj/win_qextserialport.o' failed
                                        mingw32-make[1]: *** [build/obj/win_qextserialport.o] Error 1
                                        mingw32-make[1]: Leaving directory 'C:/Qt/qextserialport-1.2win-alpha'
                                        Makefile:34: recipe for target 'release' failed
                                        mingw32-make: *** [release] Error 2

                                        C:\Qt\qextserialport-1.2win-alpha>

                                        thanks

                                        Harshit arora

                                        urgent reply needed...

                                        [quote author="qt52" date="1352892591"]Hello Sierdzio,

                                        Thanks for your advice. Ya, in the folder i found this portcomsender.pro.user file. After deleted and open the project file again the dialog never prompt out anymore.

                                        After this will ask for Target setup. I configured:
                                        Desktop - Tick
                                        Create Build Configurations: For Each Qt Version One Debug And One Release
                                        Use Shadow Building - Tick
                                        Click Finish

                                        http://i.imgur.com/fUYLq.jpg
                                        I try compile and there are few error prompt out. The image shows the error message.

                                        emmm...The program look not so complicated but when compile that time is not that easy.

                                        Is it possible to help me to create a sample project so that i can have a reference and easy for me to check where's the error?
                                        This sample tutorial i get it from http://www.instructables.com/id/Control-your-arduino-from-your-PC-with-the-Qt-Gui/step3/Lets-program/

                                        Thank you very much, I will test QtSerialPort later. It's quite interested to have working sample to test. This sample code is not a tutorial i guess it should be least explanation, hopefully i can understand the coding. I have C programming knowledge but lack C++ and this the first time i try windows programming. :)

                                        Let me have a try first ya...Any question i will come back again..

                                        Best Regards,
                                        Qt52

                                        [/quote]

                                        1 Reply Last reply
                                        0
                                        • K Offline
                                          K Offline
                                          kuzulis
                                          Qt Champions 2020
                                          wrote on 3 Jun 2014, 11:45 last edited by
                                          #20

                                          2 harshit_smart,

                                          instead of QextSerialPort you can use the QtSerialPort in your Qt5.3. The QtSerialPort is an part of an official Qt add-on package. To install it (using an official Qt installer) is enough to expand an "Addons" checkbox and to select "SerialPort" component.

                                          1 Reply Last reply
                                          0

                                          • Login

                                          • Login or register to search.
                                          • First post
                                            Last post
                                          0
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular
                                          • Users
                                          • Groups
                                          • Search
                                          • Get Qt Extensions
                                          • Unsolved