Results 1 to 5 of 5

Thread: Gui showing data read from a serial port in "realtime"

  1. #1
    Join Date
    May 2007
    Posts
    131
    Thanks
    17
    Thanked 4 Times in 2 Posts

    Default Gui showing data read from a serial port in "realtime"

    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)?
    Last edited by bmn; 14th October 2010 at 16:34.

  2. #2
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Gui showing data read from a serial port in "realtime"

    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.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

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

    Default Re: Gui showing data read from a serial port in "realtime"

    2 bmn,

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

  4. #4
    Join Date
    Jun 2012
    Posts
    1
    Qt products
    Qt4

    Default Re: Gui showing data read from a serial port in "realtime"

    uartassistant.promain.cppdialog.uidialog.hdialog.cppI 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/qextserialp...ar.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.

  5. #5
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Gui showing data read from a serial port in "realtime"

    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?
    Last edited by ChrisW67; 2nd June 2012 at 07:09.

Similar Threads

  1. Replies: 4
    Last Post: 10th July 2010, 17:34
  2. can't set serial port data bits
    By yyiu002 in forum Qt Programming
    Replies: 6
    Last Post: 23rd June 2010, 22:28
  3. Replies: 1
    Last Post: 16th June 2009, 09:09
  4. data from serial port
    By bhe in forum Newbie
    Replies: 4
    Last Post: 3rd May 2009, 10:19
  5. How to write bytes read from serial port to a QFile
    By shamik in forum Qt Programming
    Replies: 19
    Last Post: 25th June 2007, 14:12

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.