Details
-
Bug
-
Resolution: Done
-
P1: Critical
-
5.6.0, 5.7.0 Alpha, 5.7.0 Beta
-
None
-
windows 7
-
a40fcae40fdc4d7cd658c4b8ab38aad7572f2ecf
Description
Calculation of send timeout is incorrect.
Here is the calculation code:
http://code.qt.io/cgit/qt/qtserialbus.git/tree/src/serialbus/qmodbusrtuserialmaster_p.h#n294
// Example: 9600 baud, 11 bit per packet -> 872 char/sec // so: 1000 ms / 872 char = 1.147 ms/char * 3.5 character m_sendTimer.start((1000. / (qreal(m_baudRate) / 11.)) * m_current.adu.size());
Which in my case (115200 and 8 bytes of data) gives 0.7 ms. And after conversion to int, it becomes zero.
So m_sendTimer is fired up immediately, which brings us to to this code:
http://code.qt.io/cgit/qt/qtserialbus.git/tree/src/serialbus/qmodbusrtuserialmaster_p.h#n323
} else if (m_current.bytesWritten < m_current.adu.size()) { qCDebug(QT_MODBUS) << "(RTU client) Send failed:" << m_current.requestPdu; if (m_current.numberOfRetries <= 0) { if (m_current.reply) { m_current.reply->setError(QModbusDevice::TimeoutError, QModbusClient::tr("Request timeout.")); }
So there comes a premature timeout.
I experimented with a timeout and found that even a value of 15-20ms does not give stable results. only the value of around 50ms gives a stable result in my case.
I suppose that timeout calculation must include some additional minimum time constant.
It is only related to windows. In linux everything works perfectly.
Attachments
Issue Links
- duplicates
-
QTBUG-73965 Periodically, an assert will occur indicating that processQueue is in an unexpected state which is Idle
-
- Closed
-