View Full Version : QextSerialPort WaitForReadyRead()

15th September 2008, 14:16
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?

15th September 2008, 14:24
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.

16th September 2008, 09:54
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().

8th October 2008, 11:02

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.


8th October 2008, 11:29
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.

8th October 2008, 15:59

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.


8th October 2008, 20:29
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.

9th October 2008, 07:46
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

9th October 2008, 10:15

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?


9th October 2008, 20:44
I didn't manage to get it to work properly... Maybe that's why it's alpha :)