Results 1 to 4 of 4

Thread: delay while reading data from QTcpSocket every 20ms

  1. #1
    Join Date
    Oct 2010
    Posts
    3
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Question delay while reading data from QTcpSocket every 20ms

    hello,

    im working with QTCreator on Windows ultimate 64 bit edition. im trying to read data from qtcpsocket every 20ms. but i see a delay which is increasing more as the time pass.

    i was working with ex method: writing my own socket class inherited from abstractsocket class. then i added qthread to this (inheriting from qthread again). those 2 ways didnt work.

    then i saw qthread is no longer abstract:
    http://labs.qt.nokia.com/2007/07/05/...nger-abstract/
    http://labs.qt.nokia.com/2010/06/17/...oing-it-wrong/
    http://labs.qt.nokia.com/2006/12/04/...-the-headache/

    and i tried applying this method and reading but the delay still occurs.

    im attaching zip files of my whole projects.

    any ideas, advices?
    Attached Files Attached Files

  2. #2
    Join Date
    Sep 2009
    Location
    UK
    Posts
    2,447
    Thanks
    6
    Thanked 348 Times in 333 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: delay while reading data from QTcpSocket every 20ms

    Why are you trying to read every 20ms rather than just reading when there is data available?

  3. #3
    Join Date
    Oct 2010
    Posts
    3
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: delay while reading data from QTcpSocket every 20ms

    if you looked at source codes, im not doing anything special to read every 20ms. it is caused by the system im working on.
    there is a sensor hardware which is acting as server and sending data every 20ms if there is a connected client.
    so data is available every 20ms.

  4. #4
    Join Date
    Oct 2010
    Posts
    3
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: delay while reading data from QTcpSocket every 20ms

    i found the problem.

    i added

    unsigned long int len = tcpSocket->bytesAvailable();
    qDebug("%lu %d",len ,sizeof(pScanBufferParsed_t));

    to slot() of readyRead() signal.

    and results are always same and like this:

    1680 560

    which means exactly 3 times my pScanBufferParsed_t type size. in other words, readyRead() is emitting at every 3 packages.

    anything that i can do to make readyRead emitted at every package?

Similar Threads

  1. Problem with reading in data from a QTCPSocket
    By Denarius in forum Qt Programming
    Replies: 4
    Last Post: 24th April 2009, 08:54
  2. QTcpSocket writing reading problem
    By Misenko in forum Qt Programming
    Replies: 4
    Last Post: 15th October 2008, 07:27
  3. Reading non-ASCII lines from QTcpSocket via readLine()
    By joshtn in forum Qt Programming
    Replies: 1
    Last Post: 26th June 2008, 23:52
  4. Replies: 3
    Last Post: 7th December 2007, 07:09
  5. Replies: 6
    Last Post: 8th January 2007, 10:24

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.