qt:qtserialport.git
4 years agoAdd the minimal set of the base auto tests v5.3.0-alpha1
Denis Shienkov [Thu, 23 Jan 2014 15:17:52 +0000 (19:17 +0400)]
Add the minimal set of the base auto tests

Added two types of tests: the constructing tests and the opening tests.

The construction tests are checking of the getters to return of default values.
Also are checking a correctness work of the constructor of class with different
types of a port name.

The opening tests are checking the open() method with the valid/invalid open
modes and with the valid/invalid port names. The results are compared with the
expected behavior (with the error codes and the return values).

Change-Id: I503adf629cf613844bf9b96d8704ff017ea5fcdb
Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
Reviewed-by: Frederik Gladhorn <frederik.gladhorn@digia.com>
4 years agouse private linkage where appropriate
Oswald Buddenhagen [Mon, 25 Nov 2013 11:14:44 +0000 (12:14 +0100)]
use private linkage where appropriate

Task-number: QTBUG-35781
Change-Id: I24b5ec010525da2c1f1be63996193ac31dcd3808
Reviewed-by: Laszlo Papp <lpapp@kde.org>
Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
4 years agoMerge remote-tracking branch 'origin/stable' into dev
Frederik Gladhorn [Mon, 17 Feb 2014 10:35:40 +0000 (11:35 +0100)]
Merge remote-tracking branch 'origin/stable' into dev

Change-Id: Ifff35473fe07ee5d94f9fb4f0125ee125c109c76

4 years agoSet error if the file buffer flushing fails on Windows old/5.2
Laszlo Papp [Fri, 14 Feb 2014 13:38:48 +0000 (13:38 +0000)]
Set error if the file buffer flushing fails on Windows

Change-Id: I58cf61540bc53e314988753a252cbc71003ce581
Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
4 years agoUse Q_GLOBAL_STATIC for the udev symbol loading QLibrary instance
Laszlo Papp [Sun, 16 Feb 2014 01:01:03 +0000 (01:01 +0000)]
Use Q_GLOBAL_STATIC for the udev symbol loading QLibrary instance

Even though this has been introduced in 5.1, officially, we can rely on it in
the previous versions even if private API that it was.

* Global variables are better avoided.

* Q_GLOBAL_STATIC is thread-safe in Qt 5.

* QLibrary depends on QCoreApplication and we need to make sure that is
initialized afterwards, respectively.

The instantiation is now moved into the corresponding source file so that if it
is included at more than one place, it will not be instantiated each time it is
used in a new source file including this header.

Task-number: QTBUG-36870

Change-Id: I96de1257e5836b69d0c48b717d7c2e708d6b0fee
Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
4 years agoUse the qt_safe_* methods for open/read/write/close
Laszlo Papp [Sat, 15 Feb 2014 18:35:24 +0000 (18:35 +0000)]
Use the qt_safe_* methods for open/read/write/close

This makes the operation thread-safe. It also helps with preventing the leaks
for child processes. Also, there is now some protection against EINTR when the
system call has to be restarted.

Thanks go to Thiago Macieira for providing the original patches.

Task-number: QTBUG-36824

Change-Id: I90cac87c5e1c55a57e5ba6c20313446c43c6d242
Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
4 years agoMerge remote-tracking branch 'origin/stable' into dev
Frederik Gladhorn [Fri, 14 Feb 2014 14:07:11 +0000 (15:07 +0100)]
Merge remote-tracking branch 'origin/stable' into dev

Change-Id: I111ca7fd67979152329f290d45bd5b47551a404a

4 years agoRemove the continuous warning about the unknown flow control
Laszlo Papp [Fri, 14 Feb 2014 12:44:35 +0000 (12:44 +0000)]
Remove the continuous warning about the unknown flow control

Task-number: QTBUG-36865

Change-Id: I332901ad0118f1176b0d3b8e45c8000f0dfb59ee
Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
4 years agoDo not emit bytesWritten() while data aren't transferred
Denis Shienkov [Wed, 22 Jan 2014 13:52:16 +0000 (17:52 +0400)]
Do not emit bytesWritten() while data aren't transferred

The serial port very slow device therefore the system
call write() doesn't guarantee that data were transferred
completely to the device. It guarantee only that data were
sent to the driver from the user space.

Thus it is wrong to emit the bytesWritten() signal at once
after successful writing.

The correct solution is to store the number of transferred
data in some variable (e.g. pendingBytesWritten in this
case) and to wait for the next notification from the
WriteNotifier that the write FIFO of device is empty (i.e.
when all data were really transferred) and ready to
transmission of the next portion of data.

Also good decision is to divide a data transfer operation
into two methods: startAsyncWrite() and completeAsyncWrite(),
similar with the Windows implementation.

Where the startAsyncWrite() invokes the write() system
call, and the completeAsyncWrite() is invoked by a
writeNotifier to complete writing operation or start a new
startAsyncWrite() operation.

Tested on Arch Linux 64 bit with the on-board and the USB
(PL2303) serial ports with use Qt4 and then Qt5.

Change-Id: I1c274b2052a9bd54811586c6f1cfdf080b400263
Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
4 years agoRevert the private qtcore_unix related changes because they break the Qt 4 build
Laszlo Papp [Wed, 12 Feb 2014 13:54:23 +0000 (13:54 +0000)]
Revert the private qtcore_unix related changes because they break the Qt 4 build

Revert "Open file descriptors thread-safely on Unix and don't leak them"

This reverts commit 691212d9e492b12590d5b7f4e2b24921911d4b17.

Revert "Protect against EINTR in Unix non-atomic I/O calls"

This reverts commit a8597cbae47076e33b638c2e593f852c8c0a02d5.

Change-Id: I6d931ae6d3b4bee9be019fdf4a08ecc5a41a2b0f
Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
4 years agoMerge remote-tracking branch 'origin/stable' into dev
Frederik Gladhorn [Wed, 12 Feb 2014 13:11:48 +0000 (14:11 +0100)]
Merge remote-tracking branch 'origin/stable' into dev

Change-Id: I10b71332b0ec3afc50d11bcc95adb94c6343f6b1

4 years agoUse QString for device properties
Denis Shienkov [Mon, 27 Jan 2014 11:49:35 +0000 (15:49 +0400)]
Use QString for device properties

The device registry property of the SPDRP_HARDWAREID is not
used any more. This property was used earlier for parsing of
the VID/PID and had the type of the REG_MULTI_SZ which was
interpreted as QStringList, see commit:

d8dc10efb1714dcfafa6a08e107fd31fc1e3ce0e

The current code is using only string based concept, hence
changing the interface to QString.

Tested on Windows 8 with on-board and virtual com0com serial
ports using the cenumerator example.

Change-Id: I31e4f85f1b145021c1b34b81ba890553604a0531
Reviewed-by: Laszlo Papp <lpapp@kde.org>
Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
4 years agoProtect against EINTR in Unix non-atomic I/O calls
Thiago Macieira [Tue, 11 Feb 2014 21:16:12 +0000 (13:16 -0800)]
Protect against EINTR in Unix non-atomic I/O calls

read(), write() and close() may return EINTR, indicating the system call
should be restarted. The qt_safe_xxx versions of those functions do it.

Change-Id: Ifef3b98131a7e24a5defea3e3af9345a505ad733
Reviewed-by: Laszlo Papp <lpapp@kde.org>
4 years agoOpen file descriptors thread-safely on Unix and don't leak them
Thiago Macieira [Tue, 11 Feb 2014 21:14:05 +0000 (13:14 -0800)]
Open file descriptors thread-safely on Unix and don't leak them

::open directly is not thread-safe. You need to pass O_CLOEXEC if the OS
supports it. That's the only thread-safe way to open files. qt_safe_open
does that for you.

This patch also implicitly makes all serial devices be opened with
CLOEXEC on all systems, which prevents the file descriptors from leaking
to child processes.

Change-Id: I83a2657fa8d9ccca1b42182bcd83416091066045
Reviewed-by: Laszlo Papp <lpapp@kde.org>
4 years agoDon't use cfmakeraw on SunOS
Sebastian Wiedenroth [Mon, 10 Feb 2014 02:02:43 +0000 (03:02 +0100)]
Don't use cfmakeraw on SunOS

The cfmakeraw() function is an extension to POSIX and thus not fully
portable. It doesn't exist on Solaris and Illumos.
Source: http://www.perkin.org.uk/posts/solaris-portability-cfmakeraw.html

Change-Id: Icf514fe32c01e85baff2a0d49321e45a320703b7
Reviewed-by: Laszlo Papp <lpapp@kde.org>
4 years agoMerge remote-tracking branch 'origin/release' into stable
Frederik Gladhorn [Tue, 11 Feb 2014 08:23:08 +0000 (09:23 +0100)]
Merge remote-tracking branch 'origin/release' into stable

Conflicts:
src/serialport/qserialport_win.cpp

Change-Id: Ib00a645c6660a3c81dbc9e159110f7bfc392ea36

4 years agoKeep the DTR line state at changing of DCB properties
Denis Shienkov [Tue, 28 Jan 2014 12:22:33 +0000 (16:22 +0400)]
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>
4 years agoInitialize the DCB structure before using it
Denis Shienkov [Thu, 6 Feb 2014 14:38:16 +0000 (18:38 +0400)]
Initialize the DCB structure before using it

Please refer to the MSDN documentation for details:

http://msdn.microsoft.com/en-us/library/windows/desktop/aa363214%28v=vs.85%29.aspx

and

http://msdn.microsoft.com/en-us/library/windows/desktop/aa363201%28v=vs.85%29.aspx

Change-Id: Id60f6d1b4a9237c2ae74063ac52221f42761b004
Reviewed-by: Laszlo Papp <lpapp@kde.org>
Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
4 years agoRename the writeSequenceStarted variable to writeStarted
Laszlo Papp [Sat, 8 Feb 2014 07:50:51 +0000 (07:50 +0000)]
Rename the writeSequenceStarted variable to writeStarted

Conflicts:
src/serialport/qserialport_win.cpp

Change-Id: I786879a485e78e3637d8cb474f86e3bd406bd237
Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
4 years agoRename the "descriptor" to handle on Windows
Laszlo Papp [Sun, 2 Feb 2014 19:52:33 +0000 (19:52 +0000)]
Rename the "descriptor" to handle on Windows

* Windows uses the term handle instead of descriptor.

* It is also consistent with the rest how Qt manages it.

Conflicts:
src/serialport/qserialport_win.cpp

Change-Id: I68a672ea2d8e88e26ad5d822b157ccab79a3d2d9
Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
4 years agoRemove the unused SystemIn/OutputQueue size methods
Laszlo Papp [Sun, 2 Feb 2014 19:22:42 +0000 (19:22 +0000)]
Remove the unused SystemIn/OutputQueue size methods

Change-Id: Iafab6ccc376da7a856b409017bbc42c36c016253
Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
4 years agoAdd error handling to some missing functions
Laszlo Papp [Sat, 1 Feb 2014 19:03:52 +0000 (19:03 +0000)]
Add error handling to some missing functions

Change-Id: If8dee1819d493fa4b27eba99de611c61bfdfe7a3
Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
4 years agoAdd enumeration through the SERIALCOMM registry entry
Denis Shienkov [Thu, 30 Jan 2014 15:52:48 +0000 (19:52 +0400)]
Add enumeration through the SERIALCOMM registry entry

When using some software that provide an virtual serial
ports functionality is impossible to use the Win32 SetupAPI
feature to enumerate these serial ports.

For example, such software is "Virtual Serial Ports Emulator"
from Eterlogic: http://www.eterlogic.com/Products.VSPE.html

The only possible simple way to detect these serial ports
it to read the registry key HARDWARE\\DEVICEMAP\\SERIALCOMM:

http://msdn.microsoft.com/en-us/library/windows/hardware/ff546502%28v=vs.85%29.aspx

In this case it is possible to get only a name of the serial
port without any additional information.

This method is simply addition to the main SetupAPI functionality.

Task-number: QTBUG-36526
Change-Id: Ib505aee66b74b6a8ebe16cf88c3060c8267397a0
Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
4 years agoUse the ternary operator meant for this purpose rather than two returns
Laszlo Papp [Sun, 2 Feb 2014 09:44:52 +0000 (09:44 +0000)]
Use the ternary operator meant for this purpose rather than two returns

Change-Id: Ie6b17d95b83ad751130305a6d44cdead3cd46da6
Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
4 years agoAdd listing of virtual ports from the "AGG Software"
Denis Shienkov [Sun, 26 Jan 2014 11:19:04 +0000 (15:19 +0400)]
Add listing of virtual ports from the "AGG Software"

The current algorithm takes a name of the serial port from
the PortName property which is in the Registry. This value is
filled out by the Ports class installer automatically:

http://msdn.microsoft.com/en-us/library/windows/hardware/ff546514%28v=vs.85%29.aspx

But at using the "AGG Software" software this property is
absent. Therefore the algorithm ignores these serial ports.

The simplest workaround is use of the PortNumber property
which identifies a port number for this software. In this
case a port name defines indirectly, by adding a port number
to the "COM" suffix.

This does not influence other serial ports which are defined
through PortName property.

Tested on Windows XP and Windows 8 with the cenumerator example.

Task-number: QTBUG-32774
Change-Id: I8cda3ed992ff80742511a2952d3fb7e8ac6edc81
Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
4 years agoRewrite the short description of the handle() method
Laszlo Papp [Thu, 16 Jan 2014 11:47:14 +0000 (11:47 +0000)]
Rewrite the short description of the handle() method

* handle() is duplicated since the description explains that method.

* It is pointless to put the "object" into the sentence.

* It is consistent to start the sentence with the "if".

Here goes a typical example that is worth following with consistency:

"If successful, returns true; otherwise returns false."

Change-Id: I1c7648237c75381b8452b8c47a59445fff58ad34
Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
4 years agoOptimize of writing sequence algorithm
Denis Shienkov [Thu, 23 Jan 2014 11:32:13 +0000 (15:32 +0400)]
Optimize of writing sequence algorithm

* The writeSequenceStarted shall be set to true after a successful call
of WriteFile() and to be dropped to false in case of write completion.

* The method startAsyncWrite() shall not call WriteFile() if the
writeBuffer is empty or writing sequence is already started. Also now
there is no sense to check a validity of pointers on data in writeBuffer
before call of WriteFile() because writeBuffer can not be empty.

* It is also expedient to free the writeBuffer in _q_completeAsyncWrite()
method only if numberOfBytesTransferred is not zero.

Tested on Windows 8 with the on-board and the USB (PL2303) serial ports.

Change-Id: Ib70276705fcc3f2396bf7dd6cf6977b62382a64b
Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
4 years agoHandle the ERROR_INVALID_NAME error code
Denis Shienkov [Thu, 23 Jan 2014 20:11:25 +0000 (00:11 +0400)]
Handle the ERROR_INVALID_NAME error code

If the user tries to open the serial port with empty
port name, Windows returns this error code.

The error will be exposed as
QSerialPort::DeviceNotFoundError from now.

Tested only on Windows 8 (32 bit) with on-board serial
port as well as an usb dongle (PL2303) using Qt4 and Qt5.

Change-Id: I9a56a7e51dbdab684b6d2a9fdf6398d8d5018e1c
Reviewed-by: Laszlo Papp <lpapp@kde.org>
Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
4 years agoFix some typos in documentation.
Jeff Tranter [Wed, 29 Jan 2014 19:18:58 +0000 (14:18 -0500)]
Fix some typos in documentation.

Fix some spelling and grammatical errors in comments that show up in Qt documentation. No changes to code.

Change-Id: I185458e162d115eac25326d239b851b5e14ed5cf
Reviewed-by: Laszlo Papp <lpapp@kde.org>
4 years agoMerge remote-tracking branch 'origin/stable' into dev
Frederik Gladhorn [Mon, 27 Jan 2014 17:54:58 +0000 (18:54 +0100)]
Merge remote-tracking branch 'origin/stable' into dev

Change-Id: Id640f4d6e6d6c6eb794cdc59d7c2008e60634274

4 years agoObsolete the TxD/RxD signals v5.2.1
Laszlo Papp [Mon, 20 Jan 2014 17:48:41 +0000 (17:48 +0000)]
Obsolete the TxD/RxD signals

They are not much of use due to the low-level OS limitations as of now, hence
the obsolete proposal. It can be brought back to life at any point when we have
a more clear idea what to do with this API.

"faking" this signal as RealTterm probably does it, is not a nice impression
for the end users. That would be more like a software "signal" (which we
already have in place) rather than a real pinout hardware signal.

It is interesting why Windows, Linux, etc do not provide an option for this.
There must be some strong reason for it.

Change-Id: Ia065e2ee9226d16e724f5e2690b25b954329d78e
Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
4 years agoRefactor the reference in the documentation for property setters/getters
Laszlo Papp [Fri, 24 Jan 2014 08:08:14 +0000 (08:08 +0000)]
Refactor the reference in the documentation for property setters/getters

The documentation contains broken links due to this, and it is also inconsistent
with the rest. Properties should be referred to as properties, not individual
methods like setter, getter, notified signal, etc.

The change is tested with "make docs" and the broken links are history.

Change-Id: Id94cba1f88503754318c865793229e3d3947bec6
Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
Reviewed-by: Jerome Pasion <jerome.pasion@digia.com>
Reviewed-by: Martin Smith <martin.smith@digia.com>
4 years agoFix the creaderasync example name in the qdoc file
Laszlo Papp [Thu, 16 Jan 2014 18:19:57 +0000 (18:19 +0000)]
Fix the creaderasync example name in the qdoc file

This change eliminates the following warnings when using "make docs":

/home/lpapp/Projects/qt/qt5/qtserialport/examples/serialport/doc/creaderasync.qdoc:28:
warning: Cannot find file 'creader/creader.pro' or 'creader/creader.qmlproject'

/home/lpapp/Projects/qt/qt5/qtserialport/examples/serialport/doc/creaderasync.qdoc:28:
warning:   EXAMPLE PATH DOES NOT EXIST: creader

It is also visible that the example is unreachable on the following
documentation page:

http://qt-project.org/doc/qt-5/examples.html

Change-Id: I09f1532fcff6b1f7bfc5c4857bd14252aceb2eb3
Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
4 years agoDisable build for WinRT
Maurice Kalinowski [Fri, 24 Jan 2014 10:35:27 +0000 (11:35 +0100)]
Disable build for WinRT

According to MSDN Windows Store apps will not have any
serial port replacement.

http://msdn.microsoft.com/en-us/library/windows/apps/hh464945.aspx

Change-Id: I2aa54462c411341e3b3cdbbbf65a7b3397df93b6
Reviewed-by: Laszlo Papp <lpapp@kde.org>
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
4 years agoRemove an unnecessary boolean interim variable
Laszlo Papp [Tue, 21 Jan 2014 17:10:30 +0000 (17:10 +0000)]
Remove an unnecessary boolean interim variable

This is needless because it is only used once, right after the creation.
Moreover, we would probably need to separate the two calls later into distinct
introspection conditions to give a bit more correct warning whether the sysfs is
present, or it is just not readable for some reason.

It is also consistent with some other places.

It also eliminates the needless indentation level for that relatively long
block.

Change-Id: Ib66e3033c2439315a8034101129cadd2dcdc29d0
Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
4 years agoMerge remote-tracking branch 'origin/stable' into dev
Frederik Gladhorn [Fri, 17 Jan 2014 16:25:58 +0000 (17:25 +0100)]
Merge remote-tracking branch 'origin/stable' into dev

Conflicts:
.qmake.conf

Change-Id: Id8be0cbb66eabf59c47011e4605e71cf29c1f532

4 years agoFix the broken handle() documentation
Laszlo Papp [Thu, 16 Jan 2014 18:11:00 +0000 (18:11 +0000)]
Fix the broken handle() documentation

This is likely to be happening due to the mismatching function signature include
the return type between the header and source file. Two things are being fixed:

1) Dropped scope for the Handle just like with the winId case in QWidget.

2) "const" qualifier is now added for the method.

Here you can see the documentation that it is empty:
http://qt-project.org/doc/qt-5/qserialport.html#handle

Change-Id: I5e9e0732cfd746a863de523fe90e58eafa42c081
Reviewed-by: Alex Henrie <alexhenrie24@gmail.com>
Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
Reviewed-by: Martin Smith <martin.smith@digia.com>
4 years agoFix the waitForReadyRead() behavior on Windows
Denis Shienkov [Wed, 25 Dec 2013 12:32:28 +0000 (16:32 +0400)]
Fix the waitForReadyRead() behavior on Windows

It is necessary to compare size of the readBuffer before and after
completion of each read operation. If size of readBuffer are equal
it means that are no more data available for reading. In this case
the method should returns true if an initial size of readBuffer is
not equal to the current size of readBuffer. Otherwise in all other
cases should be continue waiting until timeout has been expired.

Also must not to do check for the NoError code and to hope for valid
value of this code inside waitForReadyRead(). Because a last error
code do not clears automatically. It lead to false returns of this
method in case the error number is not equal to NoError (for example
it error remained after failed of any previous method). This check
should be implemented in a different way in case of need. But at
present this check is unnecessary because result of the waitAnyEvent()
cover it.

Task-number: QTBUG-33987
Change-Id: Ic8d8e3806fd4863c2720ffb83d5c19eae54d57f0
Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
Reviewed-by: Laszlo Papp <lpapp@kde.org>
4 years agoBump MODULE_VERSION to 5.2.2
Sergio Ahumada [Wed, 15 Jan 2014 21:59:45 +0000 (22:59 +0100)]
Bump MODULE_VERSION to 5.2.2

Change-Id: Ic1184214f9ce933fc3df47629e0a707e0b8d63f5
Reviewed-by: Laszlo Papp <lpapp@kde.org>
4 years agoOptimize access to the write buffer
Denis Shienkov [Fri, 10 Jan 2014 13:36:35 +0000 (17:36 +0400)]
Optimize access to the write buffer

Earlier for writing in writeBuffer was used the
QSerialPortPrivate::writeToBuffer() method which contained
a similar code for each platform.

Therefore it is reasonable to delete this method, and to move
its common functionality to the QSerialPort::writeData(). Also
all platform-dependent code of start of data transfer move to
the QSerialPortPrivate::startWriting() method.

Change-Id: I1423723fd69c05df974f8ba597e3dd71d5a797dd
Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
4 years agoUnify of the internal API of asynchronous handling
Denis Shienkov [Wed, 25 Dec 2013 13:52:51 +0000 (17:52 +0400)]
Unify of the internal API of asynchronous handling

It makes sense to unify internal methods of asynchronous I/O where to each
method of start of operation corresponds the method of completion of
operation:

* startAsyncCommunication() - it is a new method which has a code relating
to the handling of the WaitCommEvent() function. It implementations is taken
directly by copy/paste with minimal modifications relating with adding of
returns a boolean values.

* _q_completeAsyncCommunication() - it is an existing method which is renamed
from the _q_canCompleteCommunication().

* startAsyncRead() - it is an existing method without modifications.

* _q_completeAsyncRead() - it is an existing method which is renamed from
the _q_canCompleteRead(). Earlier this method contained a subfunction of
the completeAsyncRead(DWORD) which is deleted now, and its code (related with
the policy processing) is moved into body of the _q_completeAsyncRead() with
the minimum modifications which do not change it behavior.

* startAsyncWrite() - it is an existing method without modifications.

* _q_completeAsyncWrite() - it is an existing method which is renamed from
the _q_canCompleteWrite(). Earlier this method contained a subfunction of
the completeAsyncWrite(DWORD) which is deleted now, and its code is moved
into body of the _q_completeAsyncWrite() without modifications.

Also in addition is added the new method emitReadyRead() and the code of
policy emulation is moved into new method emulateErrorPolicy().

Change-Id: I58345e3270d676879a16efc4b7f35f74869894d8
Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
4 years agoMerge remote-tracking branch 'origin/stable' into dev
Frederik Gladhorn [Fri, 10 Jan 2014 17:30:35 +0000 (18:30 +0100)]
Merge remote-tracking branch 'origin/stable' into dev

Change-Id: I9b4871e9d69e73a1267a700aa953efaa0267c0e1

4 years agocreadersync: do not return successful read for empty data
Denis Shienkov [Wed, 25 Dec 2013 12:14:12 +0000 (16:14 +0400)]
creadersync: do not return successful read for empty data

In case of handling of the TimeoutError it is necessary to check on
existence of the read data (for this concrete implementation of the
example). Otherwise the application always return the TimeoutError
even if a data was successfully read.

Change-Id: I2437461f2ed2806bb7d7e16deb6925df035f62a1
Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
4 years agoMerge remote-tracking branch 'origin/stable' into dev
Frederik Gladhorn [Mon, 6 Jan 2014 15:30:34 +0000 (16:30 +0100)]
Merge remote-tracking branch 'origin/stable' into dev

Change-Id: I535078aafe7a322f3b09e2893a89e30c0028661a

4 years agoImprove data receiving in creaderasync example
Denis Shienkov [Wed, 25 Dec 2013 08:44:18 +0000 (12:44 +0400)]
Improve data receiving in creaderasync example

Received data should be accumulated at each triggering of readyRead()
during wait timeout. Otherwise application may print out only last
portion of received data.

Change-Id: Ib4d72f70e333298bae31c0eb95d7639b5c4d177d
Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
4 years agoMerge remote-tracking branch 'origin/stable' into dev
Frederik Gladhorn [Tue, 24 Dec 2013 00:06:18 +0000 (01:06 +0100)]
Merge remote-tracking branch 'origin/stable' into dev

Conflicts:
.qmake.conf
src/serialport/qserialportinfo_unix.cpp

Change-Id: I9582d161018939defd3ba81d601fff176e86eb3c

4 years agoReimplement low level data sending
Denis Shienkov [Mon, 30 Dec 2013 13:03:42 +0000 (17:03 +0400)]
Reimplement low level data sending

A feature of writing of the buffer by chunks of 512 bytes (by default)
was introduced earlier as the developers option in order that it was
possible to regulate load of the CPU and quantity of emitted signals of
bytesWritten() just change WriteChunkSize value in source code.

As shows of the practice, the most optimal mode is writing of whole
content of the buffer without division into chunks. It reduces load of
CPU (because reduces a quantity of the events triggers) and also
simplifies the source code.

But potentially there can be negative consequences of writing of whole
buffer directly in case of broken driver:

* A kernel panic (or BSOD) in case of writing a data large than
driver's internal queue.

* Can be transferred not all data from the buffer, but only their part.

Change-Id: I0fcac1ccf3c752579978b4745771accbf8274267
Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
4 years agoRemove unused variables
Denis Shienkov [Thu, 19 Dec 2013 14:28:50 +0000 (18:28 +0400)]
Remove unused variables

* actualWriteBufferSize variable - it is a wrong old heritage related with
the implementation of a code with the analogy from the the QWindowsPipeReader
(where actualReadBufferSize is present).

* acyncWritePosition variable - it is a old heritage when the write notifier
could operate with a multiple writing operations at the same time. For this
purpose it is necessary to know the following write position in the ring buffer.
But currently all write operations happen sequentially, i.e. forbidden to carry
out startAsyncWrite() several times without completeAsyncWrite() completion.

Change-Id: I25b665b638649e6002fb194babfaa73f5ec8a6fa
Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
4 years agoUse the signals/slots for internal events handling on Windows
Denis Shienkov [Mon, 18 Nov 2013 15:45:16 +0000 (19:45 +0400)]
Use the signals/slots for internal events handling on Windows

The principal idea of this patch - to simplify a code and to minimize
risks of UB in operation with the notifiers.

Details are below:

1) Use a separate instances for the each notifier.

It allows to get rid from an lookupXX() methods because now we always
know which of notifiers was triggered.

2) Now each notifier is created once and used during serial port life.

Moreover now in the open() and the close() methods are carried out a
simply enabling and disabling of the notifiers.

It allows to simplify code and to reduce overhead costs of check of
a validity of the notifier pointers.

3) Use the signals/slots mechanism for the internal events handling.

Use a slots excludes any UB in the notifier handlers because now isn't
present a deep callbacks and so on. Even if some notifier will be deleted,
we never got a crash at processing of triggered handle, we can just got
an some error code and handle it.

4) There is no more need for existence of separate classes of notifiers
which were inherited from the QWinEventNotifier.

Now, the objects of QWinEventNotifier are use directly, only for delivery
a triggered events to the appropriate slots. All logic of a events
handling are in the _q_xx() slots.

5) The overlappedPointer() methods aren't necessary to us anymore.

Now we know each OVERLAPPAD structure instance. It gives us to pass a
pointers of these structures directly to the
ReadFile/WriteFile/WaitCommEvent functions and have direct access to
the hEvent field for the waitForXXX() methods.

6) The errors handling inside of the _q_xx() handlers are simplified.

Now is not used a dptr-pointer to the QSerialPortPrivate class. So,
earlier entered additional method QSerialPortPrivate::setError() is
removed.

This patch with using of slots is a strategic step because in the future
in case of fix of a bug QTBUG-34946 instead of the QWinEventNotifier it
is necessary to use the QWinOverlappedIoNotifier which provides only
the signal/slot API.

Note: Also this patch implicitly fix a bug QTBUG-33938.

Task-number: QTBUG-33938
Change-Id: Iba9137e13e0bd6001c665434698b8cd965bc36e5
Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
4 years agoMerge remote-tracking branch 'origin/release' into stable
Frederik Gladhorn [Thu, 12 Dec 2013 17:10:16 +0000 (18:10 +0100)]
Merge remote-tracking branch 'origin/release' into stable

Conflicts:
src/serialport/qserialport.cpp
src/serialport/qserialportinfo_unix.cpp

Change-Id: I12658a9f92c91ab83f404c93a311ef947d1f2503

4 years agoDo not remove obsolete enum values for gcc and clang v5.2.0
Laszlo Papp [Tue, 3 Dec 2013 16:41:48 +0000 (16:41 +0000)]
Do not remove obsolete enum values for gcc and clang

Do not try to work around the gcc/clang limitations with external variables
since some people have some concern that it may break the binary compatibility
due to the underlying representation layout.

Talk to upstream (gcc) if a warning for this is desired. It is out of scope for
us. C++14 will help with the [[deprecated]] attribute, but that is light years
ahead.

Task-number: QTBUG-35354
Change-Id: I1c4e0fb950469adceca85147084fa896503de78b
Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
4 years agoDeprecate further Unknown* property values similarly to UnknownParity
Laszlo Papp [Sat, 30 Nov 2013 19:21:37 +0000 (19:21 +0000)]
Deprecate further Unknown* property values similarly to UnknownParity

Task-number: QTBUG-35215
Change-Id: Id8175af00c431cc8f80f05d518b3a2ee0e8ac71b
Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
4 years agoMark the 1.5 stop bits in the documentation as Windows only
Laszlo Papp [Sat, 30 Nov 2013 18:13:16 +0000 (18:13 +0000)]
Mark the 1.5 stop bits in the documentation as Windows only

Change-Id: I58ee8bf1913c773f345b23bd01d1cc3fefc5f6ac
Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
4 years agoFix a typo in the 5.2.0 changelog text
Laszlo Papp [Sat, 30 Nov 2013 17:27:40 +0000 (17:27 +0000)]
Fix a typo in the 5.2.0 changelog text

Change-Id: I211a417d1e4af8e22a2fd736093f099b8fd15cd8
Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
4 years agoDocument the real meaning of the data bits enumeration values
Laszlo Papp [Sat, 30 Nov 2013 12:34:35 +0000 (12:34 +0000)]
Document the real meaning of the data bits enumeration values

Change-Id: I7e12e26e6676ecb064eb06599234d2844041335d
Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
4 years agoAdd the additional enumeration through Device Interface Class GUID
Denis Shienkov [Fri, 8 Nov 2013 12:36:26 +0000 (16:36 +0400)]
Add the additional enumeration through Device Interface Class GUID

The current "Setup Class GUID" approach ignores the devices which has
been created by the drivers with a custom setup GUID's (e.g. Eltima
Virtual Serial Port Driver and so on).

In this case need to add each new custom GUID to the list. But it is
not a good solution and shall be used as a last resort.

The good solution is use of the "Device Interface Class GUID" instead
of the "Setup Class GUID" because it is the recommended way:

http://msdn.microsoft.com/en-us/library/windows/hardware/ff545036%28v=vs.85%29.aspx
http://msdn.microsoft.com/en-us/library/windows/hardware/ff545046%28v=vs.85%29.aspx

A new approach uses the standard GUID_DEVINTERFACE_COMPORT and
GUID_DEVINTERFACE_MODEM GUID's which shall be used for the development
of any serial port drivers. Besides requires adding of the additional
DIGCF_DEVICEINTERFACE flag for the SetupDiGetClassDevs() function,
see MSDN:
http://msdn.microsoft.com/en-us/library/windows/hardware/ff551069%28v=vs.85%29.aspx

It should be noted that this approach also can ignore some devices
with drivers which don't use the recommendation. Earlier already
there were attempts to implement this approach but unsuccessful,
see more 3bfe998860e0bfd3ce48784188eaa0d58bf86da1 and
bcdeb589dd9d3b0ff7270d380d043b1882eefdc0 commits.

Thus, it seems effective to use both "Setup Class GUID" and
"Device Interface Class GUID" approaches that will complement each
other. In this case can be keep only the standard GUID's.

1. Now all GUID classes are in the QUuid form and stored in the
constant list of pairs as QPair<uuid, flags>. It allows to avoid the
old heritage related to the pure-C coding style.

2. The second "flags" parameter from the pair is the DWORD input
parameter for the SetupDiGetClassDevs() function which specify the
control options that filter the device information elements. It
allows to pass the appropriate flags for the each used approach
independently.

Tested with the cenumerator example on Windows with Qt4 and then Qt5,
no regressions found.

Task-number: QTBUG-33313
Change-Id: I478905e8ae4b79b7d967e0727d2e1620ad667177
Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
Reviewed-by: Laszlo Papp <lpapp@kde.org>
4 years agoObsolete the QSerialPort::UnknownParity enum value in QSerialPort
Laszlo Papp [Fri, 29 Nov 2013 06:17:49 +0000 (06:17 +0000)]
Obsolete the QSerialPort::UnknownParity enum value  in QSerialPort

Task-number: QTBUG-35215
Change-Id: I53af65ba485216a6fde238245580fe0422a2ed9a
Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
4 years agoObsolete the isValid() method in QSerialPortInfo
Laszlo Papp [Thu, 28 Nov 2013 03:48:05 +0000 (03:48 +0000)]
Obsolete the isValid() method in QSerialPortInfo

Task-number: QTBUG-35184
Change-Id: Ie822943bcaf071024bc4f9782441b0534fcbd43d
Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
4 years agoOptimization of the write notifier algorithm
Denis Shienkov [Sat, 16 Nov 2013 17:10:13 +0000 (21:10 +0400)]
Optimization of the write notifier algorithm

The algorithm before the commit eca1a6d30a98861cb811cb2faf8d01334e60dd7c
could process the write events from the several notifiers, which could be
created in data transfer operation.

But now the write notifier always is in one instance, so can do following
optimizations:

* The method lookupFreeWriteCompletionNotifier() now is renamed to the
lookupWriteCompletionNotifier() and returns the pointer to the existing
notifier without creating them (by analogy with others lookupXX() methods).

* Now there is no need to control the write notifier state (to do enable
or disable) in data transfer process. The current algorithm doesn't require
it and the write notifier enabled once when port opens.

* Use the open mode flag instead of low-level events mask to create the
write notifiers. Also, this handling was added similarly to the read
notifier.

Tested the work with the terminal, the creader(a)sync, the cwriter(a)sync
examples with Qt4 and then Qt5 on Windows 7/8 with use:

* the virtual serial ports (the com0com project)
* the physical on-board serial ports and the USB serial ports

Change-Id: I8bc6a025a00dde986fde38c052d3ade4215938ec
Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
Reviewed-by: Laszlo Papp <lpapp@kde.org>
4 years agoClear unused members of the overlapped structure before each usage
Denis Shienkov [Tue, 12 Nov 2013 09:19:20 +0000 (13:19 +0400)]
Clear unused members of the overlapped structure before each usage

For more detail, see remarks from the MSDN:
http://msdn.microsoft.com/en-us/library/windows/desktop/ms684342%28v=vs.85%29.aspx

Change-Id: Id6e5adc48e8a4648f1aabba598696b34c658a159
Reviewed-by: Laszlo Papp <lpapp@kde.org>
Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
4 years agoUse direct access to the read buffer
Denis Shienkov [Mon, 7 Oct 2013 12:20:10 +0000 (16:20 +0400)]
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>
4 years agoDocument the real meaning of the parity enumeration values
Laszlo Papp [Thu, 28 Nov 2013 08:35:53 +0000 (08:35 +0000)]
Document the real meaning of the parity enumeration values

Change-Id: I58f689e6bf8480c5a608f91d7f4fb7a83235d631
Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
4 years agotest: Add 5.1.0 bic data for linux-gcc-ia32
Sergio Ahumada [Fri, 5 Jul 2013 18:58:05 +0000 (11:58 -0700)]
test: Add 5.1.0 bic data for linux-gcc-ia32

Change-Id: I23025d79468650a62c881d3c8cbedfcb7d039495
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
4 years agoFix the detection of PCI serial ports with sysfs and without udev v5.2.0-rc1
Laszlo Papp [Sat, 23 Nov 2013 21:49:33 +0000 (21:49 +0000)]
Fix the detection of PCI serial ports with sysfs and without udev

Unfortunately, 0973537c5471288726b929250199a41435729bee caused a serious
regression for obtaining detecting PCI serial ports without udev. This was
working before since the hard coded fallback mechanism has been up to this task,
but the sysfs alternative took the precedence over.

A note has also been added to the udev part of the algorithm because we will
need to obtain the vendor and product identifiers in a separate block in the
future. The vid/pid will be fixed in a separate change once that is well-tested.
This patch has no any risk as far as I can tell since it is just adding a new
short block to the existing code without much implication.

I have tested the change on Linux for my use cases with Qt 4 and then 5, and I
cannot find any regression. Everything works as expected both with udev and
without, i.e. with sysfs.

Thanks go to Aaron Linville for reporting the issue.

Task-number: QTBUG-35064
Change-Id: Ieae6f3e94559fb61ede67ff1d8810bb686d46383
Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
Reviewed-by: Aaron Linville <aaron@linville.org>
4 years agoBump MODULE_VERSION to 5.2.1
Sergio Ahumada [Mon, 25 Nov 2013 11:49:32 +0000 (12:49 +0100)]
Bump MODULE_VERSION to 5.2.1

Change-Id: Ie52035bd9eec3fffb2c2b2b6b9869dd23f4ace3f
Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
Reviewed-by: Laszlo Papp <lpapp@kde.org>
Reviewed-by: Matti Paaso <matti.paaso@digia.com>
4 years agoDrop the empty data check in favor of proper error code handling
Laszlo Papp [Wed, 20 Nov 2013 18:39:50 +0000 (18:39 +0000)]
Drop the empty data check in favor of proper error code handling

Change-Id: Iad0f2c58a4f52daebd02a71fd7b404cb283602dc
Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
4 years agoTry to load udev at runtime if we do not link against it
Laszlo Papp [Sat, 23 Nov 2013 10:32:01 +0000 (10:32 +0000)]
Try to load udev at runtime if we do not link against it

There was an explicit option previously added into 5.2.0 due to lack of time to
implement this runtime resolution properly. The libudev load variable can now be
eliminated which also simplifies the packaging.

This change also takes care of avoiding the regression by not loading udev at
runtime at all for Qt 4. That has always been the case, so there are no
regressions there. A TODO comment has been left in the code though about it.

The helper free functions cannot be static because they are declared as friend
outside that source file. Ideally, we could have a better approach, but that
would require more significant refactoring, and such a revamp has to become
stable in the 'dev' branch before going into the 'stable' branch. Thereby, this
is an acceptable compromise.

It does not break binary compatibility either to remove or add friend
declarations to a class.

The change has been tested on Archlinux (x86_64) with Qt 4 and then 5 using the
cenumerator example. The change has been tested both with udev and without that,
i.e with sysfs on my Linux system.

Change-Id: Ia7d7ecb336c1de1913e1dd60177ae7469e90c329
Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
4 years agoSimplify the standard baudrate getter by dropping the foreach
Laszlo Papp [Sun, 24 Nov 2013 18:32:42 +0000 (18:32 +0000)]
Simplify the standard baudrate getter by dropping the foreach

1f1ca7490fa6e2231f396e564dacbbd8d0e10b29 rewrote this part of the code, but the
needless logic has not be dropped respectively. It was necessary before the
rewrite since the raw qint32* type had to be converted to QList<qint32>, but
since we have a more Qt'ish data storage up front, we do not need to iterate
through the list since it is ready-made for us.

Change-Id: Iab5d4b0d48de3fc27fb41a4694f044bd58e760c4
Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
4 years agoRemove the unnecessary and noisy comments for the serial port info files
Laszlo Papp [Sat, 23 Nov 2013 23:45:36 +0000 (23:45 +0000)]
Remove the unnecessary and noisy comments for the serial port info files

Comments are noisy, useless, and can get outdated. The only comments that might
make sense to me the ones where we note future tasks, such as TODO (or FIXME).
The code should document itself.

The serial port files need a separate evaluation since a lot of stuff is
inherited from QtCore in there where the comments should probably be kept for
consistency.

Change-Id: I6c759c7138f64546c2c4e27a039667c556a30db9
Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
4 years agoDo not use parentheses around a single statement for consistency
Laszlo Papp [Sun, 24 Nov 2013 17:55:28 +0000 (17:55 +0000)]
Do not use parentheses around a single statement for consistency

Change-Id: I54533863c80933eed8f01de190bb7713f64f6999
Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
4 years agoMerge two mini-functions for the hard coded list
Laszlo Papp [Sun, 24 Nov 2013 00:10:02 +0000 (00:10 +0000)]
Merge two mini-functions for the hard coded list

It is done for the following reason:

1) Consistency with the unix backend of the QSerialPort class, where the
serialPortLockFilePath free function is also like this.

2) There is no point in having a separate free function for initializing a
variable when it is only used in one place.

3) It is less abstraction.

4) It is negligibly faster.

5) It is still a small enough free function, and naturally fits the one page
maximum limit for a function which is the general recommendation in projects.

6) Last, but not least: It also makes the code shorter and more concise.

Change-Id: Ie07f06521e11038bdd3cc504a56cadcf00e68269
Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
4 years agoEliminate the "canAppendToList" variable usage
Laszlo Papp [Sat, 23 Nov 2013 21:26:10 +0000 (21:26 +0000)]
Eliminate the "canAppendToList" variable usage

There are problems with this variable:

1) It should have been called "isSerialPortValid" or something like that to be
more precise abouts its functionality.

2) It should have had false value by default since we do not assume everything
is correct by default, and exclude certain ones, but the other way around,
logically.

3) Most importantly: It makes the code unnecessarily longer since the loop can
be continued with the next iteration without the need to insert an invalid
serial port and an interim variable.

Tested the cenumerator example on Linux with udev using Qt 4 and then 5. There
are no regressions found.

Change-Id: I4f6bdce402f03eac696c0d2ce9448e59baedf56b
Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
4 years agoReplace the silly empty output with a reasonable "N/A" placeholder
Laszlo Papp [Sat, 23 Nov 2013 17:59:34 +0000 (17:59 +0000)]
Replace the silly empty output with a reasonable "N/A" placeholder

Change-Id: Iad5076e9a192f5a07e41314d286bc02e46ea92c8
Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
4 years agoRemove the very bizarre whitespaces from inconsistent macro usages
Laszlo Papp [Sat, 23 Nov 2013 09:50:26 +0000 (09:50 +0000)]
Remove the very bizarre whitespaces from inconsistent macro usages

b8af6f604cd86897c8a04825700892fd9970a616 introduced this for no any valid
reason. There was no review back then, so any silly stuff like this could sneak
in.

Change-Id: I80c21e9f2a7c5eec3b126e8080132ca43a60f12b
Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
4 years agoDo not handle "no data available" as error in the timeout handler
Laszlo Papp [Wed, 20 Nov 2013 18:31:30 +0000 (18:31 +0000)]
Do not handle "no data available" as error in the timeout handler

Change-Id: I132a668f1eca2d7a1ac353b6e088b7b07d4e2e12
Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
4 years agoMerge remote-tracking branch 'origin/stable' into dev
Frederik Gladhorn [Wed, 20 Nov 2013 15:44:54 +0000 (16:44 +0100)]
Merge remote-tracking branch 'origin/stable' into dev

Change-Id: I4ed57bc4bce87b9982a33ddf692b156721175440

4 years agoRemove the standard input copy/paste issue from the QIODevice documentation
Laszlo Papp [Wed, 20 Nov 2013 06:58:30 +0000 (06:58 +0000)]
Remove the standard input copy/paste issue from the QIODevice documentation

Change-Id: I03d4be1bf7fd5670c563484759eda670c9a0cb75
Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
4 years agoAdd the missing error handling on Windows for QSerialPort
Laszlo Papp [Mon, 11 Nov 2013 07:09:08 +0000 (07:09 +0000)]
Add the missing error handling on Windows for QSerialPort

Change-Id: Ia6bbf1d3958b7b9930650399ce6e99e7cc98ef2a
Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
4 years agoUse ZeroMemory on Windows instead of zero memset
Laszlo Papp [Wed, 13 Nov 2013 11:54:43 +0000 (11:54 +0000)]
Use ZeroMemory on Windows instead of zero memset

See the documentation for details:

http://msdn.microsoft.com/en-us/library/windows/desktop/aa366920(v=vs.85).aspx

Two immediate advantages:

1) Consistent with the rest of Qt.

2) It is more convenient and explicit than the raw memset.

Unfortunately, Windows CE does not seem to have this supported, so it is not
changed in there:

http://users.atw.hu/lingoland/akademia/zeromem.htm

"Windows CE: Unsupported."

Change-Id: I44154c320f13054e1bfd08e3ff1e957430eeeb49
Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
4 years agoFix the properties counter declaration place
Denis Shienkov [Sat, 9 Nov 2013 18:50:38 +0000 (22:50 +0400)]
Fix the properties counter declaration place

The properties counter shall count quantity of the processed properties for
the each found device.

Tested on Mac OSX 10.9 with Qt5, no regressions found.

Change-Id: Ie665c52dfdea5a0f9c358909e903703c41144a60
Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
4 years agoAdd an entry in the 5.2.0 change for the extended Android lock file support
Laszlo Papp [Sun, 10 Nov 2013 08:51:57 +0000 (08:51 +0000)]
Add an entry in the 5.2.0 change for the extended Android lock file support

This should have been added in the change
030f4f7d8839f1f5070fd1f4d385e775c0ef66bd, but unfortunately it has been omitted.

Change-Id: I36b5134846c32e6246f2b5ff36470a52ff267e3e
Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
4 years agoAdd a new simple and command line async reader example
Laszlo Papp [Sat, 26 Oct 2013 12:06:40 +0000 (13:06 +0100)]
Add a new simple and command line async reader example

Change-Id: I4142d187c3ad37d1e7f5219df3d50679a9f35a8e
Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
4 years agoMerge remote-tracking branch 'origin/stable' into dev
Sergio Ahumada [Sun, 10 Nov 2013 15:05:19 +0000 (16:05 +0100)]
Merge remote-tracking branch 'origin/stable' into dev

Conflicts:
src/serialport/qserialportinfo_unix.cpp

Change-Id: Idfdfd662f9e336368b6155112405536a2ce5c965

4 years agoAdd /dev/ttyO* to get the native serial port listed on Android with Beagleboard
Laszlo Papp [Fri, 8 Nov 2013 15:20:47 +0000 (15:20 +0000)]
Add /dev/ttyO* to get the native serial port listed on Android with Beagleboard

This type of serial port seems to represent the OMAP serial ports.

Change-Id: Ie4279cad96f68e618d24bbcd64da9cbc218a9937
Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
4 years agoUnify the QString creation from udev return values (char*)
Laszlo Papp [Sat, 2 Nov 2013 16:29:54 +0000 (16:29 +0000)]
Unify the QString creation from udev return values (char*)

Change-Id: Ic69fd0d62d3097685bc8c3e25a7d8f6c696d7e2a
Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
4 years agoAdd a fallback lock file path (r/w) for Android
Laszlo Papp [Thu, 7 Nov 2013 18:07:29 +0000 (18:07 +0000)]
Add a fallback lock file path (r/w) for Android

Not sure this is the most suboptimal solution, but since the QLockFile usage is
not optional in QtSerialPort as of now, it allows us to get going for the
release with Android.

Change-Id: I4ee2658f76f14061d2f7e69e218a152a7235e524
Reviewed-by: BogDan Vatra <bogdan@kde.org>
4 years agoEliminate the crash on Unix caused by the QLockFile usage
Laszlo Papp [Thu, 7 Nov 2013 14:04:39 +0000 (14:04 +0000)]
Eliminate the crash on Unix caused by the QLockFile usage

We should not check against null because swap should always take place.
Initially, we do not construct a valid pointer guarded by the QScopedPointer
because not every constructor takes the portname argument, so it is possible to
create a QSerialPort instance without portname, and set it later.

Hence, removing the check makes sense, otherwise the smart pointer will guard a
null raw pointer which will cause crash all of a sudden when trying to be used.

Change-Id: Ib383f6eef2761ca5822585b848b0d29cce4eeb45
Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
Reviewed-by: Gatis Paeglis <gatis.paeglis@digia.com>
Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
4 years agoFix the build on Linux with Qt4
Denis Shienkov [Thu, 7 Nov 2013 11:59:53 +0000 (15:59 +0400)]
Fix the build on Linux with Qt4

Change-Id: I7bb118399182d316403ce9a2aa4b082b03158c1e
Reviewed-by: Laszlo Papp <lpapp@kde.org>
4 years agoDoc: Updating the Qt Serial Port URL.
Jerome Pasion [Tue, 5 Nov 2013 15:28:47 +0000 (16:28 +0100)]
Doc: Updating the Qt Serial Port URL.

When Qt 5.2 is released, it will be at
 http://qt-project.org/doc/qt-5.2/qtserialport-index.html

Change-Id: I2b81f8546e3df25c952eaa917954bc4a5100d6c9
Reviewed-by: Laszlo Papp <lpapp@kde.org>
4 years agoDoc: Updated url variable in qdocconf files.
Jerome Pasion [Tue, 5 Nov 2013 12:33:55 +0000 (13:33 +0100)]
Doc: Updated url variable in qdocconf files.

In 5.2, the HTML output is in a flatter structure and when they are
hosted in qt-project.org/doc, the documentation will be found at
http://qt-project.org/doc/qt-$QT_VER

The url variable is used by projects outside of Qt 5 which need
to link to Qt 5 documentation, such as Qt Creator.

Task-number: QTBUG-34584
Change-Id: Ice4793cdedb1d6287ce863221a831526fbb0f0a5
Reviewed-by: Laszlo Papp <lpapp@kde.org>
4 years agoDefine QStringLiteral when undefined (e.g. Qt 4)
Laszlo Papp [Wed, 6 Nov 2013 08:37:47 +0000 (08:37 +0000)]
Define QStringLiteral when undefined (e.g. Qt 4)

This will allow us Qt 5 style coding. QLatin1String replaced everywhere where it
works for Qt 4 and 5, namely: the direct literal passing.

Note that the "standard" typo has also been fixed in this commit as the line had
to change anyway, so it is not much of an additional noise.

Change-Id: I8b7e4fe5f337441000bd3d8f58db528fdd0e175b
Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
4 years agoUse the QLockFile source on Unix only to avoid errors on other platforms
Laszlo Papp [Wed, 6 Nov 2013 08:19:58 +0000 (08:19 +0000)]
Use the QLockFile source on Unix only to avoid errors on other platforms

Change-Id: I406ec1dc0a7e131db5ea93060e9a2adc47c50489
Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
4 years agoUse local QLatin1Char as opposed to a static QLatin1String
Laszlo Papp [Sat, 2 Nov 2013 15:50:39 +0000 (15:50 +0000)]
Use local QLatin1Char as opposed to a static QLatin1String

Change-Id: I3bf8a439bef4edc86943d19b3f0e8d2e0dcbe0c4
Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
4 years agoReplace the home-grown QTtyLocker with QLockFile
Laszlo Papp [Wed, 6 Nov 2013 07:04:22 +0000 (07:04 +0000)]
Replace the home-grown QTtyLocker with QLockFile

This can be more widely adopted later, and not just for the Linux backend. It
would be more than a few-liner change for stable, so this change change is kept
minimal (of course apart from the big file integration).

The only big problem with QLockFile currently is that we cannot change the file
name on the fly as it seems, just for construction. Even the copy constructor
and assignment operators are private. It means the class currently seems to be
non-eligible for QtSerialPort needs where it is necessary to change for open
anytime, and be accessible by open/serial for the before and after read/write
session for the same file name.

Also, I had to get rid of the QTemporary file internals because we cannot have
access to the internal engine with Qt 4. I also had to make a small thread class
for the protected msleep in QThread for Qt 4.

There was a small improvement for the hidden dependency problem with
gethostname. That was also sent to QtCore proper. Also, the windows backend for
the QLockFile class is not copied for simplicity. It would not be used as of
now.

There is also a short convenience around QLockFile established to handle
system-wide lock file paths. There is also some error handling added if the lock
directory paths are not readable or writable. This will end users identify the
problems like on Android.

Tested on Archlinux with Qt 4 and then 5.

Task-number: QTBUG-34474
Change-Id: I7adf29527c01ad331d3eeff5ae4c5a4113bde083
Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
4 years agoAdd a new simple and command line async writer example
Laszlo Papp [Sat, 26 Oct 2013 09:53:16 +0000 (10:53 +0100)]
Add a new simple and command line async writer example

Change-Id: I8f33126de5c78da9a4a0dbddd16eecde7044f0c5
Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
4 years agoAdd /dev/ttyHS(L)* to the hard coded uart list on Unix
Laszlo Papp [Fri, 1 Nov 2013 13:21:15 +0000 (13:21 +0000)]
Add /dev/ttyHS(L)* to the hard coded uart list on Unix

Some information can be found on the following link:

http://www.anyclub.org/2012/05/8960-android-gsbi-uart-debug-tips.html

Change-Id: Ie57d58f5a01c168ff9498694564e43e43c7919e3
Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
4 years agoMark most of the the data error policy as deprecated
Laszlo Papp [Fri, 1 Nov 2013 03:47:13 +0000 (03:47 +0000)]
Mark most of the the data error policy as deprecated

Unfortunately, this is a bit bad heritage of the QSerialDevice project. It is
not well-thought, and it was added in rush. If this feature ever comes back,
it has to be rethought and maybe redesigned. Currently, it is not much usable
nicely. It is done similarly to the following change:

https://codereview.qt-project.org/#patch,all,43441,7

Having done this, the users will get a warning, and they will hopefully stop
using it. Then, the feature redesign it for 5.3 or later. It can get
undeprecated anytime in Qt 5.X, but it cannot be removed with bumping the
library version. That should be the last resort.

In fact, this feature is very likely not to be redesigned. It is unfortunately a
broken concept. The following long-living serial port frameworks do not provide
"Policy" API either which is a clear sign for its usage pattern:

* PySerial
* Java SerialPort
* C#/.NET SerialPort
* QextSerialPort

... so to recap: it was not a good idea to introduce it.

Unfortunately, the side effect is that we have got warnings for the deprecated
method since moc cannot handle it properly. It needs to call it for internal
reasons.

Note that enum and Q_PROPERTY cannot be deprecated because Q_PROPERTY simply
cannot be, and the enum cannot be deprecated either since that would cause
further warnings for the library itself due its usage for the accessor and
mutator, etc. However, they can be put behind the QT_DEPRECATED_SINCE macro so
that the users can get compilation errors if they define
QT_DISABLE_DEPRECATED_BEFORE to get rid of old deprecated symbols easily by
getting errors instead of warnings.

The following coding can be run to show the expected warnings when used from a
QtSerialPort based application or library:

main.cpp:

int main()
{
    QSerialPort serialPort;
    serialPort.dataErrorPolicy();
    return 0;
}

==============================================================================

1) Qt 5

g++ -fPIC -Wall -DQT_DEPRECATED_WARNINGS -I/usr/include/qt -lQt5SerialPort main.cpp

main.cpp: In function ‘int main()’:
main.cpp:6:32: warning: ‘QSerialPort::DataErrorPolicy QSerialPort::dataErrorPolicy() const’ is deprecated (declared at /usr/include/qt/QtSerialPort/qserialport.h:222) [-Wdeprecated-declarations]
     serialPort.dataErrorPolicy();

Tested on Linux with Qt 4.8.5 and then Qt 5.1.1.

==============================================================================

2) Qt 4

g++ -fPIC -Wall -DQT_DEPRECATED_WARNINGS -I/usr/include/qt4/ -lQtSerialPort main.cpp

main.cpp: In function ‘int main()’:
main.cpp:6:32: warning: ‘QSerialPort::DataErrorPolicy QSerialPort::dataErrorPolicy() const’ is deprecated (declared at /usr/include/qt4/QtSerialPort/qserialport.h:222) [-Wdeprecated-declarations]
     serialPort.dataErrorPolicy();
                                     ^

==============================================================================

Task-number: QTBUG-34429
Change-Id: Ia183817b841fb172d232f550b8402f7a314b8492
Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
4 years agoAdd an initial changelog for 5.2.0
Laszlo Papp [Wed, 30 Oct 2013 20:36:01 +0000 (20:36 +0000)]
Add an initial changelog for 5.2.0

Change-Id: Ibe5b597a490c37b43434624bdf6d1d5be05a7ce4
Reviewed-by: Sergio Ahumada <sergio.ahumada@digia.com>
4 years agoDisable QNX build
Andreas Holzammer [Thu, 31 Oct 2013 13:11:43 +0000 (14:11 +0100)]
Disable QNX build

Nobody tested the serial port and it does not
compile as CRTSCTS is not defined. Lets disable
it until its fixed.

Change-Id: Ifc032194773b166a7fd9502f5d7f518019d80c7c
Reviewed-by: Laszlo Papp <lpapp@kde.org>
4 years agoRespect the configure script run for udev
Laszlo Papp [Tue, 29 Oct 2013 13:07:10 +0000 (13:07 +0000)]
Respect the configure script run for udev

Configure does not currently have an argument for udev, but still: it will try
to detect it and if it is available QT_CONFIG contains the "libudev" word.

We should respect that for Qt 5. Unfortunate, the configure script is not
checking this for Qt 4, so we still need to fall back to pkgconfig for Qt 4.

Change-Id: I9e755ee015f4f584e945cb176f1788b6dbac7374
Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@digia.com>
Reviewed-by: Kai Koehne <kai.koehne@digia.com>