Feature request - QtSerialPort waitForReadyRead
-
Hello!
I got a feature request for a second parameter for the waitForReadyRead() function.
Today the only parameter is the time-out. My suggestion would be to add a second parameter that takes the number of chars to wait for, setting that parameter to ‘1’ would give the same behaviour that it has right now. This would be similar to the read command in Posix.
Kind regards
/Johan -
I do not think it's appropriate. The methods like WaitForXXX derived from QIODevice.
-
I am afraid that this is not the best place for reporting bugs and propose features. Please follow the instruction for the "QtSerialPort wiki page":http://qt-project.org/wiki/QtSerialPort and submit your proposition to "JIRA":https://bugreports.qt-project.org:
bq. Use "bugreports.qt-project.org":https://bugreports.qt-project.org, Project “Qt Playground Projects”, Component “qtserialport”.
-
UPD:
You can implement it yourself, like:
@static int timeout(int msecs, int elapsed)
{
if (msecs == -1)
return msecs;
msecs -= elapsed;
return qMax(msecs, 0);
}bool MyCoolPort::waitForReadyRead(int msecs, int count)
{
QElapsedTimer stopWatch;
stopWatch.start();do { waitForReadyRead(timeout(msecs, stopWatch.elapsed())); if (bytesAvailable() >= count) return true; } while (msecs == -1 || timeout(msecs, stopWatch.elapsed()) > 0); return false;
}@