Create a simple RS232 interface
-
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,..
-
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.aThe 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.. -
No ! Just copy and paste this:
LIBS += -L“C:/Qt/qextserialport-1.2win-alpha/build/” -lqextserialportor 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 -
Now my code look like this way:
@#-------------------------------------------------
Project created by QtCreator 2011-06-18T12:45:21
#-------------------------------------------------
QT += core gui
TARGET = portcomsender
TEMPLATE = appThis 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.aSOURCES += main.cpp
widget.cppHEADERS += widget.h@
after compiled the result still show
Error while building project portcomsender (target: Bureau)
When executing build step ‘qmake’ -
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 -
http://imageshack.us/photo/my-images/203/buildn.jpg/
ok, Can you see the image? I think a bit too small for you. -
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?
-
You should not use old .user files. Delete this file before opening a copied project.
-
You can also consider testing the official Qt Playground project: "QtSerialPort":https://qt.gitorious.org/qtplayground/qtserialport.
-
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 Finishhttp://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 -
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.
-
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..thnxC:\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 2C:\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 Finishhttp://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]
-
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.