Solved QSerialPort how set read and other timeouts
-
Hello everyone.
Is it possible to set timeouts for QSerialPort like ReadIntervalTimeout, ReadTotalTimeoutConstant or ReadTotalTimeoutMultiplier?
-
Hi and welcome
Both yes and no.
There are 2 ways to use QSerialPort
Synchronous and asynchronous ( block / non block)
For Synchronous operation
you use functions like
http://doc.qt.io/qt-5/qiodevice.html#waitForReadyRead
http://doc.qt.io/qt-5/qiodevice.html#waitForBytesWritten
Which does have msecs of how long to wait.For asynchronous operation you use signals and such timeout are not available.
So no, there is no way to set ReadTotalTimeoutMultiplier (afaik)
as its a pure windows thing and Qt is cross platform. -
Thanks for the answer. In oreder to work under any platform im rewriting the old win-application by using qt. In this old application time intervals was set manually. In my new application i tryed to use these funcs (watiForReadyRead, waitForBytesWritten) but after some time the device stops answering for no reason, so i tryed to repeat exactly the windows implementation, but looks like it would not be easy.
-
@Corban_Dallas
Well its hard to guess at , but even with slightly different
timings, the board should not stop responding.But if you cant debug the board and see why it stops being happy then it will be up hill.
You most likely already tried this but no harm mentioning it.
I would use a serial sniffer and have a look at a normal talk
with the board using the old program and then compare to new talk using Qt version. -
You can use QSerialPort::handle() and do what do you want on your own risk.