Do not start async read again if FIFO has no more data

The FIFO reading currently happens in chunks. The current
operation starts reading again even if there is no byte
available instead of waiting. This increases the overhead
of the library needlessly.

The correct thing to do is to wait instead of start reading
again when the last chunk is already handled.

Tested on Windows 8 using the on-board and the USB serial
ports and using Qt4 and Qt5.

Change-Id: I1926b853d1666b273d6d67b4a3f40261f1ed54ff
Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
Reviewed-by: Laszlo Papp <lpapp@kde.org>
Doc: Set example install path in documentation config

Correct example install path is required for the example
manifest file to contain valid paths to the .pro files.

Task-number: QTBUG-38359
Change-Id: Ibfe98ed4f3402f2e1534b578d0caecf3676a6f36
Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
Reviewed-by: Jerome Pasion <jerome.pasion@digia.com>
Reviewed-by: Laszlo Papp <lpapp@kde.org>
Bump MODULE_VERSION to 5.3.1

Change-Id: I46e1e634142ec2b34041ca876ca12bb10b52a9b6
Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
Fix the flush regression on Unix

Currently, flushing is not flushing the buffer to the device because
it is calling the wrong function.

Before flush() is invoked startAsyncWrite, but this did not flush the buffer
when it was not empty. The only possible way to fix this is by invoking the
function completeAsyncWrite, it first checks for pending information in the
buffer for sending and then invokes startAsyncWrite if necessary.

The following change caused the regression: 21f5049

Test Environment: Qt 5.3.0-beta1 and Qt 4.8.2.
S.O.: 3.12.6-2kali1 i686 GNU/Linux.
Fiscal Machine: SRP350 Bixolon.
USB Adapter Serial Port: CH341
Task-number: QTBUG-38339
Change-Id: I5159b48f073d537a396b65484fcc2c3d37e4908c
Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
Reviewed-by: Laszlo Papp <lpapp@kde.org>
Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
Merge remote-tracking branch 'origin/release' into stable

Change-Id: Ibbec2e6f136f9d7fa0362944d5f98a40814cd202
Mark the settingsRestoredOnClose property deprecated since 5.3

Commit bc0a65234440b6a08d862840a48ebae0d3421fbc incorrectly
marked this api as deprecated since 5.2

Change-Id: Ia4ea3d7a394376a16511a3bf2ad8ba6e051bc24d
Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@digia.com>
Enable QtSerialPort on QNX

On QNX, the combination (IHFLOW | OHFLOW) is equivalent to the CRTSCTS flag.
Only /dev/ser* ports can be enumerated.

Tested on SVTronics UEVM5432 Omap5 board with QNX 6.6

Change-Id: I64b149258a525835e63f231b5291fa86637e3d2a
Reviewed-by: Laszlo Papp <lpapp@kde.org>
Fix the serial number display in the terminal example

The display code was left out in commit
959775c41683033adbd99faab7e3d70e0009c143.

Tested using FTDI device on Windows 8 with Qt5 and
then on Windows 7 with Qt4.

Change-Id: I9f665b2826ba03877346b25a569ca89b6a3dc4af
Reviewed-by: Laszlo Papp <lpapp@kde.org>
Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
Merge remote-tracking branch 'origin/release' into stable

Change-Id: Idadda494181f643ef1b7fc2b2fb16dc5d215e83a
Ensure both input and output baud rates are set.

QSerialPortPrivate::setBaudRate() wasn't trying to set the output
baud rate for the port after successfully setting the input baud rate.

Also, some devices (such as FTDI chips) on Mac don't respond
properly if you call updateTermios() with mismatched baud rates,
even if you later set them to be the same.

Change-Id: I507fe10cba221bb4e43ded650dc44cc974de2414
Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
Reviewed-by: Laszlo Papp <lpapp@kde.org>
Fix the default constructor test case

Commit 7c737e0edcb93585856c65890ef34e5c5a28ee6b introduced
this regression by changing the default baud rate from 0 to 9600.

Change-Id: If20315eb53c3416646541dda82add0f4fc12d4a3
Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
Reviewed-by: Laszlo Papp <lpapp@kde.org>
Merge remote-tracking branch 'origin/release' into stable

Change-Id: I26db36a638685472296001d9982a157b8a6616b5
Add a unit test to verify flush()

On Windows a test will be skipped since flush() does not work there

Change-Id: Ibda38401aff5f1c50644c6d61f9802217146a4fb
Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
Merge "Merge remote-tracking branch 'origin/release' into stable" into refs/staging/stable
Use Q_NULLPTR for null pointer purposes with NULL fallback for Qt 4

Change-Id: I5422376a26111f7c8e084791a059215238a16868
Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
Reviewed-by: Steven Ceuppens <steven.ceuppens@icloud.com>
Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
Fix setting custom baud rates under Linux

This regression was caused by 7c737e0edcb93585856c65890ef34e5c5a28ee6b.
The initialization of the (current) serial port info was removed in that commit.

Tested on Linux x86_64 with Qt 5.1.1 and 4.8.6.

Task-number: QTBUG-38961
Change-Id: Idd3c5dc7eb37093848f33387563ff14567ac54fe
Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@digia.com>
Reviewed-by: Rafael Roquetto <rafael.roquetto@kdab.com>
Refactor QSerialPortPrivate::setBaudRate()

Split platform specific functions into their own setCustomBaudRate() methods to
improve readability.

As a side-effect, remove isCustomBaudRateSupported flag.

Change-Id: Ia26d5472219756fbf186c78aa049bba72966d7b5
Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
QNX: Enable custom baud rate

Change-Id: Iec4124886514c5bdeae1cf00e3b2e9432a2c75ee
Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
Return after an error of the async write operation

Tested on Windows 8 using the on-board and the USB serial
ports and using Qt4 and Qt5.

Change-Id: Idd25b81c9b6b2cd0b94e83fe30e6e7dad4dddfd6
Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
Use QTimer to defer starting of writing on Windows

The Win32 API has not possibility to do same behavior as on *nix to defer
a write operation to next event-loop. In *nix implementation enabling of
the write SocketNotifier guarantees that write operation will begin on the
following cycle of event-loop in case the TxFIFO of the driver is empty.

It give an feature of deferred data transfer where is possible to use chain
of the QSerialPort::write() methods which just accumulate data in
writeBuffer. Also it gives the chance to simple implement of the
waitForBytesWrite() method.

But in Windows implementation the first call of the QSerialPort::write()
leads to startup of data transfer. And the subsequent calls of this
method simply accumulate data while the previous operation won't completed.

It leads to a payload data are transferred by chunks and to increase of
loading of the write notifier. Also it complicates implementation of the
waitForBytesWritten() method which works not in compliance with
documentation.

The decision is use of additional QTimer with a zero interval which
launches data transfer on the following event-loop cycle.

Tested on Windows 8 using the virtual com0com serial ports and set
of the cwriter(a)sync examples with use Qt5.

Change-Id: Iaea404198e440f6cb191f168561c977d18e9f4ca
Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>