Results 1 to 10 of 10

Thread: QextSerialPort WaitForReadyRead()

  1. #1
    Join Date
    Aug 2006
    Location
    Germany
    Posts
    33
    Thanks
    8
    Qt products
    Qt4
    Platforms
    Windows

    Default QextSerialPort WaitForReadyRead()

    Is there anybody reimplemented WaitForReadyRead() in QextSerialPort class. As I am using it in a Non GuI thread ( not a member of QObject), I need this blocking functionality.

    Checking bytesavailable() in the loop leads to extreme processor load.

    Is there any other way to do it?

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

    Default Re: QextSerialPort WaitForReadyRead()

    QExtSerialPort doesn't emit readyRead() so there is no point in waiting for it. You need to use a timer. If you want the call to be blocking, you may spawn your own event loop if your application is not already event driven.

  3. #3
    Join Date
    Aug 2006
    Location
    Germany
    Posts
    33
    Thanks
    8
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QextSerialPort WaitForReadyRead()

    hallo Wysota,
    thanks for ur suggestion.

    I made it as polling with bytesavailalbe with a threadsleep().
    I feel this is a workaround.

    Also, I saw the QextSerialPort 1.2 alpha has a emit ReadyRead() command.
    But they did not implement WaitForReadyRead().

  4. #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: QextSerialPort WaitForReadyRead()

    Hi,

    Has anyone tested the QextSerialPort 1.2Alpha "readyRead" signal ? Does it work? Currently I have a Thread that pools the serial port for "bytesAvailable" and want to know if "readyRead" signal works.

    Thanks,
    Òscar Llarch i Galán

  5. #5
    Join Date
    Aug 2006
    Location
    Germany
    Posts
    33
    Thanks
    8
    Qt products
    Qt4
    Platforms
    Windows

    Post Re: QextSerialPort WaitForReadyRead()

    It wont work as they did not implement it .

    Check the win_qextserialport.h line nr. 107

    virtual bool waitForReadyRead(int msecs); ///< @todo implement.

    I wanna give it a shot .. but at the moment I dont have time to do it.

    I used the wysota's way of using the Qtimer method.

  6. #6
    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: QextSerialPort WaitForReadyRead()

    Hi,

    I don't want "waitForReadyRead", I want to connect "readyRead" SIGNAL and as I can see it is implemented on Windows using a QThread and Windows API functions.
    I just want to know if "readyRead" SIGNAL works because now I have a polling Thread that increases CPU load.

    Thanks,
    Òscar Llarch i Galán

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

    Default Re: QextSerialPort WaitForReadyRead()

    You don't need a separate thread. You can check the port in the main thread. Timers are a bit heavy, so it might be better to use timerEvent() if you experience efficiency problems.

  8. #8
    Join Date
    Jun 2008
    Posts
    35
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QextSerialPort WaitForReadyRead()

    It is possible to do only by polling based on timer and check if data available.
    Or you can make reasonable SIGNAL api yourself to hide polling

  9. #9
    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: QextSerialPort WaitForReadyRead()

    Hi,

    I know that I can use a Timer but I want to know if using QextSerialPort 1.2 Alpha, the signal "readyRead" works !!!

    If it works I don't need to use a Timer or a Thread, because it will call the properly SLOT when data arrives.

    So, anyone have tested it?

    Thanks,
    Òscar Llarch i Galán

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

    Default Re: QextSerialPort WaitForReadyRead()

    I didn't manage to get it to work properly... Maybe that's why it's alpha

Similar Threads

  1. QextSerialPort and waitForReadyRead problem
    By Ivan Wagner in forum Qt Programming
    Replies: 12
    Last Post: 20th August 2010, 07:52
  2. Problem in QExtserialport program.
    By dheeraj in forum Qt Programming
    Replies: 5
    Last Post: 31st May 2008, 10:24
  3. Replies: 4
    Last Post: 30th January 2008, 10:00
  4. any body using qextserialport?
    By yagabey in forum Newbie
    Replies: 4
    Last Post: 25th December 2007, 22:08
  5. QExtSerialPort with com ports above com9
    By mightymark in forum Qt Programming
    Replies: 2
    Last Post: 29th May 2006, 08:16

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.