diff options
author | Karsten Heimrich <karsten.heimrich@qt.io> | 2017-08-14 10:14:29 +0200 |
---|---|---|
committer | Karsten Heimrich <karsten.heimrich@qt.io> | 2017-08-14 11:37:15 +0000 |
commit | 1d37c357c843a2622d2af7e1684576e19a8c7c30 (patch) | |
tree | a03806fb4dbe51c94406c3c51cd81a19aa272da9 | |
parent | f2a800d69903448ec5388a3776dbb43bcc2670a5 (diff) |
Fix unxepected state in Modbus process queued element
Due to the nature of our serial bus device, a frame could already
be send completely, but the bytes written did not report that yet.
Then we received an answer before we reached the receive state,
messing up the whole state logic. Now we process incoming frames
only if we are in receive state, otherwise drop full frames.
Task-number: QTBUG-62144
Task-number: QTBUG-62299
Change-Id: I88a4cf0b64a823409cbb277431a004a9d126cddc
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
-rw-r--r-- | src/serialbus/qmodbusrtuserialmaster_p.h | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/src/serialbus/qmodbusrtuserialmaster_p.h b/src/serialbus/qmodbusrtuserialmaster_p.h index aaf8ecd..770a39b 100644 --- a/src/serialbus/qmodbusrtuserialmaster_p.h +++ b/src/serialbus/qmodbusrtuserialmaster_p.h @@ -151,6 +151,9 @@ public: return; } + if (m_state != State::Receive) + return; + m_sendTimer.stop(); m_responseTimer.stop(); processQueueElement(response, m_current); @@ -327,6 +330,7 @@ public: m_current.reply->setError(QModbusDevice::TimeoutError, QModbusClient::tr("Request timeout.")); } + m_current = QueueElement(); scheduleNextRequest(); } else { m_serialPort->clear(QSerialPort::AllDirections); |