Results 1 to 5 of 5

Thread: Serial communication, waitForReadyRead() doesn't wait

  1. #1
    Join Date
    Jan 2009
    Location
    Germany
    Posts
    387
    Thanks
    101
    Thanked 15 Times in 15 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Serial communication, waitForReadyRead() doesn't wait

    I have a device connected to my PC with a usb converted serial port (FTDI). I'm using qextserialport and altogether it works great. However, waitForReadyRead() doesn't wait for data to arrive, but returns immidiately with false. I'm using it like this:

    Qt Code:
    1. void Serial::checkForData()
    2. {
    3. port = new QextSerialPort("COM3");
    4. port->setBaudRate(BAUD115200);
    5. port->setFlowControl(FLOW_OFF);
    6. port->setParity(PAR_NONE);
    7. port->setDataBits(DATA_8);
    8. port->setStopBits(STOP_1);
    9. port->open(QIODevice::ReadWrite);
    10.  
    11. sendSomething();
    12.  
    13. if (port->waitForReadyRead(1000))
    14. {
    15. // Device replied within 1 second
    16. }
    17. else
    18. {
    19. // Device didn't reply.
    20. }
    21. }
    To copy to clipboard, switch view to plain text mode 

    The waitForReadyRead call returns immidiately with false, without waiting for 1 second.
    Any ideas?

  2. #2
    Join Date
    Jan 2006
    Location
    Sta. Eugènia de Berga (Vic - Barcelona - Spain)
    Posts
    869
    Thanks
    70
    Thanked 59 Times in 57 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Serial communication, waitForReadyRead() doesn't wait

    Hi,

    Reading the QextSerialPort docs. Only using 1.2 Alpha version with MS Windows and configuring it as "event driven" you will be able to get it work as you expected.
    Using older versions or using another OS like Linux you will probably need to use a timer to read the data every X ms, or wait X ms and then perform a "read" operation(if you are sure that you have data).
    Òscar Llarch i Galán

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

    Cruz (5th February 2009)

  4. #3
    Join Date
    Jan 2009
    Location
    Germany
    Posts
    387
    Thanks
    101
    Thanked 15 Times in 15 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Serial communication, waitForReadyRead() doesn't wait

    Thanks mate. What documentation did you read? I saw only the doxygen stuff on the website and the function description didn't say anything like what you described.

  5. #4
    Join Date
    Jan 2006
    Location
    Sta. Eugènia de Berga (Vic - Barcelona - Spain)
    Posts
    869
    Thanks
    70
    Thanked 59 Times in 57 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Serial communication, waitForReadyRead() doesn't wait

    Hi,

    I don't remember were I readed it but I know that there is this problem. I had developed an application one year ago that uses it and ther is no other way to make it works(at least for me).
    Òscar Llarch i Galán

  6. The following user says thank you to ^NyAw^ for this useful post:

    Cruz (5th February 2009)

  7. #5
    Join Date
    Jan 2009
    Location
    Germany
    Posts
    387
    Thanks
    101
    Thanked 15 Times in 15 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Serial communication, waitForReadyRead() doesn't wait

    Bumping into you here just saved me several days of time.

Similar Threads

  1. Serial Port communication
    By mgurbuz in forum Qt Programming
    Replies: 12
    Last Post: 22nd January 2011, 02:38
  2. serial communication problem
    By Tavit in forum Qt Programming
    Replies: 3
    Last Post: 31st May 2008, 12:56
  3. serial communication programming
    By jagadish in forum Qt Programming
    Replies: 1
    Last Post: 30th August 2007, 07:47
  4. C++ Library for serial communication
    By dec0ding in forum General Programming
    Replies: 7
    Last Post: 8th July 2007, 18:18
  5. How to transfer file through serial communication
    By shamik in forum Qt Programming
    Replies: 29
    Last Post: 29th May 2007, 10:22

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.