Query a serial number of USB device from Sysfs

Tested on Linux with the USB (FTDI and TI) serial ports
using Qt4

Change-Id: I8c088bf8b6fe440565cc37538ca7ef029651fb61
Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
Fix access after delete in OS X QSPI

Valgrind analysis shows that searchStringProperty was accessing memory
after deletion. This was caused by constructing QCFString local var
with CFStringRef, which does not retain object.

Change-Id: I1e9571a5051aa6f0c3fbc732ac01e821069f8b02
Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
Fix order of passed parameters into QCOMPARE

According to documentation the QCOMPARE should accept to the first
parameter an actual value, and to the second parameter an expected value.

Change-Id: I64e762e779fa6a61401f358c4dd6097dacf7a33a
Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
Fix typo in twoStageSynchronousLoopback test

Commit f1761c1236edce428278f7a9e8aa1091097eaa57 introduce a typo
for receiverPort and senderPort variables, that lead to failure of test.

Change-Id: I18ecad78bb11d7bb218a674c3c3bf9c863a2b33c
Reviewed-by: Samuel Gaist <samuel.gaist@edeltech.ch>
Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
Handle onboard serial ports when parsing sysfs

The device detection stopped if one of the sources reported at least
one device. This made onboard serial ports not listed if a USB device was
plugged in. Onboard serial ports are now detected and added to the list
of devices.

Change-Id: I8798e7f14073e19d9e206eb4d7cdd0b28bd8a0bb
Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
Fix segfault related to dynamic udev loading

Problem was caused by conflict of libudev symbols and function pointers
declared in qtudev_p.h.

Task-number: QTBUG-40113
Change-Id: I599575e8a1b9ffe32295331d46d991422975f773
Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
Remove custom baud rate filtering

Some serial device have baud base that it is not multiple of baud rate selected,
so we need to allow baud rate compliant with device.

Change-Id: I7d3ce94f10d4382a29ff34bb18daebb650186c1c
Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
Fix reading on Windows at limited read buffer size

In case the read buffer has a limited size then are impossible to read
remainder which is still can be in driver's queue, since no readyRead
signal emmitted and reading are stalled.

Problem is that Windows does not fire the EV_RXCHAR event in case a
driver's queue has ready to read remainder; this event will be triggered
only when a new data are received.

The solution is to start of asynchronous read operation for reading of
possible remainder from the queue after doing QSP::read() from the user.

Besides is necessary to meet conditions:

- do not start reading in case a reading already is started

- do not start reading in case is not in limited buffer size

- do not start reading in case is a previous reading returns
a less data than read buffer size or are not in the hardware
flow control mode

Tested on Windows 8 with virtual com0com serial ports using Qt5 and then
Qt4.

Task-number: QTBUG-41295
Change-Id: I01797e6f8d6006751244144fead3616b1de1b811
Reviewed-by: Robert Kurjata <rkurjata@gmail.com>
Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
Restart of async reading when a QSP::clear() is called

The method QSP::clear() can stall reading in case of following
situations:

- at the moment when PurgeComm abort of previously started
asynchronous reading operation

- when a serial port is in hardware flow control mode

- when a serial port has a limited read buffer size

Therefore is necessary restart of asynchronous reading to enable
of the read sequence.

Change-Id: I7a722a1ee20ecba0dd631da96ca81d2937d7ca6b
Reviewed-by: Robert Kurjata <rkurjata@gmail.com>
Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
Allow for deviceInstanceIdentifier() to return an upper case string

Change-Id: I91977b1aa4a8e5bd8321efc5cfda375c9d7deff7
Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
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>
Merge remote-tracking branch 'origin/5.3' into 5.4

Change-Id: Id7e66059233e8d07ba44cad19048d9cddc68e250
Merge remote-tracking branch 'origin/5.4' into dev

Change-Id: I1312ec876fa74cf42637da1cea45421d380c129f