summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenis Shienkov <denis.shienkov@gmail.com>2014-01-28 16:22:33 +0400
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-02-11 08:16:42 +0100
commita93fc13093ce6c75f23f8edcf323a1244891f14b (patch)
treebd4876deac5fe396dc870294b3599dce8145a0ec
parentf85c5fc1e25dd16dc625d15036d2dbc9498e8b76 (diff)
downloadqtserialport-a93fc13093ce6c75f23f8edcf323a1244891f14b.tar.gz
Keep the DTR line state at changing of DCB properties
Updating of the DCB structure (in case of setup of some properties through setXX() methods) leads to reset of a status of the DTR line to an initial state. For example, after opening of port the DTR state was "high", further the call of method setDataTerminalReady(false) will drop the DTR to "low" state. But if now to change any properties of the device (e.g. to setup a new baud rate), the DTR will again be set to "high". The reason of this behavior is the fDtrControl flag of DCB structure: http://msdn.microsoft.com/en-us/library/windows/desktop/aa363214%28v=vs.85%29.aspx To control of DTR is used the EscapeCommFunction() function which has no relation to the DCB structure. Therefore any re-initialization of the DCB discard the results of the EscapeCommFunction() function in case a state of the fDtrControl flag not equal to the real DTR state. Solution is change of a fDtrControl flag after successfully call of the EscapeCommFunction() function. Then further change of any property will be with a correct DCB. Besides, it is necessary to drop the flag DTR_CONTROL_HANDSHAKE at opening of device. Because in this mode the manual control of the DTR line is forbidden. Thanks to Dr. Alexander W. Lenhardt Task-number: QTBUG-36490 Change-Id: I14b040761f7e28108db87e667eb76f559be436cb Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com> Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
-rw-r--r--src/serialport/qserialport_win.cpp4
-rw-r--r--src/serialport/qserialport_wince.cpp3
2 files changed, 7 insertions, 0 deletions
diff --git a/src/serialport/qserialport_win.cpp b/src/serialport/qserialport_win.cpp
index 116206f..5641fcb 100644
--- a/src/serialport/qserialport_win.cpp
+++ b/src/serialport/qserialport_win.cpp
@@ -175,6 +175,9 @@ bool QSerialPortPrivate::open(QIODevice::OpenMode mode)
currentDcb.fNull = FALSE;
currentDcb.fErrorChar = FALSE;
+ if (currentDcb.fDtrControl == DTR_CONTROL_HANDSHAKE)
+ currentDcb.fDtrControl = DTR_CONTROL_DISABLE;
+
if (!updateDcb())
return false;
@@ -290,6 +293,7 @@ bool QSerialPortPrivate::setDataTerminalReady(bool set)
return false;
}
+ currentDcb.fDtrControl = set ? DTR_CONTROL_ENABLE : DTR_CONTROL_DISABLE;
return true;
}
diff --git a/src/serialport/qserialport_wince.cpp b/src/serialport/qserialport_wince.cpp
index d9116cc..b987c80 100644
--- a/src/serialport/qserialport_wince.cpp
+++ b/src/serialport/qserialport_wince.cpp
@@ -204,6 +204,9 @@ bool QSerialPortPrivate::open(QIODevice::OpenMode mode)
currentDcb.fNull = false;
currentDcb.fErrorChar = false;
+ if (currentDcb.fDtrControl == DTR_CONTROL_HANDSHAKE)
+ currentDcb.fDtrControl = DTR_CONTROL_DISABLE;
+
if (!updateDcb())
return false;