summaryrefslogtreecommitdiff
path: root/src/serialport/qserialport_wince.cpp
diff options
context:
space:
mode:
authorDenis Shienkov <denis.shienkov@gmail.com>2013-10-07 16:20:10 +0400
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-11-28 16:10:58 +0100
commit550a99c4785c9a5b69a1799ee4ba217a87aea49e (patch)
tree66382cd668ce2e0431eecb1bc0fa8f49f318f4ce /src/serialport/qserialport_wince.cpp
parent10ea89238b353e4d9a787bc04cfecaf6568dd493 (diff)
downloadqtserialport-550a99c4785c9a5b69a1799ee4ba217a87aea49e.tar.gz
Use direct access to the read buffer
1. Use the auxiliary array to store the chunks of data at reading on Windows. The additional array is used for temporary storing the data chunks of the each asynchronous reading operation. This data will be appended to the class read buffer when asynchronous operation completed. It reduce quantity of calls for reallocation of the input ring buffer because now the reallocation with the actual data is carried out once in the completeAsyncRead() method. 2. Delete the bytesAvailable() and readFromBuffer() methods from the QSerialPortPrivate. These methods are not necessary any more, because now the size and content of the read buffer always has actual value. Now all dependent methods can access to the read buffer directly without the intermediaries, like bytesAvailable() and readFromBuffer(). Tested the build with Qt4 and then Qt5 for: * Windows 7/8, MinGW * Windows CE Pocket PC, VS2005 * Android platforms ARM and x86 * Archlinux 64-bit Tested the work with the terminal, the creader(a)sync, the cwriter(a)sync examples with Qt4 and then Qt5 for: * Windows 7/8 with the virtual com0com, the physical on-board and the USB PL2303 devices * Archlinux 64-bit with the physical on-board and the USB PL2303 devices Change-Id: I6871f8933588377646ffeccf1d2c21bb6caada24 Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com> Reviewed-by: Laszlo Papp <lpapp@kde.org>
Diffstat (limited to 'src/serialport/qserialport_wince.cpp')
-rw-r--r--src/serialport/qserialport_wince.cpp29
1 files changed, 0 insertions, 29 deletions
diff --git a/src/serialport/qserialport_wince.cpp b/src/serialport/qserialport_wince.cpp
index 21bea1e..2983071 100644
--- a/src/serialport/qserialport_wince.cpp
+++ b/src/serialport/qserialport_wince.cpp
@@ -253,35 +253,6 @@ bool QSerialPortPrivate::clear(QSerialPort::Directions directions)
return ::PurgeComm(descriptor, flags);
}
-qint64 QSerialPortPrivate::bytesAvailable() const
-{
- return readBuffer.size();
-}
-
-qint64 QSerialPortPrivate::readFromBuffer(char *data, qint64 maxSize)
-{
- if (readBuffer.isEmpty())
- return 0;
-
- if (maxSize == 1) {
- *data = readBuffer.getChar();
- return 1;
- }
-
- const qint64 bytesToRead = qMin(qint64(readBuffer.size()), maxSize);
- qint64 readSoFar = 0;
- while (readSoFar < bytesToRead) {
- const char *ptr = readBuffer.readPointer();
- const int bytesToReadFromThisBlock = qMin(int(bytesToRead - readSoFar),
- readBuffer.nextDataBlockSize());
- ::memcpy(data + readSoFar, ptr, bytesToReadFromThisBlock);
- readSoFar += bytesToReadFromThisBlock;
- readBuffer.free(bytesToReadFromThisBlock);
- }
-
- return readSoFar;
-}
-
qint64 QSerialPortPrivate::writeToBuffer(const char *data, qint64 maxSize)
{
char *ptr = writeBuffer.reserve(maxSize);