PDA

View Full Version : Gui showing data read from a serial port in "realtime"



bmn
14th October 2010, 15:44
Hello.

I am trying to develop a program that shows a stream of function values in a chart. I recieve the values from a serial port. I set up the serial port using the windows api without any probs, but I fail to make it in a way that the gui can recieve the data. Afaik, my problem would be solved by having the comport stuff running in a seperate thread which signals the gui when new data is recieved. I was looking for somekind of code example having a qt gui and a comport communication implemented in different threads but i didnt find anything. Isnt this a very fundamental practice (show data from a stream in a guy)?

high_flyer
15th October 2010, 10:53
Isnt this a very fundamental practice
Yes it is.


but I fail to make it in a way that the gui can recieve the data.
Well, if you explain how you are doing things, we might help you by showing you what you are doing wrong.
Please include code.

P.S
You might want to have a look at QextSerialPort for a Qt serial port class that fits very nicely to Qt projects and Qt way of doing things.
In addition you get your serial port code to be cross platform, at least between Windows and Linux.

kuzulis
15th October 2010, 16:07
2 bmn,

best use QSerialDevice library : http://qt-apps.org/content/show.php/QSerialDevice?content=112039

rhyma
1st June 2012, 22:26
77887789779077917792I use windows seven as an operating system, I have dwnload DTSDK from this link http://qt.nokia.com/downloads/sdk-windows-cpp-offline , and the libriry qextserialport from this link http://code.google.com/p/qextserialport/downloads/detail?name=qextserialport-1.2beta1.tar.gz&can=1&q= , I have installed it and I am ecxecuting some examples : enumerator events qespta and also uartassistant. enumerator events qespta gives a good result. only the uartassistant cant give me a result, I could'n display the data from the serial port, so I have tried some modifications, so i I have delted the classes held.cpp and held.h and I have made some changes to the classes dialog.h and dialog.cpp, the "main" remained untouch yet.

this the dialog.cpp and dialog.h classes in attachments


i dont know where is the problem.

help me please.

ChrisW67
2nd June 2012, 07:04
Some observations (line numbers in dialog.cpp):

You load an undetermined number of ports into portBox [20]
You assume portBox has current item and use it as the port name [49]. Is this the port you think it is?
You load six speeds into baudRateBox and select the sixth 115200 as the current entry, but do not use that rate when you init the port at [48-49]. Is the port at the speed you think it is?