Results 1 to 10 of 10

Thread: QextSerialPort reading error: wrong values

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Dec 2008
    Location
    Qt Reference Documentation
    Posts
    62
    Thanks
    25
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QextSerialPort reading error: wrong values

    Quote Originally Posted by wysota View Post
    I'd read everything there is to be read using QIODevice::readAll() and I'd take the last character, not the first one.
    This works, thanks
    However, is there any more efficient (in terms of complexity) way to do it?, perhaps just clearing the buffer or something like that, because readAll() is taking about 5 seconds to get done (because of low data transfer rate)

    BTW, I tried closing and opening the port each time receiveByte() is invoked but I get a wrong value...

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,017 Times in 4,793 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QextSerialPort reading error: wrong values

    The data gets transfered TO the port in a low rate but once it reaches the port (bytesAvailable()>0) it's read from a buffer. So if you experience a delay it might be that there is no data to be read and your read() call blocks until some data is returned. So before reading check if there is anything to be read.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Dec 2008
    Location
    Qt Reference Documentation
    Posts
    62
    Thanks
    25
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QextSerialPort reading error: wrong values

    Quote Originally Posted by wysota View Post
    The data gets transfered TO the port in a low rate but once it reaches the port (bytesAvailable()>0) it's read from a buffer. So if you experience a delay it might be that there is no data to be read and your read() call blocks until some data is returned. So before reading check if there is anything to be read.
    I don't thinks so, because once I start the program, bytesAvailable() are 0 then it increases into ~4000 in like 5 or 6 seconds, and it stops there, then when I read a byte it increases again until it reaches ~20000 and stabilizes, henceforth it doesn't increase again until it's less than the first number (~4000).

    Note that it takes a fraction of a second to read a byte when the number is around 20000 but it takes about 5 only in the time the number gets below the certain limit (~4000) and the QextSerialPort refills about 16000 bytes...

    So, my guess is, it takes a long time for these values to get filled then read.

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,017 Times in 4,793 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QextSerialPort reading error: wrong values

    As far as I remember QExtSerialPort is a stupid class that does not do any buffering on its own and it's only a thin layer over native API. So if you are experiencing such behaviours, they are probably happening in your operating system. In general I'd suggest reading faster so that the system buffers don't get full.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  5. #5
    Join Date
    Dec 2008
    Location
    Qt Reference Documentation
    Posts
    62
    Thanks
    25
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QextSerialPort reading error: wrong values

    Thanks for all the info.

Similar Threads

  1. Replies: 7
    Last Post: 29th August 2008, 10:24
  2. QWT 5, QT3, SuSE 10.2. Crash and burn
    By DrMcCleod in forum Qwt
    Replies: 8
    Last Post: 7th September 2007, 20:53

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
  •  
Qt is a trademark of The Qt Company.