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?
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.
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().
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,
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.
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,
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.
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
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,
Re: QextSerialPort WaitForReadyRead()
I didn't manage to get it to work properly... Maybe that's why it's alpha :)