Results 1 to 5 of 5

Thread: Qt with qwt, qextserialport unable to plot from serial port.

  1. #1
    Join Date
    Mar 2013
    Location
    Bangalore
    Posts
    3
    Thanks
    3
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Question Qt with qwt, qextserialport unable to plot from serial port.

    Hi,
    I am using Qt 4.8.1 in Ubuntu 12.04 with Qwt libraries installed. I also have the qextserialport libraries installed. I have modified the uartassistant example from code.google.com/p/qextserialport/‎ according to my needs. I am able to display (in a plainTextEdit) my embedded device SBC6845 terminal (I can access everything of it) inside the uartassistant through /dev/ttyS0 port from my host PC.
    Now I had added a qwtPlot item to a tab widget in uartassisstant, with which I can plot data from .txt files placed in my host PC. But I need to access or use the same data coming to the plainTextEdit and use them in qwtPlot. So far, I have a few ideas:
    1. Read from the /dev/ttyS0 directly and plot them in qwtPlot. Now the problem is actually implementing it, I have run out of options. How do I do it?
    (One of the problems holding me is that ttyS0 has many other unnecessary data along with my required data. Is there some exclusive way of selecting only int data and plotting on qwtPlot? I have tried implementing other links i came by googling but most of them are too erroneous to proceed further.
    2. Save whatever comes through /dev/ttyS0 in a txt file and then read my required data from it. But this isn't the realtime, so I am not so keen on proceeding with this approach.

    So in short :
    Is there any way to implement qwt and qextserialport in some way to get the desired output in real time?
    I just need a push in the right direction, so I welcome any advice, links to more tutorials, docs or few lines of code explaining, if I am missing some point.

    Thanks.

  2. #2
    Join Date
    Jul 2013
    Posts
    6
    Thanks
    3
    Thanked 1 Time in 1 Post

    Default Re: Qt with qwt, qextserialport unable to plot from serial port.

    There is no out-of-the-box way of plotting your data, since qwt does not know what to plot from your data stream and what not (i.e. what is your "required data" and what is not).

    The data coming from your serial port has to have some sort of protocol, so you can distinguish between different data items. Specifically, you have to discern your "required data". You have to write some sort of software stack or filter which understands this protocol and is able to extract the data you want. The software stack is fed from one side with data coming form your serial port and the output of the serial port is fed into your plot. For the last part, have a look at the qwt realtime example. The oscilloscope and cpuplot examples may also be of interest to you.

    I can't give you a more specific answer without more details about the data you are processing.

    Best regards.

  3. The following user says thank you to IThu8uu1 for this useful post:

    maharnab91 (14th August 2013)

  4. #3
    Join Date
    Mar 2013
    Location
    Bangalore
    Posts
    3
    Thanks
    3
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Qt with qwt, qextserialport unable to plot from serial port.

    I am reading encoder counts of an actuator with the help of my SBC6845. The data generated is actual counts float-numbers (I made it so to make reading from file with qwtPlot easier) which are displayed on the terminal screen of my application(it uses the ttyS0 port for communicating between PC and SBC). Now since I am able to display the data as is, on my host PC, application terminal screen, I was thinking of a way to route those data straight to the qwtPlot. As of now, I am writing the data on to a file in the SBC6845, and copying the file from SBC6845 to host PC using tftp(Ethernet LAN between PC and SBC). This copied file in my host PC is being read by the qwtPlot and displayed as a graph on my application.
    I know there are easier and quicker way to do this. But as you said there is need for some sort of protocol to identify the data. I actually tried saving in a file(in host PC) whatever comes from SBC to PC via ttyS0, but this was a disaster as it was only hex code which the 'port' of qextserialport reads and converts before displaying on my application screen. So it was a no go for me, I tried understanding the logic used in 'port' of qextserialport for conversion, but still unable to figure out completely.
    If can elaborate on the 'software stack or filter' part with some examples it will be of great help.
    Thanks.

  5. #4
    Join Date
    Feb 2006
    Location
    Munich, Germany
    Posts
    3,313
    Thanked 879 Times in 827 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Qt with qwt, qextserialport unable to plot from serial port.

    Only to mention it once: Qt 5.1 came with a new module https://qt-project.org/doc/qt-5.1/qt...ort-index.html

    Uwe

  6. The following 2 users say thank you to Uwe for this useful post:

    IThu8uu1 (14th August 2013), maharnab91 (14th August 2013)

  7. #5
    Join Date
    Jul 2013
    Posts
    6
    Thanks
    3
    Thanked 1 Time in 1 Post

    Default Re: Qt with qwt, qextserialport unable to plot from serial port.

    Quote Originally Posted by maharnab91 View Post
    If can elaborate on the 'software stack or filter' part with some examples it will be of great help.
    As I understand your description your data is put out as ASCII, yes?
    Then you need to read from your serial port, sscanf(), use fstream or so, or write your own parser to translate the ASCII back to the IEEE 754 representation of that floating point number. Then you can put you floating point number into your curve data.

    In case I have misunderstood you: You have to extract your floats from your data stream, possibly re-arrange the byte order and put them into your curve data.

    Best regards.

Similar Threads

  1. Replies: 7
    Last Post: 19th April 2013, 11:46
  2. Serial port timeout - Qextserialport
    By h-n-s in forum Newbie
    Replies: 1
    Last Post: 9th April 2013, 06:42
  3. Replies: 2
    Last Post: 3rd July 2012, 16:42
  4. Replies: 5
    Last Post: 11th August 2011, 14:16
  5. Replies: 1
    Last Post: 1st July 2009, 00:36

Tags for this Thread

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.