qt:qtserialport.git
3 years agoMark the signal QSP::settingsRestoredOnCloseChanged() as deprecated qt4-dev
Denis Shienkov [Tue, 12 May 2015 12:45:22 +0000 (15:45 +0300)]
Mark the signal QSP::settingsRestoredOnCloseChanged() as deprecated

This was missed since Qt 5.3.

(cherry-picked from 9177a6c473afde7207c53f4d72f015a16dbeeb5f)
Change-Id: Ifb00421dec915682fd35587128aae6bd36bd9c9e
Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
3 years agoAdd the missed macro QT_DEPRECATED for QSP::sendBreak()
Denis Shienkov [Tue, 12 May 2015 12:41:37 +0000 (15:41 +0300)]
Add the missed macro QT_DEPRECATED for QSP::sendBreak()

(cherry-picked from da7a9e58a4b22ac7de087ed518139de5f06aebc5)
Change-Id: Iba0b5a63d225a469fd70125a90e306ef67f68cb9
Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
3 years agoMark the signal QSP::dataErrorPolicyChanged() as deprecated
Denis Shienkov [Tue, 12 May 2015 12:33:36 +0000 (15:33 +0300)]
Mark the signal QSP::dataErrorPolicyChanged() as deprecated

This was missed since Qt 5.2.

(cherry-picked from 05673348c71a967da09b4d26274a447d00ff16c4)
Task-number: QTBUG-46066
Change-Id: I105728382a682def9bbecbf1e33d28bfff00a6e9
Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
3 years agoRemove the QT_VERSION_CHECK(5, 0, 0) macro
Denis Shienkov [Mon, 20 Apr 2015 12:59:39 +0000 (15:59 +0300)]
Remove the QT_VERSION_CHECK(5, 0, 0) macro

... since current branch supports only Qt4.

Change-Id: Idf7de463bf28ff046f4d4356ef1b50009740a82a
Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
3 years agoCleanup an error string when QSP::clearError() is called
Denis Shienkov [Sat, 18 Apr 2015 15:06:14 +0000 (18:06 +0300)]
Cleanup an error string when QSP::clearError() is called

QSP::clearError() calls setError() with an empty error string.
But setError() anyway calls the qt_error_string() that sets an
error string from an system error which occurred before, that
is garbage in this case.

Thus, we need to call qt_error_string() only if the input
QSP::SerialPortError is not NoError.

(cherry-picked from 6ae78369d1156e653df6a2e539230a89cf963b00)
Change-Id: I949f30ca8bf260c8884e819524909fd6cd32ad5e
Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
3 years agoRemove unused readyReadEmitted variable
Denis Shienkov [Sat, 18 Apr 2015 12:00:02 +0000 (15:00 +0300)]
Remove unused readyReadEmitted variable

(cherry-picked from 9a9aed53e1e23200d471ced91a83fbca9976f231)
Change-Id: Ia1c15507ffa7135ffae0d8776c45746b454633cd
Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
3 years agoAdd additional lock directories for *nix-specific platforms
Denis Shienkov [Thu, 2 Apr 2015 18:17:14 +0000 (21:17 +0300)]
Add additional lock directories for *nix-specific platforms

(cherry-picked from 03629b992766fe30ad148ccdf732e0aa1ec0171e)
Change-Id: I03a32923f773a55304f47a58d4b709e880bf3a5e
Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
3 years agoDon't use QStringLiteral when QLatin1String is efficient.
Debao Zhang [Thu, 26 Mar 2015 07:41:50 +0000 (15:41 +0800)]
Don't use QStringLiteral when QLatin1String is efficient.

For QLatin1String, startsWith/endsWith/append/operator==/... are overloaded,
so use QLatin1String instead of QStringLiteral in such cases.

(cherry-picked from 7f857db22e0d409aac65e4773bb377796893b624)
Change-Id: I92b0a2597f935acb4310c8d717a46b537308ecd9
Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
3 years agoFix warning about constructing a QString from ASCII.
Friedemann Kleint [Tue, 3 Mar 2015 11:18:59 +0000 (12:18 +0100)]
Fix warning about constructing a QString from ASCII.

(cherry-picked from 801198fab9f6e29b1cd56a8820606f616e3d256e)
Change-Id: I814992c07273b9aa55d2eb0a02dffc46b60a9842
Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
3 years agoFix QSPI::portName() on OSX
Denis Shienkov [Fri, 13 Mar 2015 20:48:53 +0000 (00:48 +0400)]
Fix QSPI::portName() on OSX

The commit ab51ad6a5f4e533c31bd8e5b6f16a3bcd09a3ee6 changes a behavior
of conversion from a device location to a device name and vice-versa.
Now it is expected that the location as "/dev/cu.serial1" will be
converted to the "cu.serial1" name and vice-versa. But currently the
QSPI on OSX returns the name of device as "serial1" instead of
"cu.serial1", that lead to failure of QSP::open() method.

The reason is that a device name is queried from the dictionary with the
"kIOTTYDeviceKey" key, which always returns a right part of name from a
dot. Thus, we need to use QSPI::portNameFromSystemLocation() method
instead.

(cherry-picked from 3db7c8ac2484c5e5eb10150b87a9c4d81d20b51d)
Change-Id: Id7dfb2476c4a52a4c320c64588341fe6d0a5fa7d
Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
3 years agoMake QSP::timeoutValue() as static
Denis Shienkov [Wed, 11 Mar 2015 20:15:26 +0000 (23:15 +0300)]
Make QSP::timeoutValue() as static

(cherry-picked from e19945cdd347bf2aaef9f0552f6bea7a706030ad)
Change-Id: I9f11be6f1de66af70e84a00943d8cc75909e4956
Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
3 years agoGet rid of C-style's SERIALPORT_BUFFERSIZE macro
Denis Shienkov [Wed, 11 Mar 2015 20:12:40 +0000 (23:12 +0300)]
Get rid of C-style's SERIALPORT_BUFFERSIZE macro

It is reasonable make it as enum and part of QSP class.

(cherry-picked from ae7cd02d1c5b9d3f659a3a2430f47c8fa41672b7)
Change-Id: I13d4561568b2688f7d1a054073455c23a64c1b94
Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
3 years agoUnix: Clear serial_struct instances
Jonathan Liu [Mon, 9 Mar 2015 11:35:56 +0000 (22:35 +1100)]
Unix: Clear serial_struct instances

Silences the following Valgrind warning:
Conditional jump or move depends on uninitialised value(s)

(cherry-picked from 53afe73154c7c00b54cd280fa3d6c9127a2bc84b)
Change-Id: I8fd8cfd6aa6f75ed515e6151cfc282faca508bdc
Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
3 years agoUpdate the licenses and its headers
Denis Shienkov [Mon, 16 Feb 2015 19:44:56 +0000 (22:44 +0300)]
Update the licenses and its headers

As this branch is intended for support of Qt4, then expediently
to revert the license headers with the same content as in the
current Qt4. Besides, are removed the licenses as GPLv2(2.1, 3)
as they aren't present in sources of current Qt4.

Change-Id: I8bda62ef5f95f362053ad77f5b1666df27795254
Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
3 years agoUpdate copyright headers
Jani Heikkinen [Fri, 13 Feb 2015 05:49:31 +0000 (07:49 +0200)]
Update copyright headers

Qt copyrights are now in The Qt Company, so we could update the source
code headers accordingly. In the same go we should also fix the links to
point to qt.io.

Change-Id: I35f551de8408a2eb6a0f39df1f09d90c8084a7c0
Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
3 years agoFix a regresison in the waitForXXX() methods on Windows
Denis Shienkov [Sun, 25 Jan 2015 13:11:31 +0000 (16:11 +0300)]
Fix a regresison in the waitForXXX() methods on Windows

A regression was introduced by commit
893173f9d562f312ce51f00c07eef4ae0f1a0212: call to waitForXX() method
always fails.

The reason is in that earlier we always had a three valid handles of I/O
events, which are passed to the WaitForMultipleObjects() function. But
after that commit, we can have up 1 to 3 created handles, depends on the
I/O operation. In this case, we also passes a three handles to the
WaitForMultipleObjects() function, but some of them are non-initialized.
This lead to the WaitForMultipleObjects() always returns with the
ERROR_INVALID_HANDLE error code.

Thus, we need transfer to the WaitForMultipleObjects() only active
event handles.

Change-Id: Idc0d98e781506dd30011d4e50f53e06e2776ed52
Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
3 years agoFix crash in destructor if a device was not open on Windows
Denis Shienkov [Sun, 25 Jan 2015 12:38:01 +0000 (15:38 +0300)]
Fix crash in destructor if a device was not open on Windows

If a device is not open, then the hEvent field of the OVERLAPPED
structure is in non-initialized state. In this case the CloseHandle()
on the hEvent lead to crash. It is reasonable to initialize this
hEvent field in a constructor.

Change-Id: I1c9df21bdab4c95fc774f8d024de04e18948d81f
Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
3 years agoImprove usage of the break state for the Tx line
Denis Shienkov [Tue, 30 Dec 2014 10:38:05 +0000 (13:38 +0300)]
Improve usage of the break state for the Tx line

1. Now the sendBreak() method is deprecated since it is blocking and
impossible to implement same behavior on different platforms using
their API's. Besides, this method can be implemented via
setBreakEnabled() and QTimer.

2. Introduced the new property named as "breakEnabled" which consist
of setBreakEnabled() and isBreakEnabled() methods and the signal
breakEnabledChanged().

Note: After opening, the port always is in non-break state.

Task-number: QTBUG-36571
Change-Id: Ib808dab7eaed8cc5449c66d8186a29a7b7e45afc
Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
3 years agoDo not touch of the read notifier after its creation
Denis Shienkov [Sun, 4 Jan 2015 17:03:53 +0000 (17:03 +0000)]
Do not touch of the read notifier after its creation

When are used the multiple opening and closing chains, then a read
notification can be stalled. The reason is in old heritage of a code
related to preventing of recursive calls. Thus, need just to remove this
old code. It is not the in-depth investigation of an issue but just a
workaround which can be improved in future.

Tested on Linux with on-board and socat serial ports using Qt5.

Task-number: QTBUG-43484
Change-Id: I04556fdde2775448b33d68f141f4328647c549c9
Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
3 years agoUse Q_NULLPTR where it is possible
Denis Shienkov [Tue, 6 Jan 2015 18:26:33 +0000 (21:26 +0300)]
Use Q_NULLPTR where it is possible

Change-Id: I7261a92ea4405c8aeab7670f73e7225ed7e4d9d0
Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
3 years agoDo not use internal pre-cached RTS and DTR variables
Denis Shienkov [Fri, 5 Dec 2014 09:57:48 +0000 (12:57 +0300)]
Do not use internal pre-cached RTS and DTR variables

Some devices do not support these signals, and returns an errors when attempt
to query it. But the QSP::open() always requests a status of these lines.
In this case the QSP::open() will return true, but also will setup an error
code (for example, QSP::UnsupportedOperationError for socat's devices in
Linux). That is unexpected behavior for the user.

It is reasonable do not query a state of these signals when opening.
Also we do not need to use of appropriate internal variables, and we can
remove it.

Change-Id: I277110014c20c1f2c3fdaed20c4582d1356897b9
Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
3 years agoInterpret ENOTTY as UnsupportedOperationError instead of ResourceError
Denis Shienkov [Thu, 4 Dec 2014 19:57:11 +0000 (22:57 +0300)]
Interpret ENOTTY as UnsupportedOperationError instead of ResourceError

The ENOTTY is closer to QSP::UnsupportedOperationError, because it
is decoded as "Inappropriate ioctl for device".

Change-Id: Ibcbe09e201eeb5ede6daa417654a181dd380df5a
Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
3 years agoDetect of Bluetooth SPP (rfcomm) device with SysFs
Denis Shienkov [Thu, 4 Dec 2014 13:14:51 +0000 (16:14 +0300)]
Detect of Bluetooth SPP (rfcomm) device with SysFs

Change-Id: I41d67e9ca8d9cb6042b4d8de756a22d18b077dcd
Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
3 years agoSetup an error when QSP::setBaudRate() fails on Unix
Denis Shienkov [Thu, 4 Dec 2014 10:36:04 +0000 (13:36 +0300)]
Setup an error when QSP::setBaudRate() fails on Unix

Inside of a method is missed setup of an error code, therefore always
returns QSP::UnknownError (or some previous error).

Tested on Linux with USB PL2303, using Terminal example (when trying to
setup of an unsupported 14400 baud rate).

Change-Id: I6b3143dd6d451a32024a5ca5239dac826ceb7af6
Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
3 years agoMark a device as open only after all settings was aplied
Denis Shienkov [Thu, 4 Dec 2014 10:22:47 +0000 (13:22 +0300)]
Mark a device as open only after all settings was aplied

Otherwise it lead to emmiting of the QSP::NotOpenError in case we close
a device from a slot, which is connected to QSP::SerialPortError signal.
In this case QSP::close() called twice: from the slot, and from the
QSP::open() method (this behavior can be reproduced with Terminal
example).

So, inside of QSP::open() we need to move QIODevice::open() down, and
instead of QSP::close() to use QSPP::close().

Tested on Linux with USB PL2303 with trying to setup an unsupported
baud rate as 14400 baud.

Change-Id: I12dec085423dd9f5a08b7884f32dd2ba8aa8c951
Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
3 years agoDo not close closed device in Terminal example
Denis Shienkov [Thu, 4 Dec 2014 09:56:13 +0000 (12:56 +0300)]
Do not close closed device in Terminal example

When opening is fails, the QSP himself close a device. Thus, we do not
need to close device in Terminal example again, because it caused
emmiting of the QSP::NotOpenError and to showing of additional
messagebox.

Change-Id: Id8aa3f3b835fd7d4187bdf83c1d6584d5fd541f7
Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
3 years agoDetect a valid of serial8250 ports
Denis Shienkov [Sat, 29 Nov 2014 16:23:33 +0000 (16:23 +0000)]
Detect a valid of serial8250 ports

Usually, a Linux kernel reserves a places for the non-PnP serial
devices, for example, such as ttyS[0-4/14]. In case the system has not a
HW devices which are attached to this places, then these devices will be
stubs and present as usual serial ports. Thus, we can know about a
validity of these devices only in attempt to open them and to query a
type of.

Note: This patch is theoretical, because are not tested for a valid 8250
devices.

Task-number: QTBUG-32024
Change-Id: I313145caadfeeee4d5fe3c8e16c1bcf4ae79214d
Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
3 years agoImprove QSPI sysfs algorithm
Denis Shienkov [Sat, 29 Nov 2014 00:14:37 +0000 (00:14 +0000)]
Improve QSPI sysfs algorithm

Earlier, the algorithm used check for magic keywords (like "usb",
"platform" and so on) in the target path for decision-making what
of device can be skipped or accepted. But this is a wrong approach,
because on different platforms can be different key-words and we
can not know it. So, it is more reasonable to use a different
approach where we make decision by a driver name (by analogy with
current udev implementation). In this case we skip those devices
which has an empty driver name or when a name is equal to
"serial8250".

* When a driver name is empty, then we can be sure that it is
other than serial port device (e.g. as pseudo-terminal, console
and so on). Thus, it is similar to udev devices without a parent,
which we ignore.

* When a driver name is "serial8250", it is equal to "platform"
devices, which we too ignore for current implementation. Though in
a future this can be solved (i.e. we can try to detect a valid
devices based on "serial8250" driver).

Tested on Linux with on-board and USB serial ports using Qt5.

Change-Id: I884ad8f3fddff9487ad4a67c4904b57f62164e00
Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
3 years agoMake QSPI udev functions more readable
Denis Shienkov [Fri, 28 Nov 2014 21:48:56 +0000 (21:48 +0000)]
Make QSPI udev functions more readable

Change-Id: I5c33421338e6a64dbadeb168cf165a84bedec5b9
Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
3 years agoImprove QSPI algorithm on Unix
Denis Shienkov [Fri, 28 Nov 2014 21:25:36 +0000 (21:25 +0000)]
Improve QSPI algorithm on Unix

QSPI uses the wrong algorithm of devices search. In case no any devices
are detected with udev (or with sysfs), starts a search with a filters.
In this case a user gets a list of devices that are not a serial ports,
that is wrong.

The main idea should be in that udev or sysfs are the main sources of
obtaining information. In case they returns an empty list this means
that system has no serial ports.

Algorithm is:

Try to find devices through udev. If it fails (system error or udev is
not present), then try to find using sysfs; otherwise return udev result,
even if it has an empty list. If sysfs is fails (permission denied or
sysfs is not present), then try to find devices in /dev/ as last attempt;
otherwise return sysfs result, even if it has an empty list.

Tested on Linux (with udev, sysfs, filters) using FTDI serial ports.

Change-Id: I0132e27f720b007ea3f4861e9cd7ed77833cff8c
Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
3 years agoAdd scroll area to Enumerator example
Denis Shienkov [Mon, 1 Dec 2014 11:30:57 +0000 (14:30 +0300)]
Add scroll area to Enumerator example

When a system has many serial ports, the last of them are
not visible on the screen, because a widget has a big height.
So, it is reasonable to add scrolling of all serial ports info.

Change-Id: Ic13b58fba38a17d6f5142476bca501a0d26ec76d
Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
3 years agoTranslate serial port settings of Terminal example
Denis Shienkov [Mon, 1 Dec 2014 10:51:46 +0000 (13:51 +0300)]
Translate serial port settings of Terminal example

Change-Id: Ica127147999eaecc3d03189cfa9cd893115b846c
Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
3 years agoAllow to setup custom device in Terminal example
Denis Shienkov [Thu, 27 Nov 2014 13:18:42 +0000 (16:18 +0300)]
Allow to setup custom device in Terminal example

Terminal example allows to select only available devices which are
received from QSPI. Now it is possible to enter and to open of any
custom device.

Change-Id: I83172a346cb5dc0e20c217957133e9e3e506d8a4
Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
3 years agoAutotest misconfiguration error message is more verbose
Sergey Belyashov [Mon, 1 Dec 2014 08:38:28 +0000 (11:38 +0300)]
Autotest misconfiguration error message is more verbose

Error message about missing environment variables generates list of
required variables.

Change-Id: Icbb680abbd9fc5d0549907b7399757d943c6d535
Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
3 years agoSimplify and improve the QSP::TimeoutError handling
Denis Shienkov [Fri, 21 Nov 2014 21:14:12 +0000 (00:14 +0300)]
Simplify and improve the QSP::TimeoutError handling

It is reasonable to get rid of duplicating a code of TimeoutError
handling. A common parts of a code can be moved to one place.
Also, can be improved some of related if/else conditions.

Tested on Windows 8 and Linux with virtual serial ports.

Change-Id: I63112727faf42d4357f64f3450ea422167eaee90
Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
3 years agoHandle EINVAL, ENOIOCTLCMD, ENOTTY and EPERM errors
Denis Shienkov [Thu, 27 Nov 2014 22:21:22 +0000 (22:21 +0000)]
Handle EINVAL, ENOIOCTLCMD, ENOTTY and EPERM errors

According to TTY_IOCTL(4), the ioctl on tty device can return these
errors, which we need to interpret to QSP::SerialPortError.

For example, a virtual devices which are created by SOCAT, returns the
EINVAL error when the ioctl does query of line states.

Change-Id: Iece3b773fdc8fe4b97951ccf7cff9d2670f24694
Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
3 years agoImprove the QSP::clear() on Windows
Denis Shienkov [Fri, 10 Oct 2014 18:41:24 +0000 (22:41 +0400)]
Improve the QSP::clear() on Windows

Commit 9c88ad89801596e1d94acc4f32ff55c34118a66f solves a problem
partially. Still when used QSP::clear() with some devices (e.g.
virtual ports from the "AGG Software") the reading can be stalled.

It is reasonable to make following:

1. Prevent to reset the both readStarted and writeStarted variables
inside of QSP::clear() method. These variables shall be reset inside
of _q_completeXX() methods which will be called automatically from the
notifiers, since the PurgeComm should terminate pending read or write
operations.

2. Instead of startAsyncRead() should be called the
startAsyncCommunication(), that allow to correctly startup of the read
sequence.

This scenario can be reproduced with running of the
tst_QSerialPort::readAfterInputClear() autotest.

Tested on Windows 8 with the virtual com0com ports and with the
virtual ports from the "AGG Software" using Qt5.

Change-Id: Ic1a53334abd97667a9dd3291c3b975eb04062efd
Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
3 years agoPrevent multiple calls of WaitCommEvent
Denis Shienkov [Fri, 10 Oct 2014 17:51:12 +0000 (21:51 +0400)]
Prevent multiple calls of WaitCommEvent

Commit ac0422e8c9e74f2275129e3c7c69ef64299f07a9 introduced a regression
that QSP::startAsyncCommunication() was called twice when a limited read
buffer is used. In the second call the WaitCommEvent function returned the
ERROR_INVALID_PARAMETER error that lead to a stall of the read sequence.

QSP::startAsyncCommunication() should be called only when the read buffer
has enough space.

Tested on Windows 8 with the virtual com0com ports using Qt5.

Change-Id: Icd6cada7c3acfd4e689ac76ec304416b00f52b50
Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
3 years agoFix critical typo with _q_startAsyncWrite()
Denis Shienkov [Fri, 24 Oct 2014 13:36:01 +0000 (17:36 +0400)]
Fix critical typo with _q_startAsyncWrite()

Commit 62dfdeb3642250bdb642dbf607a8c7b95e57835e introduce a
critical typo that revert a bug which are fixed in the
b4d5bd813f591dc618e0fff2d55d93eeccb1a26e commit.

Change-Id: I9ed29f5b443cbd7102878287d531d18a9351a2e5
Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
3 years agoClose the handle for the events that were created
Andy Shaw [Thu, 27 Nov 2014 11:24:17 +0000 (12:24 +0100)]
Close the handle for the events that were created

The handles should be closed when QSerialPort is deleted in order to clean
up the native resources.

Change-Id: If04521fc0fa3b898093bda3317962b4c44818034
Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
3 years agoAllow to use custom devices paths
Denis Shienkov [Mon, 24 Nov 2014 15:21:57 +0000 (18:21 +0300)]
Allow to use custom devices paths

QSP incorrectly transforms non-standard device names to their paths
and vice-versa (for example, "/home/ttyS0", "//./COM1", and so on).

Now this problem is solved:

* The transformation code is moved to QSPP.

* Added autotests auto/qserialportinfoprivate to testing of
conversion algorithm. These tests are private and can be activated
with building of QtSerialPort with:

qmake "QT_CONFIG+=private_tests warnings_are_errors" \
DEFINES+=QT_BUILD_INTERNAL

Tested on Windows 8, Linux, OSX with auto-tests, with on-board
and virtual serial ports.

Task-number: QTBUG-38639
Change-Id: I43757a7f1390f53ed2b1d70de59c6bfb71892a59
Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
3 years agoRemove the 'register' keyword
Thiago Macieira [Sun, 23 Nov 2014 15:09:19 +0000 (07:09 -0800)]
Remove the 'register' keyword

It doesn't do anything and has been deprecated in C++14. Clang even
prints a warning.

Change-Id: Ie803a206f02897f99358ed22bf9cb999ca457741
Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
3 years agoRemove Q_OS_WIN64 since Q_OS_WIN32 defines 64-bit too
Denis Shienkov [Sun, 23 Nov 2014 20:06:16 +0000 (23:06 +0300)]
Remove Q_OS_WIN64 since Q_OS_WIN32 defines 64-bit too

Change-Id: I32eaf132f19a3b6fcbd5fd55d0690c3bd62bb641
Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
3 years agoSimplify handling of overlapped result
Denis Shienkov [Sat, 22 Nov 2014 20:22:41 +0000 (23:22 +0300)]
Simplify handling of overlapped result

There is not necessary to pass direction to handleOverlappedResult().
Because it is passed already as a second argument (pointer to
OVERLAPPED structure that defines a desired direction).

Also this method is renamed to more simple and short name.

Change-Id: I9c20cf97c1712aed8d3e9ea6d9b4687ce4487523
Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
3 years agoDeclare QElapsedTimer closer to usage
Denis Shienkov [Fri, 21 Nov 2014 20:36:57 +0000 (23:36 +0300)]
Declare QElapsedTimer closer to usage

Change-Id: I74622eaf3a7f5179ff25fc815997d5e4cf3cc2c7
Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
3 years agoCreate notifiers inside of startAsyncXX() methods when required
Denis Shienkov [Sat, 22 Nov 2014 13:35:58 +0000 (16:35 +0300)]
Create notifiers inside of startAsyncXX() methods when required

It is reasonable to move creation of notifiers from the constructor
to the specific separate methods. In this case notifiers are created
in startAsyncXXX() methods if necessary for concrete I/O operation.
Also it allows to return an error in case a notifier is failed.

Tested on Windows 8 with virtual com0com serial ports.

Change-Id: I351a4c54214c84455150d0fc157a99108280cc12
Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
3 years agoFix QSPI::isNull()
Denis Shienkov [Fri, 21 Nov 2014 13:01:30 +0000 (16:01 +0300)]
Fix QSPI::isNull()

The method QSPI::isNull() should return false when QSPI is empty.

Tested on Winsows 8 and Linux with on-board, virtual and USB serial
ports using Qt5 and then Qt4.

Task-number: QTBUG-41262
Change-Id: Ic9e0afc5549311283aef7ec2ed841f5e418b7edf
Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
3 years agoCheck for lock file in non-writable directories
Rainer Keller [Thu, 23 Oct 2014 07:15:07 +0000 (09:15 +0200)]
Check for lock file in non-writable directories

On some linux systems /var/lock is not writable by users which are not
root and not in the uucp or dialout group.
If the root user acquires a lock and you are trying to access the same
port with a non-root user it will not check for the lock but creates a
new lock file in /tmp instead.
This change checks in readable directories for lock files.

Change-Id: Ia308fd344d2fe9d3c699f7a428ff620ea101eff3
Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
3 years agoCleanup from the Qt5 dependences
Denis Shienkov [Tue, 7 Oct 2014 23:15:09 +0000 (23:15 +0000)]
Cleanup from the Qt5 dependences

Now in this branch there is QtSerialPort which has support only for Qt4.

Change-Id: I11d5403dcc17f8c2929429abb6df9f2b2b4fb558
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
3 years agoMerge remote-tracking branch 'origin/5.3' into 5.4
Frederik Gladhorn [Tue, 14 Oct 2014 12:07:32 +0000 (14:07 +0200)]
Merge remote-tracking branch 'origin/5.3' into 5.4

Change-Id: Id7e66059233e8d07ba44cad19048d9cddc68e250

3 years agoDoc: Applied title case in section1 titles v5.4.0-beta1
Nico Vertriest [Wed, 8 Oct 2014 11:31:05 +0000 (13:31 +0200)]
Doc: Applied title case in section1 titles

Change-Id: I8d68786028fe6e561e9c1d8b6960d43020c60e50
Task-number: QTBUG-41250
Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
3 years agoFix QSP::bytesToWrite() on Windows
Denis Shienkov [Sat, 19 Jul 2014 15:25:19 +0000 (19:25 +0400)]
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>
3 years agoAllow for deviceInstanceIdentifier() to return an upper case string
Denis Shienkov [Tue, 30 Sep 2014 19:00:03 +0000 (23:00 +0400)]
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>
3 years agoRestart of async reading when a QSP::clear() is called
Denis Shienkov [Fri, 3 Oct 2014 09:21:17 +0000 (13:21 +0400)]
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>
3 years agoFix reading on Windows at limited read buffer size
Denis Shienkov [Mon, 29 Sep 2014 14:44:36 +0000 (18:44 +0400)]
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>
3 years agoRemove custom baud rate filtering
Manuele Conti [Wed, 1 Oct 2014 11:13:11 +0000 (13:13 +0200)]
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>
3 years agoFix segfault related to dynamic udev loading
Sergey Belyashov [Fri, 26 Sep 2014 12:00:39 +0000 (16:00 +0400)]
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>
3 years agoHandle onboard serial ports when parsing sysfs
Rainer Keller [Fri, 26 Sep 2014 12:42:20 +0000 (14:42 +0200)]
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>
3 years agoFix typo in twoStageSynchronousLoopback test
Denis Shienkov [Sat, 27 Sep 2014 20:00:22 +0000 (00:00 +0400)]
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>
3 years agoFix order of passed parameters into QCOMPARE
Denis Shienkov [Sat, 27 Sep 2014 19:22:04 +0000 (23:22 +0400)]
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>
3 years agoFix access after delete in OS X QSPI
Dyami Caliri [Wed, 24 Sep 2014 22:07:01 +0000 (15:07 -0700)]
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>
3 years agoQuery a serial number of USB device from Sysfs
Denis Shienkov [Thu, 25 Sep 2014 09:22:26 +0000 (13:22 +0400)]
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>
3 years agoMerge remote-tracking branch 'origin/5.3' into 5.4
Frederik Gladhorn [Tue, 16 Sep 2014 13:29:27 +0000 (15:29 +0200)]
Merge remote-tracking branch 'origin/5.3' into 5.4

Conflicts:
.qmake.conf

Change-Id: I5887622f233275703cca8cc2a5db4aaaccc72d97

3 years agoMake tst_qtserialport build with Qt 4
Samuel Gaist [Thu, 11 Sep 2014 19:52:52 +0000 (21:52 +0200)]
Make tst_qtserialport build with Qt 4

The newly moved twoStageSynchronousLoopback fails to compile since
there's no qCompare available for int and long long with Qt 4. This
patch allows to build it again with Qt 4

Change-Id: Ib3764b125f371ae70864bd578c7ccda39d08ae22
Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
3 years agoAdded missing deprecation guards and documentation update
Samuel Gaist [Thu, 11 Sep 2014 23:00:17 +0000 (01:00 +0200)]
Added missing deprecation guards and documentation update

This patch adds the missing guards around the deprecated functions
implementations.

Change-Id: I829e90e289da7af736fc6f5d6c319509138f1aef
Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
3 years agoFix Qt 4 build
Samuel Gaist [Thu, 11 Sep 2014 23:03:08 +0000 (01:03 +0200)]
Fix Qt 4 build

Following the discussion on the development mailing list with
Thiago Macieira, remove the guard around the signals since
it's not supported to build with Qt 4.

Task-number: QTBUG-41190
Change-Id: I8df1b7fa8cc69a2aacdcb4fedea0cc6fe092eece
Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
3 years agoUpdate license headers and add new license files
Antti Kokko [Fri, 22 Aug 2014 06:02:37 +0000 (09:02 +0300)]
Update license headers and add new license files

- Renamed LICENSE.LGPL to LICENSE.LGPLv21
- Added LICENSE.LGPLv3 & LICENSE.GPLv2
- Removed LICENSE.GPL

Change-Id: I08685205169cdd4b49a651ed98f36ba1e6c1bb29
Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
3 years agoBump version
Frederik Gladhorn [Fri, 29 Aug 2014 09:33:42 +0000 (11:33 +0200)]
Bump version

Change-Id: Ida6ecfd792ea1906c70bf17bb5b8077ad4c5e631

3 years agoFix a race condition at writing on Windows 5.3.2 v5.3.2
Denis Shienkov [Thu, 14 Aug 2014 17:50:05 +0000 (21:50 +0400)]
Fix a race condition at writing on Windows

1. The writeStarted flag shall be reset to false after bytesWritten() signal
is emitted, but not before it.

2. In case of start of writing from the startAsyncWriteTimer it is necessary
to call the startAsyncWrite() method but not the completeAsyncWrite() method.

It give guarantees to exclude of race condition to multiple call of the
WriteFile twice until the write operation is not completed.

For example, a race condition is watched in case of writing data from the
slots which are connected to the bytesWritten() signal from a device; or to
the timeout() signal from a timer with zero interval. To checking of these
scenarios are added additional autotests.

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

Task-number: QTBUG-40769
Change-Id: Iedabbf38847debeee795a10fd7a4c54c65d2a338
Reviewed-by: Patrick Noffke <patrick.noffke@gmail.com>
Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
3 years agoMerge remote-tracking branch 'origin/5.3' into 5.4 v5.4.0-alpha1
Frederik Gladhorn [Thu, 28 Aug 2014 14:18:59 +0000 (16:18 +0200)]
Merge remote-tracking branch 'origin/5.3' into 5.4

Change-Id: Id742521c303261262a87db4189d369851ed2078b

3 years agoAdd missing private headers warnings
Samuel Gaist [Sat, 16 Aug 2014 21:24:32 +0000 (23:24 +0200)]
Add missing private headers warnings

Change-Id: Ia60bf0d020d98a6fda8f689d631bb8681950d15f
Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
3 years agoFix handling of writing at using of waitForReadyRead()
Denis Shienkov [Thu, 14 Aug 2014 18:35:03 +0000 (22:35 +0400)]
Fix handling of writing at using of waitForReadyRead()

The method waitForReadyRead() shall call of the write sequence since the
signals from the startAsyncWriteTimer will not be handled inside of
waitForReadyRead() without event-loop.

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

Task-number: QTBUG-40793
Change-Id: I7806f16a4df30c4ec1643d8f696ad5761decd30a
Reviewed-by: Patrick Noffke <patrick.noffke@gmail.com>
Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
3 years agoMerge remote-tracking branch 'origin/5.3' into 5.4
Frederik Gladhorn [Tue, 12 Aug 2014 11:09:58 +0000 (13:09 +0200)]
Merge remote-tracking branch 'origin/5.3' into 5.4

Conflicts:
examples/serialport/examples.qdoc

Change-Id: If79f2f140e72f0a499f8e61e3897848f454a5042

3 years agoFix compilation of apps with QT_DISABLE_DEPRECATED_BEFORE=0x050300
Marcel Krems [Mon, 11 Aug 2014 14:51:12 +0000 (16:51 +0200)]
Fix compilation of apps with QT_DISABLE_DEPRECATED_BEFORE=0x050300

The enum is already marked as deprecated leading to this error:
qserialport.h:267:46: error: no type named 'DataErrorPolicy' in 'QSerialPort'
    void dataErrorPolicyChanged(QSerialPort::DataErrorPolicy policy);
                                ~~~~~~~~~~~~~^

Change-Id: I8d178f0d0921b8f5308183e1f09a4c8388448e26
Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
3 years agoMove the synchronous loopback test from benchmarks to auto tests
Denis Shienkov [Sat, 26 Jul 2014 13:55:43 +0000 (17:55 +0400)]
Move the synchronous loopback test from benchmarks to auto tests

Previous commit 76f293bfb0fd7bab391f96ac822eacc40e4c5176 with adding of
this test to the benchmarks were hasty.

After all it makes sense to place it to auto tests to have opportunity to
run with others together.

Besides, this test is renamed since it is not a loopback, it is an I/O
test with the synchronous approach.

Change-Id: I043a6e0075561167bb29a59a384554ef98dbbd4a
Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
3 years agoMake the QSerialPort::flush() non-blocking
Denis Shienkov [Sat, 19 Jul 2014 15:53:16 +0000 (19:53 +0400)]
Make the QSerialPort::flush() non-blocking

According to documentation, the flush() method shall be non-blocking.

Tested on Linux 64-bit with auto-tests with the on-board and the USB
serial ports for Qt4 and then Qt5.

Note: On Windows the flush() method still does not work.

Change-Id: Iaee80361e59e0c281206ca24c817a446cdbf6ed1
Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
3 years agoPass a length of string to QString::fromWCharArray
Denis Shienkov [Thu, 10 Jul 2014 12:46:28 +0000 (16:46 +0400)]
Pass a length of string to QString::fromWCharArray

Using of the QString::fromWCharArray() we didn't pass length of a string,
hoping that all WCHAR strings are terminated by the null-character.

But it can lead to the wrong results if the initial WCHAR string has no
null character. Therefore it is reasonable to pass length of a string to
exclude an error.

Besides, to do not break of the algorithm of string comparison it is
necessary to return not null-terminated strings. Also now there is no need
to initialize of some allocated arrays by zero values.

Tested on Windows 7/8 with the on-board, the virtual com0com, the USB FTDI
and the PL2303 serial ports, using Qt4 and then Qt5.

Change-Id: I382cf8eacf4ab4d21c54de17fcdd6b9fcfa3d02c
Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>
Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
3 years agoFix leak of a descriptor after unsuccessful opening
Denis Shienkov [Fri, 25 Jul 2014 08:14:54 +0000 (12:14 +0400)]
Fix leak of a descriptor after unsuccessful opening

In case of unsuccessful initialization of a device at the opening, a
valid descriptor has to be closed before return from the open() method.

Task-number: QTBUG-40414
Change-Id: I45568f176e003d9be1fe8c3017da29f39908efb0
Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
3 years agoFix events handling in waitForBytesWritten() method on Windows
Denis Shienkov [Fri, 25 Jul 2014 21:31:28 +0000 (01:31 +0400)]
Fix events handling in waitForBytesWritten() method on Windows

In case of communication event is triggered in the
waitForBytesWritten() method then necessary to process it with
the _q_completeAsyncCommunication() method, but not with the
_q_completeAsyncRead() method.

Otherwise it leads to false filling of the readBuffer with the
data that were read earlier (or with garbage) which remained in
readChunkBuffer.

The synchronous loopback autotest reproduces a bug without of
this patch.

Tested on Windows 7/8 with the on-board and USB serial ports,
using Qt5.

Task-number: QTBUG-40344
Change-Id: I679109b60f4058c4c6f7e5f02c1f70ba6039d8d8
Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
3 years agoUpdate QRingBuffer by recent version from qtbase
Alex Trotsenko [Sat, 26 Jul 2014 12:19:33 +0000 (15:19 +0300)]
Update QRingBuffer by recent version from qtbase

Fix some issues. Optimized for size and speed.

Change-Id: Ie7b55e3f01fb088999d3a5b10d0d941934fda162
Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
3 years agoAdd the synchronous loopback data verification test
Denis Shienkov [Fri, 11 Jul 2014 12:32:28 +0000 (16:32 +0400)]
Add the synchronous loopback data verification test

Good reason to check of data correctness at transferring and receiving.
In this test are used two serial ports, connected in a null-modem mode:
http://en.wikipedia.org/wiki/Null_modem .

The sender port transfers data to the receiver port. After data are
received is carried out check of equivalence of the transferred and
received data.

Before run of testing it is necessary to set two variable environments
QTEST_SERIALPORT_SENDER and QTEST_SERIALPORT_RECEIVER to specify names
of used serial ports.

This test can reveal errors related with the internal data processing
and also errors of synchronous I/O inside of QSerialPort.

This test is placed in separate "benchmarks" category not to mix-up
with "manual" and "auto" categories, because this test is closer to
"benchmarks" by own functionality.

Tested on Windows 7/8 with the virtual com0com serial ports, using
Qt4 and then Qt5.

Change-Id: Ie6f87b50784bce211cf68c16cf75f79d12a8564f
Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>
3 years agoDoc: rename the end file for serialport docs
Thiago Macieira [Thu, 24 Jul 2014 17:59:36 +0000 (10:59 -0700)]
Doc: rename the end file for serialport docs

This page has been showing up in the master Qt docs as
http://qt-project.org/doc/qt-5/examples.html, which is way too
generic. The current practice is to add the module:

    \page qt3d-examples.html
    \page qt3d-examples-placeholder.html
    \page examples-graphicsview.html
    \page examples-graphicsview.html
    \page bluetooth-examples.html
\page nfc-examples.html
\page qtquick-codesamples.html
    \page qtexamplesandtutorials.html
    \page examples-layouts.html
    \page examples-draganddrop.html
    \page examples-threadandconcurrent.html
    \page examples-sql.html
    \page examples-xml.html
    \page examples-statemachine.html
    \page examples-animation.html
    \page examples-gestures.html
    \page examples-activeqt.html
  \page qdeclarativeexamples.html
    \page declarative-cppextensions-reference.html
    \page declarative-cppextensions-qgraphicslayouts.html
    \page examples-serialport.html
    \page qtwebkitexamples-index.html

Change-Id: Ib272f6380cb694ad4acfc24a248266805cef05a8
Reviewed-by: Martin Smith <martin.smith@digia.com>
3 years agoDoc: Edited example documentation.
Jerome Pasion [Thu, 10 Jul 2014 13:15:23 +0000 (15:15 +0200)]
Doc: Edited example documentation.

-added information about how to run the example by including a file
 from qtbase/doc/global
-edited summary sections
-added \brief.
-removed image captions. Our Qt 5 CSS files don't handle them.

Task-number: QTBUG-33597
Change-Id: If3293aa9d98b662f20af2af7030b0ab0fb1e8401
Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@digia.com>
3 years agoReturn from the loop if a port name is found
Denis Shienkov [Thu, 10 Jul 2014 07:40:18 +0000 (11:40 +0400)]
Return from the loop if a port name is found

The function devicePortName() search in the Registry the names of ports
by names of registry keys. At first looks for value of a key of "PortName",
and then of "PortNumber" key.

Thus, the first found value shall stop search and do not try to continue.

Tested on Windows 7/8 using Qt4 and then Qt5.

Change-Id: I98b00ff043a3b08476fec0a57b0d36ce65fc8d63
Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
3 years agoMerge remote-tracking branch 'origin/5.3' into dev
Frederik Gladhorn [Thu, 10 Jul 2014 08:16:01 +0000 (10:16 +0200)]
Merge remote-tracking branch 'origin/5.3' into dev

Change-Id: I64b13e135d58980ea4cf7429224aa1877778cb46

3 years agoWrap of getting the port properties on Windows
Denis Shienkov [Wed, 2 Jul 2014 12:52:09 +0000 (16:52 +0400)]
Wrap of getting the port properties on Windows

It is reasonable to wrap implementation of getting properties of port
from availablePorts() to the separate functions. It is simplifies a
code and improves its understanding.

Tested on Windows 7/8 with the on-board, virtual com0com, USB FTDI
serial ports using Qt4 and then Qt5.

Change-Id: I2345fa49b3633960412715b299e068daa8fdcfd0
Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
3 years agoDo not continue waitForReadyRead() if an error occurred
Denis Shienkov [Wed, 2 Jul 2014 23:23:17 +0000 (23:23 +0000)]
Do not continue waitForReadyRead() if an error occurred

This patch improves workaround implemented in the previous commit
d34fce4a5d12789ded107631e22cb6ef54d35eee

Change-Id: I013b19b47ee343ab00f242d7ee1021b92c07d18f
Reviewed-by: Peter Kümmel <syntheticpp@gmx.net>
Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
3 years agoRefactor of the QSerialPortInfo for OS X
Denis Shienkov [Wed, 2 Jul 2014 08:28:11 +0000 (12:28 +0400)]
Refactor of the QSerialPortInfo for OS X

The current implementation of the qserialportinfo_mac.cpp module is a
little confused and complicated.

It is reasonable to re-write it using some ready wrappers of CFTypeRef,
CFStringRef and others objects from the private qcore_mac_p.h file.

Thus, it will allow to bypass of manual releasing of the allocated
resources (using the RAII idiom where it is possible), and also to
simplify a code.

Tested on OS X 10.8.4 with the on-board, USB PL2303, USB FTDI,
USB Android serial ports and with the USB ZTE Modem using Qt4.

Change-Id: Ibbac03a17fdd41bbaf530f863e7c690a15708bd2
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
3 years agoMake independent implementation of QSerialPortInfo for OS X
Denis Shienkov [Tue, 1 Jul 2014 14:57:59 +0000 (18:57 +0400)]
Make independent implementation of QSerialPortInfo for OS X

Building in OS X uses some shared code from the serialportinfo_unix.cpp
module with the OS X specific code from the serialportinfo_mac.cpp module.

Thus, all code of the serialportinfo_unix.cpp module, which not related
with the OS X, is shielded by a macro. It adds an excessive garbage for
readability in this module and also some confusion in the *.pri file.

It makes sense to make implementation of the serialportinfo_mac.cpp
module completely independent, that will simplify maintaining of source
code.

Besides are added tests which can reveal declared but not implemented
methods in building, and also to check a correctness of default values
at running.

Tested build on OS X 10.8.4 with Qt4, an then on Android with Qt5.

Change-Id: I67935b64e2b623fb8d4c14d59e1b87f1eac71c3e
Reviewed-by: Bernard Pratz <guyzmo+qt@m0g.net>
Reviewed-by: Peter Kümmel <syntheticpp@gmx.net>
Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
3 years agoCorrect WinRT exclusion to top-level pro file
Maurice Kalinowski [Mon, 7 Jul 2014 09:58:34 +0000 (11:58 +0200)]
Correct WinRT exclusion to top-level pro file

So far only the module was excluded, but not the examples.
Adopt to a style which has been approved for other modules as well
by using requires.

Change-Id: I8a8bbeb8c5db1bdb2e508da0988a38bbb1789986
Reviewed-by: Oliver Wolff <oliver.wolff@digia.com>
Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@digia.com>
3 years agoImprove error handling for the waitForXX() methods on Windows
Denis Shienkov [Mon, 30 Jun 2014 14:38:04 +0000 (18:38 +0400)]
Improve error handling for the waitForXX() methods on Windows

The slots _q_completeXX() returns empty values, therefore the
waitForXX() methods continue to work even if occurs an error
from the I/O completion.

Is reasonable allow to return of boolean values for the I/O
completion slots.

Besides, it allows avoiding indirect detection of an error,
comparing of the sizes of I/O buffers before and after the
operation completion. Though, for the waitForReadyRead(),
for this purpose it is necessary to add additional
modifications in a following patches.

Tested on Windows 7/8 with the virtual com0com ports using
Qt4 and then Qt5. Testing was made using of autotests
and examples.

Change-Id: I95a76461af4595f6658f0cad766a4fff14eb7afc
Reviewed-by: Peter Kümmel <syntheticpp@gmx.net>
Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
3 years agoUnify handling of errors of the overlapped I/O result
Denis Shienkov [Mon, 30 Jun 2014 09:35:50 +0000 (13:35 +0400)]
Unify handling of errors of the overlapped I/O result

Each q_completeXXX() slot does call of GetOverlappedResult()
and differently interprets an error depending on the type of
I/O operation (read, write or communication).

It is more reasonable to make it in the separate method
handleOverlappedResult() which returns the number of the
transferred bytes or -1 in case of error.

Besides, this method accepts the additional integer parameter
which expresses type of overlapped operation using the
existing QSerialPort::Direction enumeration. The type of the
communication operation has not separate value, so is used
zero value for it.

Tested build on Windows 7/8 using Qt4 and then Qt5.

Change-Id: I8482392d06279bc430656e50b1e4392c513885c6
Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
Reviewed-by: Peter Kümmel <syntheticpp@gmx.net>
Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
3 years agoDoc: Removing url variable from qdocconf file.
Jerome Pasion [Fri, 4 Jul 2014 12:48:49 +0000 (14:48 +0200)]
Doc: Removing url variable from qdocconf file.

-url inherited from the url variable set in qtbase/doc/global

Change-Id: I16bde5a3c34540c448a10903e4efde69a9d3585c
Reviewed-by: Martin Smith <martin.smith@digia.com>
3 years agoAbort waitForReadyRead() when there is an error
Peter Kümmel [Mon, 16 Jun 2014 18:59:22 +0000 (20:59 +0200)]
Abort waitForReadyRead() when there is an error

When in readNotification() or completeAsyncWrite() an error
is emitted and the loop is not exited, this error signal
will flood the eventloop.

Change-Id: I77b8a4c337041258862b19a07917bef059c11cc1
Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
3 years agoImprove the serial number handling on Windows
Denis Shienkov [Tue, 10 Jun 2014 13:49:02 +0000 (17:49 +0400)]
Improve the serial number handling on Windows

The standard USB CDC driver (usbser.sys) does not add information of
serial number to the device instance identifier of the child devices
(serial ports), so our algorithm returns an empty string.

But information about a serial number is stored in the device identifier
of the parental node. Thus, it is necessary to get this parent
identifier, using these recommendations from MSDN:

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

For this purpose is used the set of new functions from the
"Configuration Manager Functions" family.

Therefore it was necessary:

* Rewrite the deviceInstanceIdentifier() function.

Now this function accepts one DEVINST parameter and returns the
corresponding device instance identifier string.

* Add the new parentDeviceInstanceNumber() function.

This function accepts a DEVINST of the child device and returns a
DEVINST of the parent device.

Thus, the new algorithm tries to extract a serial number from the
current (child) device and in case it is empty, try to extract from
the parent.

Tested on Windows 7/8 with the Segger JLink device (provides the CDC
serial port) using Qt4 (MSVC2010) and then Qt5 (MSVC2012, MinGW).

Also are checked other devices for possible regressions:

* on-board serial port
* com0com virtual serial port
* USB FTDI serial port

no regressions found.

Change-Id: Ic6afc258f45aa374ec77dc0b586d479b5286359f
Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
3 years agoImprove the ResourceError handling on Windows
Denis Shienkov [Sat, 7 Jun 2014 11:18:15 +0000 (15:18 +0400)]
Improve the ResourceError handling on Windows

To the ResourceError handling we generally relied on triggering of the
_q_completeAsyncCommunication(), in case of ejection of an USB device
from a host. But it worked with not all USB devices (for example it did
not work with the ZTE modems). Even when this worked (for example with
the PL2303 devices), then we got the non informative "Unknown error" of
the ResourceError string representation.

It is more reasonable not to do any custom checks of an event mask when
triggered of the _q_completeAsyncCommunication() method. We need allow
to detect an errors with means of the
ReadFile/GetOverlappedResult/WaitCommEvent syscalls on an invalid device
handle.

An important note is that returns the different error codes for a
different types of devices.

For example:

* For the USB ZTE and the Samsung Android USB modem returns the
ERROR_ACCESS_DENIED error code.

* For the FTDI and the Samsung Android Diagnostic Serial Port returns
the ERROR_OPERATION_ABORTED error code.

* For the USB PL2303 device returns the ERROR_BAD_COMMAND error code.

Thus, there is no universal solution of this issue. Each vendor of the
driver implements it own way. Therefore for each new type of the device
it is necessary to add processing its error code, if we have no it yet.

Tested on Windows 7/8 with the USB ZTE and the Android modems, with the
USB PL2303 and the FTDI devices and with the Android diagnostic serial
port using Qt4 and then Qt5, no regressions found.

Task-number: QTBUG-32020
Change-Id: I61c02078ee98221ecef18a27cde3d9bae3674d70
Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
3 years agoImprove the I/O completion errors handling on Windows
Denis Shienkov [Sat, 7 Jun 2014 10:04:12 +0000 (14:04 +0400)]
Improve the I/O completion errors handling on Windows

* It is necessary to ignore the NoError error code.

* In case of error from GetOverlappedResult() it is necessary to stop
the I/O operation by a immediate return from the function, because I/O
processing does not make sense. This is consistent behavior similar to
starting I/O operations.

* All errors from the read completion should be interpreted as ReadError.
Exception is only the critical ResourceError error which it is necessary
to leave without changes. This is also consistent behavior similar to
starting I/O operations.

* The write completion error handling should be similar to the read
completion handling.

* For the communication completion we have no specific error codes.
Therefore error handling shall be without modification of their error
code.

Also were made small cosmetic fixes to the related start I/O methods.

Tested on Windows 7/8 with the on-board, the PL2303 and the virtual
com0com serial ports using Qt4 and then Qt5. Testing are made by means
of examples of library and also by means of auto tests, no regressions
found.

Change-Id: I0d08b53627431c42ab5147d4330f1aaf819b4d63
Reviewed-by: Peter Kümmel <syntheticpp@gmx.net>
Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
3 years agoMerge remote-tracking branch 'origin/5.3' into dev
Frederik Gladhorn [Thu, 26 Jun 2014 15:27:19 +0000 (17:27 +0200)]
Merge remote-tracking branch 'origin/5.3' into dev

Conflicts:
.qmake.conf

Change-Id: Ib1727ebdc69ab673d782c39ba9f1b5f51c192d4b

4 years agoBump version
Oswald Buddenhagen [Tue, 17 Jun 2014 22:36:41 +0000 (00:36 +0200)]
Bump version

Change-Id: I50ea328c903f3ba0c78f9570b6b6b892bb38f976

4 years agoFix mixed up vendor and product identifiers v5.3.1
Oleg Shparber [Fri, 13 Jun 2014 21:53:47 +0000 (14:53 -0700)]
Fix mixed up vendor and product identifiers

Caused by I1a66164c.

Change-Id: I78973a509ff91a1302f435b1a23ecce432e56dd4
Reviewed-by: Laszlo Papp <lpapp@kde.org>
Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>