PDA

View Full Version : Protocol Implementation. ?



dheeraj
26th April 2008, 07:11
Hi friends. I am using Qt4.3 with VS2005. I am working on a Data Acqusition System. I am using Qt to develop the Application. I need to acquire the data of the selected channels from the Embedded System and Plot Graphs in the Application. For which i need to implement a Protocol. I have the following -

Format byte -- Service ID -- Data bytes -- Check Sum

Format Byte is the size of Service ID and Data byte. ,example- 0X03
Service ID defines which Channel I have selected. ,example - 0XC1
Data Byte is the parameters i have selected in the Channel.
Check Sum is the size of Format Byte and Service ID ,example- 0XC4
:)
I have to send all this on a serial port to the embedded system which has all these defined so it is going to select the required Channel and send the data back to the Application.
Hey this is the first time i am doing this i have done a some searching on Google but i am not sure about how to implement this. ?? I don't have any one at my work to help me out with this.:o

wysota
27th April 2008, 20:01
Is your question oriented on the protocol itself or how to physically send data through the serial port?

dheeraj
28th April 2008, 09:20
Hi wysota thankx for the reply. I wanted to know how to physically send data through the serial port . I tried the TCP example of Qt but it is not illustrating what i exactly wanted. Can you pls post me some example . I am not able to figure out how i exactly implement sending the Data serially in that format. I am still a novice in this field. :o

Thanks a Lot

wysota
28th April 2008, 09:25
If you want to use the serial port, I suggest you google for QExtSerialPort - it's probably http://qextserialport.sourceforge.net

dheeraj
28th April 2008, 10:54
Hey i even tried the Qextserialport lib. But had so much problem installing it. The example programs din't work at all. Hey can u pls tell me how to install this.I will try Qextserialport again. I din't understand the help file installation so i cud't install properly. I am using Qt4.3.3 with VS2005.


Thank You

wysota
28th April 2008, 11:45
I had no problems in installing QExtSerialPort on both Windows (with MSVC and MinGW as compilers) and Linux. Could you provide more details on what is going wrong?

dheeraj
29th April 2008, 07:03
Hi wysota i copied the Qextserialport precompiled file to my system and tried to run the example program qespta. I got the following error i have attached the Output-Build file . I don know what is wrong. Hey can you pls tell me the proper procedure to install qexternalserialport lib to Qt4.3.3 with VS2005.:confused: I did not find any installation file online. I even got qextserialport-1.2win-alpha file unzipped it and tried the example program but i get error saying


1>LINK : fatal error LNK1181: cannot open input file 'qextserialportd.lib'


Pls Help me out in installing the lib wysota :)

Thank You
Regards

wysota
29th April 2008, 09:00
You are compiling your application in debug mode and the ext serial port library is compiled in release mode. Either recompile the library in debug mode or compile your application in release mode. As for the file you attached - there seems to be a syntax error in the source code, so the build fails.

dheeraj
29th April 2008, 09:50
Hey i did what you said but the same errors. And i have not changed the source code of any example file. But i get these syntax error. What do i have to do.:confused: wysota

wysota
29th April 2008, 09:59
I'm not talking about example files but your project - MessageWindow file. What exactly did you do to build the library and use it?

dheeraj
29th April 2008, 10:16
Hey this is what i did

Unzipped the qextserialport-1.2win-alpha package in C:\qextserialport-1.2win-alpha\qextserialport-1.2win-alpha

opened Qt command Promt and

qmake -project

qmake qextserialport.pro

nmake qextserialport.pro

qmake -tp vc qextserialport.pro

I then found two .pro files. qextserialport-1.2win-alpha.pro and qextserialport.pro .
I tried debuging both the files in VS2005. But i got errors for both . I am attaching the error log for qextserialport-1.2win-alpha.pro file. I compiled it in Debug mode only. Where am i going wrong wysota. ??

Thank You

wysota
29th April 2008, 10:30
Why did you call "qmake -project"? By doing that you ruined the existing project file.

dheeraj
29th April 2008, 10:41
Hey sorry i read your before post and again did the same procedure but without "qmake -project"
.I complied and but as soon as the comp i get a Pop Up telling " Please specify the name of the executable file to be used for the debug session " I have attached the dialog box that pops up just after compliation.

Thank You
wysota

wysota
29th April 2008, 10:43
What debug session? This is a library, there is nothing to debug. Please unpack the sourcecode, open the command line with all environment variables set up, cd to the source code, type in "qmake" followed by "nmake" and you're done. No need to even start visual studio.

dheeraj
29th April 2008, 11:33
Hi wysota thank you have helped me so much in trying to get the qextserialport installed. But i still get the errors. I did exactly what you said i took a fresh copy of qextserialport-1.2win-alpha package unzipped it in C:\ drive . Opened Qt command promt cd to the qextserialport-1.2win-alpha folder and did qmake and nmake. The errors are shown in Qt cmd promt. Pls check the error.zip i have attached the snap shot of the error in the cmd promt.

Thank You so much.
wysota

wysota
29th April 2008, 15:36
Use the stable release of QExtSerialPort, not the alpha one.

dheeraj
30th April 2008, 06:57
Hi wysota i did every thing possible . I tried all the version's . I unzipped them to the C:\ and did qmake and nmake. And tried to run the example program but still i get the same error when i try to build the qespta example.
[/CODE]
1>.\MessageWindow.cpp(93) : error C2061: syntax error : identifier '{ctor}'
1>.\MessageWindow.cpp(121) : error C2061: syntax error : identifier '{ctor}'
[/CODE]

Hey i have to some how make this work my whole project is dependent on serial communication. :crying:. Pls help me out.

Thank You wysota

wysota
30th April 2008, 08:04
What is the contents of those lines mentioned above?

mazurekwrc
30th April 2008, 08:14
hi, I've got version 1.1 of qextserialport from http://qextserialport.sourceforge.net/ which is differ from this on web, the difference is in example in file meesagewindow.cpp, I've got comments in line 92 and 93
// if (static_cast<MessageWindow::EventType>(event->type()) == MessageWindow::MessageEvent)
// msgTextEdit.append(dynamic_cast<MessageEvent::MessageEvent* >(event)->msg);
and in line 121
// QCoreApplication::postEvent(this, new MessageEvent::MessageEvent(qmsg));
with this comments it's work fine but when I delete them I get the same errors as you

dheeraj
30th April 2008, 08:17
Hi wysota
The first error takes me to this part of the code.


void MessageWindow::customEvent(QEvent* event)
{
if (static_cast<MessageWindow::EventType>(event->type()) == MessageWindow::MessageEvent)

msgTextEdit.append(dynamic_cast<MessageEvent::MessageEvent* >(event)->msg); // '{ctor}' Error takes me to this line
}


the second error takes me to this line.


QCoreApplication::postEvent(this, new MessageEvent::MessageEvent(qmsg));

mazurekwrc
30th April 2008, 08:36
so take it in comments as I have written avbove

dheeraj
30th April 2008, 08:46
hey mazurekwrc i tried what you told but i get a error saying


1>LINK : fatal error LNK1181: cannot open input file 'qextserialport.lib'

So i added the path of the folder where qextserialport is "C:\qextserialport-1.1\qextserialport"
there is no qextserialport.lib file though.Now when i build the program again i get a new error


>LINK : fatal error LNK1181: cannot open input file 'C:\qextserialport-1.1\qextserialport.obj'


even get a warning

1>.\MessageWindow.cpp(90) : warning C4100: 'event' : unreferenced formal parameter

Hey i don't find any qextserialport.lib file any where in the qextserialport folder.

mazurekwrc
30th April 2008, 08:54
add
CONFIG += staticlib
in qexterialport.pro file, then run qmake, nmake, go to example and run do the same

dheeraj
30th April 2008, 09:12
Hey mazurekwrc Thank you.:) finally after couple of weeks of breaking head got the output for the example. The GUI was displayed once the example was complied. I need to check if it works fine to send a message from one computer to another.
And i have a doubt what does the line
" CONFIG += staticlib" in qexterialport.pro file actually do all the linker errors were removed. ?? Hey and do i need to qmake and nmake all the qexterialport programs in order to work. I am using Qt 4.3.3 integrated with VS2005.net. cause i don't do qmake and nmake for all the other programs which i have been doing all these dazz.

mazurekwrc
30th April 2008, 10:00
here you got about config += staticlib
http://doc.trolltech.com/4.3/qmake-common-projects.html#building-a-library

you asked also about qmake, it's used to create a platform-specific makefile from the project file, so if we changed .pro file we need to use it, and at the end we use nmake to build program

wysota
30th April 2008, 10:21
Hi wysota
The first error takes me to this part of the code.


void MessageWindow::customEvent(QEvent* event)
{
if (static_cast<MessageWindow::EventType>(event->type()) == MessageWindow::MessageEvent)

msgTextEdit.append(dynamic_cast<MessageEvent::MessageEvent* >(event)->msg); // '{ctor}' Error takes me to this line
}


the second error takes me to this line.


QCoreApplication::postEvent(this, new MessageEvent::MessageEvent(qmsg));


The problem seems to be the dynamic_cast. Maybe your compiler has support for it turned off or you compiled Qt without RTTI support.

dheeraj
30th April 2008, 11:53
Hi wysota i think the problem is solved finally. I am able to run the qextserialport examples but with a few warnings. I even tested one example program on RS232 cable connected to two computer and it is working. mazurekwrc asked me to add " CONFIG += staticlib" to .pro file. I did it and finally worked. But i had to comment these two lines


msgTextEdit.append(dynamic_cast<MessageEvent::MessageEvent* >(event)->msg);

QCoreApplication::postEvent(this, new MessageEvent::MessageEvent(qmsg));

only then it works . Hey do you have any extra serial communication example. So that i can learn how to send a Frame in a format like i asked in the first post.

Thank You So much wysota

wysota
4th May 2008, 21:39
QExtSerialPort gives you access to the serial communication through the QIODevice API, so I suggest you start by taking a look at it.

dheeraj
8th May 2008, 14:05
Hi wysota i was able to run all the example programs. I started a new QtApplication Project i wanted to send a string of numbers through serial port on click of a OK button on the GUI form. But i get two linker errors i tried so much but cud't clear the error's pls help me with tthis problem. These are the error's


select_spacecraft.obj : error LNK2019: unresolved external symbol "public: __thiscall QextSerialPort::QextSerialPort(class QString const &,enum QextSerialBase::QueryMode)" (??0QextSerialPort@@QAE@ABVQString@@W4QueryMode@Qe xtSerialBase@@@Z) referenced in function "public: __thiscall select_spacecraft::select_spacecraft(class QWidget *)" (??0select_spacecraft@@QAE@PAVQWidget@@@Z)
F:\lpsu_gui 8 RS232\Debug\lpsu_gui.exe : fatal error LNK1120: 1 unresolved externals
Build log was saved at "file://f:\lpsu_gui 8 RS232\lpsu_gui\Debug\BuildLog.htm"


I have attached the .h and .cpp files also.

dheeraj
9th May 2008, 05:08
Hi friends can you pls tell me what is wrong in my program. I am trying to remove those linker errors but not able to clear them. :confused:

wysota
9th May 2008, 07:26
Did you link with the library?

dheeraj
9th May 2008, 10:13
Ya i did link every thing but i have this error. !! :( All the example qextserialport programs
work perfectly but the one i created has these link error's.


Thank You

wysota
9th May 2008, 10:26
Could you show your project file? Does QExtSerialPort contain the constructor mentioned in the error? Also make sure you got the class name right. Is it QextSerialPort or QExtSerialPort?