I am using QextSerialPort on Windows to enable my Qt/C++ application to read and write from/to the serial port.
I want to read bytes from the serial port only when there are bytes to read.
First, I tried connecting the QextSerialPort::readyRead()
signal to a slot in my main class, but I noticed that the application hangs.
Then I tried using QextSerialPort::read(char *, uint64)
, which returns the amount of bytes read, and thereafter I made another unsuccesful attempt combining QextSerialPort::bytesAvailable()
and QextSerialPort::read(char *, uint64)
to see if that would help my application not to block.
However, the application always blocks and has to be killed, since it does not respond to any mouse or keyboard events. I pressume that the application freezes because the read routine blocks.
Is there a way to perform non-blocking reading with QextSerialPort?
If not, what library should I use to have non-blocking reading capabilities from serial port on Windows?
UPDATE:
I have tried using QextSerialPort::atEnd()
to check whether there are bytes to read instead of using QextSerialPort::bytesAvailable()
or QextSerialPort::size()
and it always returns false.
Reads should be non-blocking, unless you have set the Query mode to polling