How to wait for ready read for ever on RS232
-
Hi All,
I'm using qt5.5 on my computer and Linux+QT for my OS system.
I'm using QSerialport to get the information from my MCU via RS232.
And I want to detect is there any information I have to read.After some googling I'm using
waitforreadyread()
to do it.
But I do not know how can I wait until the data is coming.How can I wait for the data without limited time?
Thanks in Advanced!
-
@victor-wang said in How to wait for ready read for ever on RS232:
QSerialpor
Have to you tried to connect to the readyRead() signal ?
-
@victor-wang said in How to wait for ready read for ever on RS232:
After some googling I'm using waitforreadyread() to do it.
But I do not know how can I wait until the data is coming.
How can I wait for the data without limited time?Hi Victor,
Hmm, it seems the documentation is missing a piece here, but it's documented in http://doc.qt.io/qt-5/qiodevice.html#waitForReadyRead:
If msecs is -1, this function will not time out.
I've checked in the Win and Unix implementations of QSerialPort, that passing -1 as timeout should never time out.
You can check yourself:
http://code.qt.io/cgit/qt/qtserialport.git/tree/src/serialport/qserialport_win.cpp#n371
http://code.qt.io/cgit/qt/qtserialport.git/tree/src/serialport/qserialport_unix.cpp#n521
-
I've added a note to the QSerialPort documentation for waitForReadyRead():