diff options
author | Denis Shienkov <denis.shienkov@gmail.com> | 2014-07-19 19:25:19 +0400 |
---|---|---|
committer | Denis Shienkov <denis.shienkov@gmail.com> | 2014-10-06 15:40:02 +0200 |
commit | 62dfdeb3642250bdb642dbf607a8c7b95e57835e (patch) | |
tree | a38ae8ded5ffcfd0fbe2541dcfa6ba1301e9268a /src/serialport/qserialport_unix_p.h | |
parent | d9a29ff7cc479e8a9e6d418de6408866f0dce4b6 (diff) |
Fix QSP::bytesToWrite() on Windows
After calling the WriteFile() function, QSP::bytesToWrite() should
return zero, but did return the size of writeBuffer.
On Windows, we must not to cut a size of the writeBuffer until the
asynchronous write operation has completed. So we need to make use of an
additional actualBytesToWrite variable, the value of which is increased
when new data is added to the writeBuffer, and decreased after calling
the WriteFile() function.
This change also entails the modification of the QSP::writeData() method
and deleting the QSP::startWriting() method. Now all platform-dependent
code (related to startWriting(), and to copying of memory to
writeBuffer) resides in the new QSP::writeData() method. But this
modification does not change the behavior on platforms other than Windows.
Tested on Windows with the virtual com0com serial ports using Qt5.
Change-Id: I35c1428ad374c0709d6c352a93c552898e947bde
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@digia.com>
Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
Diffstat (limited to 'src/serialport/qserialport_unix_p.h')
-rw-r--r-- | src/serialport/qserialport_unix_p.h | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/serialport/qserialport_unix_p.h b/src/serialport/qserialport_unix_p.h index 408fdc50..14e3cea2 100644 --- a/src/serialport/qserialport_unix_p.h +++ b/src/serialport/qserialport_unix_p.h @@ -119,7 +119,6 @@ public: bool sendBreak(int duration); bool setBreakEnabled(bool set); - void startWriting(); qint64 readData(char *data, qint64 maxSize); bool waitForReadyRead(int msecs); @@ -137,6 +136,9 @@ public: bool startAsyncWrite(); bool completeAsyncWrite(); + qint64 bytesToWrite() const; + qint64 writeData(const char *data, qint64 maxSize); + static QString portNameToSystemLocation(const QString &port); static QString portNameFromSystemLocation(const QString &location); |