summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.cmake.conf3
-rw-r--r--.gitignore6
-rw-r--r--.qmake.conf5
-rw-r--r--CMakeLists.txt40
-rw-r--r--LICENSE.GPL3-EXCEPT704
-rw-r--r--LICENSES/BSD-3-Clause.txt9
-rw-r--r--LICENSES/GFDL-1.3-no-invariants-only.txt (renamed from LICENSE.FDL)23
-rw-r--r--LICENSES/GPL-2.0-only.txt (renamed from LICENSE.GPL2)0
-rw-r--r--LICENSES/GPL-3.0-only.txt (renamed from LICENSE.GPL3)0
-rw-r--r--LICENSES/LGPL-3.0-only.txt (renamed from LICENSE.LGPL3)0
-rw-r--r--LICENSES/LicenseRef-Qt-Commercial.txt8
-rw-r--r--LICENSES/Qt-GPL-exception-1.0.txt22
-rw-r--r--coin/axivion/ci_config_linux.json59
-rw-r--r--coin/module_config.yaml12
-rw-r--r--conanfile.py31
-rw-r--r--configure.cmake24
-rw-r--r--configure.json5
-rw-r--r--dependencies.yaml2
-rw-r--r--dist/changes-5.12.1028
-rw-r--r--dist/changes-5.15.120
-rw-r--r--examples/CMakeLists.txt10
-rw-r--r--examples/serialport/CMakeLists.txt8
-rw-r--r--examples/serialport/blockingmaster/dialog.h99
-rw-r--r--examples/serialport/blockingmaster/main.cpp61
-rw-r--r--examples/serialport/blockingmaster/masterthread.h86
-rw-r--r--examples/serialport/blockingreceiver/CMakeLists.txt39
-rw-r--r--examples/serialport/blockingreceiver/blockingreceiver.pro (renamed from examples/serialport/blockingslave/blockingslave.pro)8
-rw-r--r--examples/serialport/blockingreceiver/dialog.cpp94
-rw-r--r--examples/serialport/blockingreceiver/dialog.h50
-rw-r--r--examples/serialport/blockingreceiver/main.cpp14
-rw-r--r--examples/serialport/blockingreceiver/receiverthread.cpp107
-rw-r--r--examples/serialport/blockingreceiver/receiverthread.h38
-rw-r--r--examples/serialport/blockingsender/CMakeLists.txt39
-rw-r--r--examples/serialport/blockingsender/blockingsender.pro (renamed from examples/serialport/blockingmaster/blockingmaster.pro)8
-rw-r--r--examples/serialport/blockingsender/dialog.cpp (renamed from examples/serialport/blockingmaster/dialog.cpp)59
-rw-r--r--examples/serialport/blockingsender/dialog.h52
-rw-r--r--examples/serialport/blockingsender/main.cpp14
-rw-r--r--examples/serialport/blockingsender/senderthread.cpp (renamed from examples/serialport/blockingmaster/masterthread.cpp)61
-rw-r--r--examples/serialport/blockingsender/senderthread.h39
-rw-r--r--examples/serialport/blockingslave/dialog.cpp141
-rw-r--r--examples/serialport/blockingslave/dialog.h97
-rw-r--r--examples/serialport/blockingslave/main.cpp61
-rw-r--r--examples/serialport/blockingslave/slavethread.cpp154
-rw-r--r--examples/serialport/blockingslave/slavethread.h85
-rw-r--r--examples/serialport/cenumerator/cenumerator.pro14
-rw-r--r--examples/serialport/cenumerator/main.cpp87
-rw-r--r--examples/serialport/creaderasync/creaderasync.pro18
-rw-r--r--examples/serialport/creaderasync/main.cpp92
-rw-r--r--examples/serialport/creaderasync/serialportreader.cpp102
-rw-r--r--examples/serialport/creaderasync/serialportreader.h82
-rw-r--r--examples/serialport/creadersync/creadersync.pro14
-rw-r--r--examples/serialport/creadersync/main.cpp104
-rw-r--r--examples/serialport/cwriterasync/cwriterasync.pro18
-rw-r--r--examples/serialport/cwriterasync/main.cpp104
-rw-r--r--examples/serialport/cwriterasync/serialportwriter.cpp121
-rw-r--r--examples/serialport/cwriterasync/serialportwriter.h85
-rw-r--r--examples/serialport/cwritersync/cwritersync.pro14
-rw-r--r--examples/serialport/cwritersync/main.cpp125
-rw-r--r--examples/serialport/doc/blockingreceiver.qdoc (renamed from examples/serialport/doc/blockingslave.qdoc)100
-rw-r--r--examples/serialport/doc/blockingsender.qdoc (renamed from examples/serialport/doc/blockingmaster.qdoc)88
-rw-r--r--examples/serialport/doc/cenumerator.qdoc47
-rw-r--r--examples/serialport/doc/creaderasync.qdoc49
-rw-r--r--examples/serialport/doc/creadersync.qdoc49
-rw-r--r--examples/serialport/doc/cwriterasync.qdoc49
-rw-r--r--examples/serialport/doc/cwritersync.qdoc49
-rw-r--r--examples/serialport/doc/enumerator.qdoc47
-rw-r--r--examples/serialport/doc/terminal.qdoc79
-rw-r--r--examples/serialport/enumerator/enumerator.pro10
-rw-r--r--examples/serialport/enumerator/main.cpp88
-rw-r--r--examples/serialport/master/dialog.h101
-rw-r--r--examples/serialport/master/main.cpp61
-rw-r--r--examples/serialport/master/master.pro19
-rw-r--r--examples/serialport/serialport.pro3
-rw-r--r--examples/serialport/slave/dialog.h101
-rw-r--r--examples/serialport/slave/main.cpp61
-rw-r--r--examples/serialport/slave/slave.pro19
-rw-r--r--examples/serialport/slave/slavethread.cpp146
-rw-r--r--examples/serialport/slave/slavethread.h82
-rw-r--r--examples/serialport/terminal/CMakeLists.txt56
-rw-r--r--examples/serialport/terminal/console.cpp53
-rw-r--r--examples/serialport/terminal/console.h53
-rw-r--r--examples/serialport/terminal/main.cpp53
-rw-r--r--examples/serialport/terminal/mainwindow.cpp109
-rw-r--r--examples/serialport/terminal/mainwindow.h59
-rw-r--r--examples/serialport/terminal/mainwindow.ui2
-rw-r--r--examples/serialport/terminal/settingsdialog.cpp106
-rw-r--r--examples/serialport/terminal/settingsdialog.h53
-rw-r--r--qt_cmdline.cmake1
-rw-r--r--qtserialport.pro15
-rw-r--r--src/CMakeLists.txt1
-rw-r--r--src/serialport/CMakeLists.txt72
-rw-r--r--src/serialport/configure.cmake46
-rw-r--r--src/serialport/configure.json41
-rw-r--r--src/serialport/doc/images/blockingmaster-example.pngbin3797 -> 0 bytes
-rw-r--r--src/serialport/doc/images/blockingreceiver-example.pngbin0 -> 17425 bytes
-rw-r--r--src/serialport/doc/images/blockingsender-example.pngbin0 -> 16983 bytes
-rw-r--r--src/serialport/doc/images/blockingslave-example.pngbin3918 -> 0 bytes
-rw-r--r--src/serialport/doc/images/cenumerator-example.pngbin3532 -> 0 bytes
-rw-r--r--src/serialport/doc/images/creaderasync-example.pngbin12788 -> 0 bytes
-rw-r--r--src/serialport/doc/images/creadersync-example.pngbin13638 -> 0 bytes
-rw-r--r--src/serialport/doc/images/cwriterasync-example.pngbin11519 -> 0 bytes
-rw-r--r--src/serialport/doc/images/cwritersync-example.pngbin12653 -> 0 bytes
-rw-r--r--src/serialport/doc/images/enumerator-example.pngbin15557 -> 0 bytes
-rw-r--r--src/serialport/doc/images/terminal-example.pngbin8548 -> 11541 bytes
-rw-r--r--src/serialport/doc/qtserialport.qdocconf13
-rw-r--r--src/serialport/doc/snippets/doc_src_serialport.cpp41
-rw-r--r--src/serialport/doc/src/index.qdoc59
-rw-r--r--src/serialport/doc/src/qt6-changes.qdoc26
-rw-r--r--src/serialport/doc/src/qtserialport-examples.qdoc32
-rw-r--r--src/serialport/doc/src/qtserialport-module-use.qdocinc15
-rw-r--r--src/serialport/doc/src/qtserialport-module.qdoc40
-rw-r--r--src/serialport/qserialport.cpp381
-rw-r--r--src/serialport/qserialport.h151
-rw-r--r--src/serialport/qserialport_p.h114
-rw-r--r--src/serialport/qserialport_unix.cpp48
-rw-r--r--src/serialport/qserialport_win.cpp405
-rw-r--r--src/serialport/qserialportglobal.h57
-rw-r--r--src/serialport/qserialportinfo.cpp96
-rw-r--r--src/serialport/qserialportinfo.h51
-rw-r--r--src/serialport/qserialportinfo_freebsd.cpp75
-rw-r--r--src/serialport/qserialportinfo_osx.cpp77
-rw-r--r--src/serialport/qserialportinfo_p.h53
-rw-r--r--src/serialport/qserialportinfo_unix.cpp130
-rw-r--r--src/serialport/qserialportinfo_win.cpp76
-rw-r--r--src/serialport/qt_cmdline.cmake0
-rw-r--r--src/serialport/qtntdll_p.h158
-rw-r--r--src/serialport/qtudev_p.h41
-rw-r--r--src/serialport/qwinoverlappedionotifier.cpp84
-rw-r--r--src/serialport/qwinoverlappedionotifier_p.h55
-rw-r--r--src/serialport/serialport-lib.pri51
-rw-r--r--src/serialport/serialport.pro12
-rw-r--r--src/src.pro3
-rw-r--r--tests/CMakeLists.txt8
-rw-r--r--tests/auto/CMakeLists.txt9
-rw-r--r--tests/auto/auto.pro5
-rw-r--r--tests/auto/cmake/CMakeLists.txt48
-rw-r--r--tests/auto/cmake/cmake.pro7
-rw-r--r--tests/auto/qserialport/CMakeLists.txt14
-rw-r--r--tests/auto/qserialport/qserialport.pro7
-rw-r--r--tests/auto/qserialport/tst_qserialport.cpp229
-rw-r--r--tests/auto/qserialportinfo/CMakeLists.txt14
-rw-r--r--tests/auto/qserialportinfo/qserialportinfo.pro11
-rw-r--r--tests/auto/qserialportinfo/tst_qserialportinfo.cpp29
-rw-r--r--tests/auto/qserialportinfoprivate/CMakeLists.txt14
-rw-r--r--tests/auto/qserialportinfoprivate/qserialportinfoprivate.pro4
-rw-r--r--tests/auto/qserialportinfoprivate/tst_qserialportinfoprivate.cpp29
-rw-r--r--tests/manual/CMakeLists.txt7
-rw-r--r--tests/manual/examples/receiver/CMakeLists.txt26
-rw-r--r--tests/manual/examples/receiver/dialog.cpp (renamed from examples/serialport/slave/dialog.cpp)59
-rw-r--r--tests/manual/examples/receiver/dialog.h54
-rw-r--r--tests/manual/examples/receiver/main.cpp14
-rw-r--r--tests/manual/examples/receiver/receiver.pro12
-rw-r--r--tests/manual/examples/sender/CMakeLists.txt28
-rw-r--r--tests/manual/examples/sender/dialog.cpp (renamed from examples/serialport/master/dialog.cpp)53
-rw-r--r--tests/manual/examples/sender/dialog.h54
-rw-r--r--tests/manual/examples/sender/main.cpp14
-rw-r--r--tests/manual/examples/sender/sender.pro12
-rw-r--r--tests/tests.pro2
158 files changed, 2270 insertions, 6210 deletions
diff --git a/.cmake.conf b/.cmake.conf
new file mode 100644
index 0000000..2792a7d
--- /dev/null
+++ b/.cmake.conf
@@ -0,0 +1,3 @@
+set(QT_REPO_MODULE_VERSION "6.6.0")
+set(QT_REPO_MODULE_PRERELEASE_VERSION_SEGMENT "alpha1")
+set(QT_EXTRA_INTERNAL_TARGET_DEFINES "QT_NO_AS_CONST=1")
diff --git a/.gitignore b/.gitignore
index 1ca16d1..ef2176f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -5,7 +5,7 @@ Makefile
*.o
*.a
moc_*.cpp
-*.pro.user
+*.pro.user*
*.moc
lib*.so
lib*.so.*
@@ -18,3 +18,7 @@ module-paths/*
lib/pkgconfig/*
Makefile.Debug
Makefile.Release
+.vs
+CMakeSettings.json
+out/*
+CMakeLists.txt.user*
diff --git a/.qmake.conf b/.qmake.conf
deleted file mode 100644
index 3066cd8..0000000
--- a/.qmake.conf
+++ /dev/null
@@ -1,5 +0,0 @@
-load(qt_build_config)
-
-DEFINES += QT_NO_FOREACH QT_NO_JAVA_STYLE_ITERATORS
-
-MODULE_VERSION = 6.0.0
diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100644
index 0000000..777a042
--- /dev/null
+++ b/CMakeLists.txt
@@ -0,0 +1,40 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
+cmake_minimum_required(VERSION 3.16)
+
+include(.cmake.conf)
+project(QtSerialPort
+ VERSION "${QT_REPO_MODULE_VERSION}"
+ DESCRIPTION "Qt SerialPort Libraries"
+ HOMEPAGE_URL "https://qt.io/"
+ LANGUAGES CXX C
+)
+
+set(QT_NO_INTERNAL_COMPATIBILITY_FUNCTIONS TRUE)
+
+find_package(Qt6 ${PROJECT_VERSION} CONFIG REQUIRED COMPONENTS BuildInternals Core)
+find_package(Qt6 ${PROJECT_VERSION} CONFIG OPTIONAL_COMPONENTS Gui Widgets)
+qt_internal_project_setup()
+
+if(INTEGRITY)
+ message(NOTICE "Skipping the build as the condition \"NOT INTEGRITY\" is not met.")
+ return()
+endif()
+if(VXWORKS)
+ message(NOTICE "Skipping the build as the condition \"NOT VXWORKS\" is not met.")
+ return()
+endif()
+if(WINRT)
+ message(NOTICE "Skipping the build as the condition \"NOT WINRT\" is not met.")
+ return()
+endif()
+if(UIKIT)
+ message(NOTICE "Skipping the build as the condition \"NOT UIKIT\" is not met.")
+ return()
+endif()
+if(EMSCRIPTEN)
+ message(NOTICE "Skipping the build as the condition \"NOT EMSCRIPTEN\" is not met.")
+ return()
+endif()
+qt_build_repo()
diff --git a/LICENSE.GPL3-EXCEPT b/LICENSE.GPL3-EXCEPT
deleted file mode 100644
index b1cb1be..0000000
--- a/LICENSE.GPL3-EXCEPT
+++ /dev/null
@@ -1,704 +0,0 @@
-This is the GNU General Public License version 3, annotated with The
-Qt Company GPL Exception 1.0:
-
--------------------------------------------------------------------------
-
-The Qt Company GPL Exception 1.0
-
-Exception 1:
-
-As a special exception you may create a larger work which contains the
-output of this application and distribute that work under terms of your
-choice, so long as the work is not otherwise derived from or based on
-this application and so long as the work does not in itself generate
-output that contains the output from this application in its original
-or modified form.
-
-Exception 2:
-
-As a special exception, you have permission to combine this application
-with Plugins licensed under the terms of your choice, to produce an
-executable, and to copy and distribute the resulting executable under
-the terms of your choice. However, the executable must be accompanied
-by a prominent notice offering all users of the executable the entire
-source code to this application, excluding the source code of the
-independent modules, but including any changes you have made to this
-application, under the terms of this license.
-
-
--------------------------------------------------------------------------
-
- GNU GENERAL PUBLIC LICENSE
- Version 3, 29 June 2007
-
- Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
- Preamble
-
- The GNU General Public License is a free, copyleft license for
-software and other kinds of works.
-
- The licenses for most software and other practical works are designed
-to take away your freedom to share and change the works. By contrast,
-the GNU General Public License is intended to guarantee your freedom to
-share and change all versions of a program--to make sure it remains free
-software for all its users. We, the Free Software Foundation, use the
-GNU General Public License for most of our software; it applies also to
-any other work released this way by its authors. You can apply it to
-your programs, too.
-
- When we speak of free software, we are referring to freedom, not
-price. Our General Public Licenses are designed to make sure that you
-have the freedom to distribute copies of free software (and charge for
-them if you wish), that you receive source code or can get it if you
-want it, that you can change the software or use pieces of it in new
-free programs, and that you know you can do these things.
-
- To protect your rights, we need to prevent others from denying you
-these rights or asking you to surrender the rights. Therefore, you have
-certain responsibilities if you distribute copies of the software, or if
-you modify it: responsibilities to respect the freedom of others.
-
- For example, if you distribute copies of such a program, whether
-gratis or for a fee, you must pass on to the recipients the same
-freedoms that you received. You must make sure that they, too, receive
-or can get the source code. And you must show them these terms so they
-know their rights.
-
- Developers that use the GNU GPL protect your rights with two steps:
-(1) assert copyright on the software, and (2) offer you this License
-giving you legal permission to copy, distribute and/or modify it.
-
- For the developers' and authors' protection, the GPL clearly explains
-that there is no warranty for this free software. For both users' and
-authors' sake, the GPL requires that modified versions be marked as
-changed, so that their problems will not be attributed erroneously to
-authors of previous versions.
-
- Some devices are designed to deny users access to install or run
-modified versions of the software inside them, although the manufacturer
-can do so. This is fundamentally incompatible with the aim of
-protecting users' freedom to change the software. The systematic
-pattern of such abuse occurs in the area of products for individuals to
-use, which is precisely where it is most unacceptable. Therefore, we
-have designed this version of the GPL to prohibit the practice for those
-products. If such problems arise substantially in other domains, we
-stand ready to extend this provision to those domains in future versions
-of the GPL, as needed to protect the freedom of users.
-
- Finally, every program is threatened constantly by software patents.
-States should not allow patents to restrict development and use of
-software on general-purpose computers, but in those that do, we wish to
-avoid the special danger that patents applied to a free program could
-make it effectively proprietary. To prevent this, the GPL assures that
-patents cannot be used to render the program non-free.
-
- The precise terms and conditions for copying, distribution and
-modification follow.
-
- TERMS AND CONDITIONS
-
- 0. Definitions.
-
- "This License" refers to version 3 of the GNU General Public License.
-
- "Copyright" also means copyright-like laws that apply to other kinds of
-works, such as semiconductor masks.
-
- "The Program" refers to any copyrightable work licensed under this
-License. Each licensee is addressed as "you". "Licensees" and
-"recipients" may be individuals or organizations.
-
- To "modify" a work means to copy from or adapt all or part of the work
-in a fashion requiring copyright permission, other than the making of an
-exact copy. The resulting work is called a "modified version" of the
-earlier work or a work "based on" the earlier work.
-
- A "covered work" means either the unmodified Program or a work based
-on the Program.
-
- To "propagate" a work means to do anything with it that, without
-permission, would make you directly or secondarily liable for
-infringement under applicable copyright law, except executing it on a
-computer or modifying a private copy. Propagation includes copying,
-distribution (with or without modification), making available to the
-public, and in some countries other activities as well.
-
- To "convey" a work means any kind of propagation that enables other
-parties to make or receive copies. Mere interaction with a user through
-a computer network, with no transfer of a copy, is not conveying.
-
- An interactive user interface displays "Appropriate Legal Notices"
-to the extent that it includes a convenient and prominently visible
-feature that (1) displays an appropriate copyright notice, and (2)
-tells the user that there is no warranty for the work (except to the
-extent that warranties are provided), that licensees may convey the
-work under this License, and how to view a copy of this License. If
-the interface presents a list of user commands or options, such as a
-menu, a prominent item in the list meets this criterion.
-
- 1. Source Code.
-
- The "source code" for a work means the preferred form of the work
-for making modifications to it. "Object code" means any non-source
-form of a work.
-
- A "Standard Interface" means an interface that either is an official
-standard defined by a recognized standards body, or, in the case of
-interfaces specified for a particular programming language, one that
-is widely used among developers working in that language.
-
- The "System Libraries" of an executable work include anything, other
-than the work as a whole, that (a) is included in the normal form of
-packaging a Major Component, but which is not part of that Major
-Component, and (b) serves only to enable use of the work with that
-Major Component, or to implement a Standard Interface for which an
-implementation is available to the public in source code form. A
-"Major Component", in this context, means a major essential component
-(kernel, window system, and so on) of the specific operating system
-(if any) on which the executable work runs, or a compiler used to
-produce the work, or an object code interpreter used to run it.
-
- The "Corresponding Source" for a work in object code form means all
-the source code needed to generate, install, and (for an executable
-work) run the object code and to modify the work, including scripts to
-control those activities. However, it does not include the work's
-System Libraries, or general-purpose tools or generally available free
-programs which are used unmodified in performing those activities but
-which are not part of the work. For example, Corresponding Source
-includes interface definition files associated with source files for
-the work, and the source code for shared libraries and dynamically
-linked subprograms that the work is specifically designed to require,
-such as by intimate data communication or control flow between those
-subprograms and other parts of the work.
-
- The Corresponding Source need not include anything that users
-can regenerate automatically from other parts of the Corresponding
-Source.
-
- The Corresponding Source for a work in source code form is that
-same work.
-
- 2. Basic Permissions.
-
- All rights granted under this License are granted for the term of
-copyright on the Program, and are irrevocable provided the stated
-conditions are met. This License explicitly affirms your unlimited
-permission to run the unmodified Program. The output from running a
-covered work is covered by this License only if the output, given its
-content, constitutes a covered work. This License acknowledges your
-rights of fair use or other equivalent, as provided by copyright law.
-
- You may make, run and propagate covered works that you do not
-convey, without conditions so long as your license otherwise remains
-in force. You may convey covered works to others for the sole purpose
-of having them make modifications exclusively for you, or provide you
-with facilities for running those works, provided that you comply with
-the terms of this License in conveying all material for which you do
-not control copyright. Those thus making or running the covered works
-for you must do so exclusively on your behalf, under your direction
-and control, on terms that prohibit them from making any copies of
-your copyrighted material outside their relationship with you.
-
- Conveying under any other circumstances is permitted solely under
-the conditions stated below. Sublicensing is not allowed; section 10
-makes it unnecessary.
-
- 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
-
- No covered work shall be deemed part of an effective technological
-measure under any applicable law fulfilling obligations under article
-11 of the WIPO copyright treaty adopted on 20 December 1996, or
-similar laws prohibiting or restricting circumvention of such
-measures.
-
- When you convey a covered work, you waive any legal power to forbid
-circumvention of technological measures to the extent such circumvention
-is effected by exercising rights under this License with respect to
-the covered work, and you disclaim any intention to limit operation or
-modification of the work as a means of enforcing, against the work's
-users, your or third parties' legal rights to forbid circumvention of
-technological measures.
-
- 4. Conveying Verbatim Copies.
-
- You may convey verbatim copies of the Program's source code as you
-receive it, in any medium, provided that you conspicuously and
-appropriately publish on each copy an appropriate copyright notice;
-keep intact all notices stating that this License and any
-non-permissive terms added in accord with section 7 apply to the code;
-keep intact all notices of the absence of any warranty; and give all
-recipients a copy of this License along with the Program.
-
- You may charge any price or no price for each copy that you convey,
-and you may offer support or warranty protection for a fee.
-
- 5. Conveying Modified Source Versions.
-
- You may convey a work based on the Program, or the modifications to
-produce it from the Program, in the form of source code under the
-terms of section 4, provided that you also meet all of these conditions:
-
- a) The work must carry prominent notices stating that you modified
- it, and giving a relevant date.
-
- b) The work must carry prominent notices stating that it is
- released under this License and any conditions added under section
- 7. This requirement modifies the requirement in section 4 to
- "keep intact all notices".
-
- c) You must license the entire work, as a whole, under this
- License to anyone who comes into possession of a copy. This
- License will therefore apply, along with any applicable section 7
- additional terms, to the whole of the work, and all its parts,
- regardless of how they are packaged. This License gives no
- permission to license the work in any other way, but it does not
- invalidate such permission if you have separately received it.
-
- d) If the work has interactive user interfaces, each must display
- Appropriate Legal Notices; however, if the Program has interactive
- interfaces that do not display Appropriate Legal Notices, your
- work need not make them do so.
-
- A compilation of a covered work with other separate and independent
-works, which are not by their nature extensions of the covered work,
-and which are not combined with it such as to form a larger program,
-in or on a volume of a storage or distribution medium, is called an
-"aggregate" if the compilation and its resulting copyright are not
-used to limit the access or legal rights of the compilation's users
-beyond what the individual works permit. Inclusion of a covered work
-in an aggregate does not cause this License to apply to the other
-parts of the aggregate.
-
- 6. Conveying Non-Source Forms.
-
- You may convey a covered work in object code form under the terms
-of sections 4 and 5, provided that you also convey the
-machine-readable Corresponding Source under the terms of this License,
-in one of these ways:
-
- a) Convey the object code in, or embodied in, a physical product
- (including a physical distribution medium), accompanied by the
- Corresponding Source fixed on a durable physical medium
- customarily used for software interchange.
-
- b) Convey the object code in, or embodied in, a physical product
- (including a physical distribution medium), accompanied by a
- written offer, valid for at least three years and valid for as
- long as you offer spare parts or customer support for that product
- model, to give anyone who possesses the object code either (1) a
- copy of the Corresponding Source for all the software in the
- product that is covered by this License, on a durable physical
- medium customarily used for software interchange, for a price no
- more than your reasonable cost of physically performing this
- conveying of source, or (2) access to copy the
- Corresponding Source from a network server at no charge.
-
- c) Convey individual copies of the object code with a copy of the
- written offer to provide the Corresponding Source. This
- alternative is allowed only occasionally and noncommercially, and
- only if you received the object code with such an offer, in accord
- with subsection 6b.
-
- d) Convey the object code by offering access from a designated
- place (gratis or for a charge), and offer equivalent access to the
- Corresponding Source in the same way through the same place at no
- further charge. You need not require recipients to copy the
- Corresponding Source along with the object code. If the place to
- copy the object code is a network server, the Corresponding Source
- may be on a different server (operated by you or a third party)
- that supports equivalent copying facilities, provided you maintain
- clear directions next to the object code saying where to find the
- Corresponding Source. Regardless of what server hosts the
- Corresponding Source, you remain obligated to ensure that it is
- available for as long as needed to satisfy these requirements.
-
- e) Convey the object code using peer-to-peer transmission, provided
- you inform other peers where the object code and Corresponding
- Source of the work are being offered to the general public at no
- charge under subsection 6d.
-
- A separable portion of the object code, whose source code is excluded
-from the Corresponding Source as a System Library, need not be
-included in conveying the object code work.
-
- A "User Product" is either (1) a "consumer product", which means any
-tangible personal property which is normally used for personal, family,
-or household purposes, or (2) anything designed or sold for incorporation
-into a dwelling. In determining whether a product is a consumer product,
-doubtful cases shall be resolved in favor of coverage. For a particular
-product received by a particular user, "normally used" refers to a
-typical or common use of that class of product, regardless of the status
-of the particular user or of the way in which the particular user
-actually uses, or expects or is expected to use, the product. A product
-is a consumer product regardless of whether the product has substantial
-commercial, industrial or non-consumer uses, unless such uses represent
-the only significant mode of use of the product.
-
- "Installation Information" for a User Product means any methods,
-procedures, authorization keys, or other information required to install
-and execute modified versions of a covered work in that User Product from
-a modified version of its Corresponding Source. The information must
-suffice to ensure that the continued functioning of the modified object
-code is in no case prevented or interfered with solely because
-modification has been made.
-
- If you convey an object code work under this section in, or with, or
-specifically for use in, a User Product, and the conveying occurs as
-part of a transaction in which the right of possession and use of the
-User Product is transferred to the recipient in perpetuity or for a
-fixed term (regardless of how the transaction is characterized), the
-Corresponding Source conveyed under this section must be accompanied
-by the Installation Information. But this requirement does not apply
-if neither you nor any third party retains the ability to install
-modified object code on the User Product (for example, the work has
-been installed in ROM).
-
- The requirement to provide Installation Information does not include a
-requirement to continue to provide support service, warranty, or updates
-for a work that has been modified or installed by the recipient, or for
-the User Product in which it has been modified or installed. Access to a
-network may be denied when the modification itself materially and
-adversely affects the operation of the network or violates the rules and
-protocols for communication across the network.
-
- Corresponding Source conveyed, and Installation Information provided,
-in accord with this section must be in a format that is publicly
-documented (and with an implementation available to the public in
-source code form), and must require no special password or key for
-unpacking, reading or copying.
-
- 7. Additional Terms.
-
- "Additional permissions" are terms that supplement the terms of this
-License by making exceptions from one or more of its conditions.
-Additional permissions that are applicable to the entire Program shall
-be treated as though they were included in this License, to the extent
-that they are valid under applicable law. If additional permissions
-apply only to part of the Program, that part may be used separately
-under those permissions, but the entire Program remains governed by
-this License without regard to the additional permissions.
-
- When you convey a copy of a covered work, you may at your option
-remove any additional permissions from that copy, or from any part of
-it. (Additional permissions may be written to require their own
-removal in certain cases when you modify the work.) You may place
-additional permissions on material, added by you to a covered work,
-for which you have or can give appropriate copyright permission.
-
- Notwithstanding any other provision of this License, for material you
-add to a covered work, you may (if authorized by the copyright holders of
-that material) supplement the terms of this License with terms:
-
- a) Disclaiming warranty or limiting liability differently from the
- terms of sections 15 and 16 of this License; or
-
- b) Requiring preservation of specified reasonable legal notices or
- author attributions in that material or in the Appropriate Legal
- Notices displayed by works containing it; or
-
- c) Prohibiting misrepresentation of the origin of that material, or
- requiring that modified versions of such material be marked in
- reasonable ways as different from the original version; or
-
- d) Limiting the use for publicity purposes of names of licensors or
- authors of the material; or
-
- e) Declining to grant rights under trademark law for use of some
- trade names, trademarks, or service marks; or
-
- f) Requiring indemnification of licensors and authors of that
- material by anyone who conveys the material (or modified versions of
- it) with contractual assumptions of liability to the recipient, for
- any liability that these contractual assumptions directly impose on
- those licensors and authors.
-
- All other non-permissive additional terms are considered "further
-restrictions" within the meaning of section 10. If the Program as you
-received it, or any part of it, contains a notice stating that it is
-governed by this License along with a term that is a further
-restriction, you may remove that term. If a license document contains
-a further restriction but permits relicensing or conveying under this
-License, you may add to a covered work material governed by the terms
-of that license document, provided that the further restriction does
-not survive such relicensing or conveying.
-
- If you add terms to a covered work in accord with this section, you
-must place, in the relevant source files, a statement of the
-additional terms that apply to those files, or a notice indicating
-where to find the applicable terms.
-
- Additional terms, permissive or non-permissive, may be stated in the
-form of a separately written license, or stated as exceptions;
-the above requirements apply either way.
-
- 8. Termination.
-
- You may not propagate or modify a covered work except as expressly
-provided under this License. Any attempt otherwise to propagate or
-modify it is void, and will automatically terminate your rights under
-this License (including any patent licenses granted under the third
-paragraph of section 11).
-
- However, if you cease all violation of this License, then your
-license from a particular copyright holder is reinstated (a)
-provisionally, unless and until the copyright holder explicitly and
-finally terminates your license, and (b) permanently, if the copyright
-holder fails to notify you of the violation by some reasonable means
-prior to 60 days after the cessation.
-
- Moreover, your license from a particular copyright holder is
-reinstated permanently if the copyright holder notifies you of the
-violation by some reasonable means, this is the first time you have
-received notice of violation of this License (for any work) from that
-copyright holder, and you cure the violation prior to 30 days after
-your receipt of the notice.
-
- Termination of your rights under this section does not terminate the
-licenses of parties who have received copies or rights from you under
-this License. If your rights have been terminated and not permanently
-reinstated, you do not qualify to receive new licenses for the same
-material under section 10.
-
- 9. Acceptance Not Required for Having Copies.
-
- You are not required to accept this License in order to receive or
-run a copy of the Program. Ancillary propagation of a covered work
-occurring solely as a consequence of using peer-to-peer transmission
-to receive a copy likewise does not require acceptance. However,
-nothing other than this License grants you permission to propagate or
-modify any covered work. These actions infringe copyright if you do
-not accept this License. Therefore, by modifying or propagating a
-covered work, you indicate your acceptance of this License to do so.
-
- 10. Automatic Licensing of Downstream Recipients.
-
- Each time you convey a covered work, the recipient automatically
-receives a license from the original licensors, to run, modify and
-propagate that work, subject to this License. You are not responsible
-for enforcing compliance by third parties with this License.
-
- An "entity transaction" is a transaction transferring control of an
-organization, or substantially all assets of one, or subdividing an
-organization, or merging organizations. If propagation of a covered
-work results from an entity transaction, each party to that
-transaction who receives a copy of the work also receives whatever
-licenses to the work the party's predecessor in interest had or could
-give under the previous paragraph, plus a right to possession of the
-Corresponding Source of the work from the predecessor in interest, if
-the predecessor has it or can get it with reasonable efforts.
-
- You may not impose any further restrictions on the exercise of the
-rights granted or affirmed under this License. For example, you may
-not impose a license fee, royalty, or other charge for exercise of
-rights granted under this License, and you may not initiate litigation
-(including a cross-claim or counterclaim in a lawsuit) alleging that
-any patent claim is infringed by making, using, selling, offering for
-sale, or importing the Program or any portion of it.
-
- 11. Patents.
-
- A "contributor" is a copyright holder who authorizes use under this
-License of the Program or a work on which the Program is based. The
-work thus licensed is called the contributor's "contributor version".
-
- A contributor's "essential patent claims" are all patent claims
-owned or controlled by the contributor, whether already acquired or
-hereafter acquired, that would be infringed by some manner, permitted
-by this License, of making, using, or selling its contributor version,
-but do not include claims that would be infringed only as a
-consequence of further modification of the contributor version. For
-purposes of this definition, "control" includes the right to grant
-patent sublicenses in a manner consistent with the requirements of
-this License.
-
- Each contributor grants you a non-exclusive, worldwide, royalty-free
-patent license under the contributor's essential patent claims, to
-make, use, sell, offer for sale, import and otherwise run, modify and
-propagate the contents of its contributor version.
-
- In the following three paragraphs, a "patent license" is any express
-agreement or commitment, however denominated, not to enforce a patent
-(such as an express permission to practice a patent or covenant not to
-sue for patent infringement). To "grant" such a patent license to a
-party means to make such an agreement or commitment not to enforce a
-patent against the party.
-
- If you convey a covered work, knowingly relying on a patent license,
-and the Corresponding Source of the work is not available for anyone
-to copy, free of charge and under the terms of this License, through a
-publicly available network server or other readily accessible means,
-then you must either (1) cause the Corresponding Source to be so
-available, or (2) arrange to deprive yourself of the benefit of the
-patent license for this particular work, or (3) arrange, in a manner
-consistent with the requirements of this License, to extend the patent
-license to downstream recipients. "Knowingly relying" means you have
-actual knowledge that, but for the patent license, your conveying the
-covered work in a country, or your recipient's use of the covered work
-in a country, would infringe one or more identifiable patents in that
-country that you have reason to believe are valid.
-
- If, pursuant to or in connection with a single transaction or
-arrangement, you convey, or propagate by procuring conveyance of, a
-covered work, and grant a patent license to some of the parties
-receiving the covered work authorizing them to use, propagate, modify
-or convey a specific copy of the covered work, then the patent license
-you grant is automatically extended to all recipients of the covered
-work and works based on it.
-
- A patent license is "discriminatory" if it does not include within
-the scope of its coverage, prohibits the exercise of, or is
-conditioned on the non-exercise of one or more of the rights that are
-specifically granted under this License. You may not convey a covered
-work if you are a party to an arrangement with a third party that is
-in the business of distributing software, under which you make payment
-to the third party based on the extent of your activity of conveying
-the work, and under which the third party grants, to any of the
-parties who would receive the covered work from you, a discriminatory
-patent license (a) in connection with copies of the covered work
-conveyed by you (or copies made from those copies), or (b) primarily
-for and in connection with specific products or compilations that
-contain the covered work, unless you entered into that arrangement,
-or that patent license was granted, prior to 28 March 2007.
-
- Nothing in this License shall be construed as excluding or limiting
-any implied license or other defenses to infringement that may
-otherwise be available to you under applicable patent law.
-
- 12. No Surrender of Others' Freedom.
-
- If conditions are imposed on you (whether by court order, agreement or
-otherwise) that contradict the conditions of this License, they do not
-excuse you from the conditions of this License. If you cannot convey a
-covered work so as to satisfy simultaneously your obligations under this
-License and any other pertinent obligations, then as a consequence you may
-not convey it at all. For example, if you agree to terms that obligate you
-to collect a royalty for further conveying from those to whom you convey
-the Program, the only way you could satisfy both those terms and this
-License would be to refrain entirely from conveying the Program.
-
- 13. Use with the GNU Affero General Public License.
-
- Notwithstanding any other provision of this License, you have
-permission to link or combine any covered work with a work licensed
-under version 3 of the GNU Affero General Public License into a single
-combined work, and to convey the resulting work. The terms of this
-License will continue to apply to the part which is the covered work,
-but the special requirements of the GNU Affero General Public License,
-section 13, concerning interaction through a network will apply to the
-combination as such.
-
- 14. Revised Versions of this License.
-
- The Free Software Foundation may publish revised and/or new versions of
-the GNU General Public License from time to time. Such new versions will
-be similar in spirit to the present version, but may differ in detail to
-address new problems or concerns.
-
- Each version is given a distinguishing version number. If the
-Program specifies that a certain numbered version of the GNU General
-Public License "or any later version" applies to it, you have the
-option of following the terms and conditions either of that numbered
-version or of any later version published by the Free Software
-Foundation. If the Program does not specify a version number of the
-GNU General Public License, you may choose any version ever published
-by the Free Software Foundation.
-
- If the Program specifies that a proxy can decide which future
-versions of the GNU General Public License can be used, that proxy's
-public statement of acceptance of a version permanently authorizes you
-to choose that version for the Program.
-
- Later license versions may give you additional or different
-permissions. However, no additional obligations are imposed on any
-author or copyright holder as a result of your choosing to follow a
-later version.
-
- 15. Disclaimer of Warranty.
-
- THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
-APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
-HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
-OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
-THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
-IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
-ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
-
- 16. Limitation of Liability.
-
- IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
-WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
-THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
-GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
-USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
-DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
-PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
-EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
-SUCH DAMAGES.
-
- 17. Interpretation of Sections 15 and 16.
-
- If the disclaimer of warranty and limitation of liability provided
-above cannot be given local legal effect according to their terms,
-reviewing courts shall apply local law that most closely approximates
-an absolute waiver of all civil liability in connection with the
-Program, unless a warranty or assumption of liability accompanies a
-copy of the Program in return for a fee.
-
- END OF TERMS AND CONDITIONS
-
- How to Apply These Terms to Your New Programs
-
- If you develop a new program, and you want it to be of the greatest
-possible use to the public, the best way to achieve this is to make it
-free software which everyone can redistribute and change under these terms.
-
- To do so, attach the following notices to the program. It is safest
-to attach them to the start of each source file to most effectively
-state the exclusion of warranty; and each file should have at least
-the "copyright" line and a pointer to where the full notice is found.
-
- <one line to give the program's name and a brief idea of what it does.>
- Copyright (C) <year> <name of author>
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-Also add information on how to contact you by electronic and paper mail.
-
- If the program does terminal interaction, make it output a short
-notice like this when it starts in an interactive mode:
-
- <program> Copyright (C) <year> <name of author>
- This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
- This is free software, and you are welcome to redistribute it
- under certain conditions; type `show c' for details.
-
-The hypothetical commands `show w' and `show c' should show the appropriate
-parts of the General Public License. Of course, your program's commands
-might be different; for a GUI interface, you would use an "about box".
-
- You should also get your employer (if you work as a programmer) or school,
-if any, to sign a "copyright disclaimer" for the program, if necessary.
-For more information on this, and how to apply and follow the GNU GPL, see
-<http://www.gnu.org/licenses/>.
-
- The GNU General Public License does not permit incorporating your program
-into proprietary programs. If your program is a subroutine library, you
-may consider it more useful to permit linking proprietary applications with
-the library. If this is what you want to do, use the GNU Lesser General
-Public License instead of this License. But first, please read
-<http://www.gnu.org/philosophy/why-not-lgpl.html>.
diff --git a/LICENSES/BSD-3-Clause.txt b/LICENSES/BSD-3-Clause.txt
new file mode 100644
index 0000000..b91bbd8
--- /dev/null
+++ b/LICENSES/BSD-3-Clause.txt
@@ -0,0 +1,9 @@
+Copyright (c) <year> <owner>.
+
+Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
+ 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
+ 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
diff --git a/LICENSE.FDL b/LICENSES/GFDL-1.3-no-invariants-only.txt
index 938bb8d..857214d 100644
--- a/LICENSE.FDL
+++ b/LICENSES/GFDL-1.3-no-invariants-only.txt
@@ -1,9 +1,10 @@
+
GNU Free Documentation License
Version 1.3, 3 November 2008
Copyright (C) 2000, 2001, 2002, 2007, 2008 Free Software Foundation, Inc.
- <http://fsf.org/>
+ <https://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
@@ -376,7 +377,7 @@ The Free Software Foundation may publish new, revised versions of the
GNU Free Documentation License from time to time. Such new versions
will be similar in spirit to the present version, but may differ in
detail to address new problems or concerns. See
-http://www.gnu.org/copyleft/.
+https://www.gnu.org/licenses/.
Each version of the License is given a distinguishing version number.
If the Document specifies that a particular numbered version of this
@@ -400,19 +401,19 @@ public wiki that anybody can edit is an example of such a server. A
"Massive Multiauthor Collaboration" (or "MMC") contained in the site
means any set of copyrightable works thus published on the MMC site.
-"CC-BY-SA" means the Creative Commons Attribution-Share Alike 3.0
-license published by Creative Commons Corporation, a not-for-profit
-corporation with a principal place of business in San Francisco,
-California, as well as future copyleft versions of that license
+"CC-BY-SA" means the Creative Commons Attribution-Share Alike 3.0
+license published by Creative Commons Corporation, a not-for-profit
+corporation with a principal place of business in San Francisco,
+California, as well as future copyleft versions of that license
published by that same organization.
-"Incorporate" means to publish or republish a Document, in whole or in
+"Incorporate" means to publish or republish a Document, in whole or in
part, as part of another Document.
-An MMC is "eligible for relicensing" if it is licensed under this
-License, and if all works that were first published under this License
-somewhere other than this MMC, and subsequently incorporated in whole or
-in part into the MMC, (1) had no cover texts or invariant sections, and
+An MMC is "eligible for relicensing" if it is licensed under this
+License, and if all works that were first published under this License
+somewhere other than this MMC, and subsequently incorporated in whole or
+in part into the MMC, (1) had no cover texts or invariant sections, and
(2) were thus incorporated prior to November 1, 2008.
The operator of an MMC Site may republish an MMC contained in the site
diff --git a/LICENSE.GPL2 b/LICENSES/GPL-2.0-only.txt
index d159169..d159169 100644
--- a/LICENSE.GPL2
+++ b/LICENSES/GPL-2.0-only.txt
diff --git a/LICENSE.GPL3 b/LICENSES/GPL-3.0-only.txt
index 94a9ed0..94a9ed0 100644
--- a/LICENSE.GPL3
+++ b/LICENSES/GPL-3.0-only.txt
diff --git a/LICENSE.LGPL3 b/LICENSES/LGPL-3.0-only.txt
index 65c5ca8..65c5ca8 100644
--- a/LICENSE.LGPL3
+++ b/LICENSES/LGPL-3.0-only.txt
diff --git a/LICENSES/LicenseRef-Qt-Commercial.txt b/LICENSES/LicenseRef-Qt-Commercial.txt
new file mode 100644
index 0000000..825b1f3
--- /dev/null
+++ b/LICENSES/LicenseRef-Qt-Commercial.txt
@@ -0,0 +1,8 @@
+Licensees holding valid commercial Qt licenses may use this software in
+accordance with the the terms contained in a written agreement between
+you and The Qt Company. Alternatively, the terms and conditions that were
+accepted by the licensee when buying and/or downloading the
+software do apply.
+
+For the latest licensing terms and conditions, see https://www.qt.io/terms-conditions.
+For further information use the contact form at https://www.qt.io/contact-us.
diff --git a/LICENSES/Qt-GPL-exception-1.0.txt b/LICENSES/Qt-GPL-exception-1.0.txt
new file mode 100644
index 0000000..d0322bf
--- /dev/null
+++ b/LICENSES/Qt-GPL-exception-1.0.txt
@@ -0,0 +1,22 @@
+The Qt Company GPL Exception 1.0
+
+Exception 1:
+
+As a special exception you may create a larger work which contains the
+output of this application and distribute that work under terms of your
+choice, so long as the work is not otherwise derived from or based on
+this application and so long as the work does not in itself generate
+output that contains the output from this application in its original
+or modified form.
+
+Exception 2:
+
+As a special exception, you have permission to combine this application
+with Plugins licensed under the terms of your choice, to produce an
+executable, and to copy and distribute the resulting executable under
+the terms of your choice. However, the executable must be accompanied
+by a prominent notice offering all users of the executable the entire
+source code to this application, excluding the source code of the
+independent modules, but including any changes you have made to this
+application, under the terms of this license.
+
diff --git a/coin/axivion/ci_config_linux.json b/coin/axivion/ci_config_linux.json
new file mode 100644
index 0000000..2fe9e36
--- /dev/null
+++ b/coin/axivion/ci_config_linux.json
@@ -0,0 +1,59 @@
+{
+ "Project": {
+ "Git": {
+ "_active": true,
+ "sourceserver_gitdir": "/data/axivion/databases/$(env:TESTED_MODULE_COIN).git"
+ },
+ "BuildSystemIntegration": {
+ "child_order": [
+ "GCCSetup",
+ "CMake",
+ "LinkLibraries"
+ ]
+ },
+ "CMake": {
+ "_active": true,
+ "_copy_from": "CMakeIntegration",
+ "build_environment": {},
+ "build_options": "-j4",
+ "generate_options": "--fresh",
+ "generator": "Ninja"
+ },
+ "GCCSetup": {
+ "_active": true,
+ "_copy_from": "Command",
+ "build_command": "gccsetup --cc gcc --cxx g++ --config ../../../axivion/"
+ },
+ "LinkLibraries": {
+ "_active": true,
+ "_copy_from": "AxivionLinker",
+ "input_files": [
+ "build/lib/lib*.so*.ir"
+ ],
+ "ir": "build/$(env:TESTED_MODULE_COIN).ir"
+ },
+ "Project-GlobalOptions": {
+ "directory": "../work/qt/$(env:TESTED_MODULE_COIN)",
+ "ir": "build/$(env:TESTED_MODULE_COIN).ir",
+ "name": "qt_$(env:TESTED_MODULE_COIN)_dev_$(env:TARGET_OS_COIN)"
+ }
+ },
+ "Results": {
+ "Dashboard": {
+ "dashboard_url": "https://axivion-srv.ci.qt.io/axivion/"
+ },
+ "Database": {
+ "ci_mode": {
+ "directory": "/data/axivion/databases"
+ }
+ }
+ },
+ "_Format": "1.0",
+ "_Version": "trunk-9e0ef9c5818",
+ "_VersionNum": [
+ 7,
+ 6,
+ 9999,
+ 11489
+ ]
+}
diff --git a/coin/module_config.yaml b/coin/module_config.yaml
new file mode 100644
index 0000000..16d158c
--- /dev/null
+++ b/coin/module_config.yaml
@@ -0,0 +1,12 @@
+version: 2
+accept_configuration:
+ condition: property
+ property: features
+ not_contains_value: Disable
+
+instructions:
+ Build:
+ - !include "{{qt/qtbase}}/coin_module_build_template_v2.yaml"
+
+ Test:
+ - !include "{{qt/qtbase}}/coin_module_test_template_v3.yaml"
diff --git a/conanfile.py b/conanfile.py
new file mode 100644
index 0000000..b8ad8f9
--- /dev/null
+++ b/conanfile.py
@@ -0,0 +1,31 @@
+# Copyright (C) 2021 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+
+from conans import ConanFile
+import re
+from pathlib import Path
+
+
+def _parse_qt_version_by_key(key: str) -> str:
+ with open(Path(__file__).parent.resolve() / ".cmake.conf") as f:
+ m = re.search(fr'{key} .*"(.*)"', f.read())
+ return m.group(1) if m else ""
+
+
+def _get_qt_minor_version() -> str:
+ return ".".join(_parse_qt_version_by_key("QT_REPO_MODULE_VERSION").split(".")[:2])
+
+
+class QtSerialPort(ConanFile):
+ name = "qtserialport"
+ license = "LGPL-3.0, GPL-2.0+, Commercial Qt License Agreement"
+ author = "The Qt Company <https://www.qt.io/contact-us>"
+ url = "https://code.qt.io/cgit/qt/qtserialport.git"
+ description = "Qt Serialport support."
+ topics = "qt", "qt6", "serialport", "serial communication interface"
+ settings = "os", "compiler", "arch", "build_type"
+ # for referencing the version number and prerelease tag and dependencies info
+ exports = ".cmake.conf", "dependencies.yaml"
+ exports_sources = "*", "!conan*.*"
+ python_requires = f"qt-conan-common/{_get_qt_minor_version()}@qt/everywhere"
+ python_requires_extend = "qt-conan-common.QtLeafModule"
diff --git a/configure.cmake b/configure.cmake
new file mode 100644
index 0000000..68f54ce
--- /dev/null
+++ b/configure.cmake
@@ -0,0 +1,24 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
+
+
+#### Inputs
+
+
+
+#### Libraries
+
+
+
+#### Tests
+
+
+
+#### Features
+
+
+qt_extra_definition("QT_VERSION_STR" "\"${PROJECT_VERSION}\"" PUBLIC)
+qt_extra_definition("QT_VERSION_MAJOR" ${PROJECT_VERSION_MAJOR} PUBLIC)
+qt_extra_definition("QT_VERSION_MINOR" ${PROJECT_VERSION_MINOR} PUBLIC)
+qt_extra_definition("QT_VERSION_PATCH" ${PROJECT_VERSION_PATCH} PUBLIC)
diff --git a/configure.json b/configure.json
deleted file mode 100644
index fdfda24..0000000
--- a/configure.json
+++ /dev/null
@@ -1,5 +0,0 @@
-{
- "subconfigs": [
- "src/serialport"
- ]
-}
diff --git a/dependencies.yaml b/dependencies.yaml
index 15a9f04..96f65d0 100644
--- a/dependencies.yaml
+++ b/dependencies.yaml
@@ -1,4 +1,4 @@
dependencies:
../qtbase:
- ref: e278d721920c6bf2b05b0fa36e2097f691451a4a
+ ref: 06830bd78d2cf43b9d544e3792711cbb60d1c27a
required: true
diff --git a/dist/changes-5.12.10 b/dist/changes-5.12.10
new file mode 100644
index 0000000..c9b97b2
--- /dev/null
+++ b/dist/changes-5.12.10
@@ -0,0 +1,28 @@
+Qt 5.12.10 is a bug-fix release. It maintains both forward and backward
+compatibility (source and binary) with Qt 5.12.9.
+
+For more details, refer to the online documentation included in this
+distribution. The documentation is also available online:
+
+ https://doc.qt.io/qt-5.12/index.html
+
+The Qt version 5.12 series is binary compatible with the 5.11.x series.
+Applications compiled for 5.11 will continue to run with 5.12.
+
+Some of the changes listed in this file include issue tracking numbers
+corresponding to tasks in the Qt Bug Tracker:
+
+ https://bugreports.qt.io/
+
+Each of these identifiers can be entered in the bug tracker to obtain more
+information about a particular change.
+
+****************************************************************************
+* Important Behavior Changes *
+****************************************************************************
+
+****************************************************************************
+* Library *
+****************************************************************************
+
+
diff --git a/dist/changes-5.15.1 b/dist/changes-5.15.1
new file mode 100644
index 0000000..332ee9d
--- /dev/null
+++ b/dist/changes-5.15.1
@@ -0,0 +1,20 @@
+Qt 5.15.1 is a bug-fix release. It maintains both forward and backward
+compatibility (source and binary) with Qt 5.15.0.
+
+For more details, refer to the online documentation included in this
+distribution. The documentation is also available online:
+
+https://doc.qt.io/qt-5/index.html
+
+The Qt version 5.15 series is binary compatible with the 5.14.x series.
+Applications compiled for 5.14 will continue to run with 5.15.
+
+Some of the changes listed in this file include issue tracking numbers
+corresponding to tasks in the Qt Bug Tracker:
+
+https://bugreports.qt.io/
+
+Each of these identifiers can be entered in the bug tracker to obtain more
+information about a particular change.
+
+ - This release contains only minor code improvements.
diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt
new file mode 100644
index 0000000..0b3097b
--- /dev/null
+++ b/examples/CMakeLists.txt
@@ -0,0 +1,10 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
+qt_examples_build_begin(EXTERNAL_BUILD)
+
+if(NOT QNX)
+ add_subdirectory(serialport)
+endif()
+
+qt_examples_build_end()
diff --git a/examples/serialport/CMakeLists.txt b/examples/serialport/CMakeLists.txt
new file mode 100644
index 0000000..f1b6877
--- /dev/null
+++ b/examples/serialport/CMakeLists.txt
@@ -0,0 +1,8 @@
+# Copyright (C) 2023 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
+if(TARGET Qt::Widgets)
+ qt_internal_add_example(terminal)
+ qt_internal_add_example(blockingsender)
+ qt_internal_add_example(blockingreceiver)
+endif()
diff --git a/examples/serialport/blockingmaster/dialog.h b/examples/serialport/blockingmaster/dialog.h
deleted file mode 100644
index 8d997fa..0000000
--- a/examples/serialport/blockingmaster/dialog.h
+++ /dev/null
@@ -1,99 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Denis Shienkov <denis.shienkov@gmail.com>
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtSerialPort module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef DIALOG_H
-#define DIALOG_H
-
-#include "masterthread.h"
-
-#include <QDialog>
-
-QT_BEGIN_NAMESPACE
-
-class QLabel;
-class QLineEdit;
-class QSpinBox;
-class QPushButton;
-class QComboBox;
-
-QT_END_NAMESPACE
-
-class Dialog : public QDialog
-{
- Q_OBJECT
-
-public:
- explicit Dialog(QWidget *parent = nullptr);
-
-private slots:
- void transaction();
- void showResponse(const QString &s);
- void processError(const QString &s);
- void processTimeout(const QString &s);
-
-private:
- void setControlsEnabled(bool enable);
-
-private:
- int m_transactionCount = 0;
- QLabel *m_serialPortLabel = nullptr;
- QComboBox *m_serialPortComboBox = nullptr;
- QLabel *m_waitResponseLabel = nullptr;
- QSpinBox *m_waitResponseSpinBox = nullptr;
- QLabel *m_requestLabel = nullptr;
- QLineEdit *m_requestLineEdit = nullptr;
- QLabel *m_trafficLabel = nullptr;
- QLabel *m_statusLabel = nullptr;
- QPushButton *m_runButton = nullptr;
-
- MasterThread m_thread;
-};
-
-#endif // DIALOG_H
diff --git a/examples/serialport/blockingmaster/main.cpp b/examples/serialport/blockingmaster/main.cpp
deleted file mode 100644
index 8e68c73..0000000
--- a/examples/serialport/blockingmaster/main.cpp
+++ /dev/null
@@ -1,61 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Denis Shienkov <denis.shienkov@gmail.com>
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtSerialPort module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "dialog.h"
-
-#include <QApplication>
-
-int main(int argc, char *argv[])
-{
- QApplication app(argc, argv);
- Dialog dialog;
- dialog.show();
- return app.exec();
-}
diff --git a/examples/serialport/blockingmaster/masterthread.h b/examples/serialport/blockingmaster/masterthread.h
deleted file mode 100644
index 9dc6048..0000000
--- a/examples/serialport/blockingmaster/masterthread.h
+++ /dev/null
@@ -1,86 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Denis Shienkov <denis.shienkov@gmail.com>
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtSerialPort module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef MASTERTHREAD_H
-#define MASTERTHREAD_H
-
-#include <QMutex>
-#include <QThread>
-#include <QWaitCondition>
-
-//! [0]
-class MasterThread : public QThread
-{
- Q_OBJECT
-
-public:
- explicit MasterThread(QObject *parent = nullptr);
- ~MasterThread();
-
- void transaction(const QString &portName, int waitTimeout, const QString &request);
-
-signals:
- void response(const QString &s);
- void error(const QString &s);
- void timeout(const QString &s);
-
-private:
- void run() override;
-
- QString m_portName;
- QString m_request;
- int m_waitTimeout = 0;
- QMutex m_mutex;
- QWaitCondition m_cond;
- bool m_quit = false;
-};
-//! [0]
-
-#endif // MASTERTHREAD_H
diff --git a/examples/serialport/blockingreceiver/CMakeLists.txt b/examples/serialport/blockingreceiver/CMakeLists.txt
new file mode 100644
index 0000000..b2db3fe
--- /dev/null
+++ b/examples/serialport/blockingreceiver/CMakeLists.txt
@@ -0,0 +1,39 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
+cmake_minimum_required(VERSION 3.16)
+project(blockingreceiver LANGUAGES CXX)
+
+if(NOT DEFINED INSTALL_EXAMPLESDIR)
+ set(INSTALL_EXAMPLESDIR "examples")
+endif()
+
+set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/serialport/blockingreceiver")
+
+find_package(Qt6 REQUIRED COMPONENTS Core Gui SerialPort Widgets)
+
+qt_standard_project_setup()
+
+qt_add_executable(blockingreceiver
+ dialog.cpp dialog.h
+ main.cpp
+ receiverthread.cpp receiverthread.h
+)
+
+set_target_properties(blockingreceiver PROPERTIES
+ WIN32_EXECUTABLE TRUE
+ MACOSX_BUNDLE TRUE
+)
+
+target_link_libraries(blockingreceiver PRIVATE
+ Qt::Core
+ Qt::Gui
+ Qt::SerialPort
+ Qt::Widgets
+)
+
+install(TARGETS blockingreceiver
+ RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
+ BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
+ LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
+)
diff --git a/examples/serialport/blockingslave/blockingslave.pro b/examples/serialport/blockingreceiver/blockingreceiver.pro
index 4e2a25d..378b069 100644
--- a/examples/serialport/blockingslave/blockingslave.pro
+++ b/examples/serialport/blockingreceiver/blockingreceiver.pro
@@ -1,17 +1,17 @@
QT += widgets serialport
requires(qtConfig(combobox))
-TARGET = blockingslave
+TARGET = blockingreceiver
TEMPLATE = app
HEADERS += \
dialog.h \
- slavethread.h
+ receiverthread.h
SOURCES += \
main.cpp \
dialog.cpp \
- slavethread.cpp
+ receiverthread.cpp
-target.path = $$[QT_INSTALL_EXAMPLES]/serialport/blockingslave
+target.path = $$[QT_INSTALL_EXAMPLES]/serialport/blockingreceiver
INSTALLS += target
diff --git a/examples/serialport/blockingreceiver/dialog.cpp b/examples/serialport/blockingreceiver/dialog.cpp
new file mode 100644
index 0000000..9beaf7e
--- /dev/null
+++ b/examples/serialport/blockingreceiver/dialog.cpp
@@ -0,0 +1,94 @@
+// Copyright (C) 2012 Denis Shienkov <denis.shienkov@gmail.com>
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#include "dialog.h"
+
+#include <QComboBox>
+#include <QGridLayout>
+#include <QLabel>
+#include <QLineEdit>
+#include <QPushButton>
+#include <QSerialPortInfo>
+#include <QSpinBox>
+
+Dialog::Dialog(QWidget *parent) :
+ QDialog(parent),
+ m_serialPortLabel(new QLabel(tr("Serial port:"))),
+ m_serialPortComboBox(new QComboBox),
+ m_waitRequestLabel(new QLabel(tr("Wait request, msec:"))),
+ m_waitRequestSpinBox(new QSpinBox),
+ m_responseLabel(new QLabel(tr("Response:"))),
+ m_responseLineEdit(new QLineEdit(tr("Hello, I'm the receiver."))),
+ m_trafficLabel(new QLabel(tr("No traffic."))),
+ m_statusLabel(new QLabel(tr("Status: Not running."))),
+ m_runButton(new QPushButton(tr("Start")))
+{
+ m_waitRequestSpinBox->setRange(0, 10000);
+ m_waitRequestSpinBox->setValue(10000);
+
+ const auto infos = QSerialPortInfo::availablePorts();
+ for (const QSerialPortInfo &info : infos)
+ m_serialPortComboBox->addItem(info.portName());
+
+ auto mainLayout = new QGridLayout;
+ mainLayout->addWidget(m_serialPortLabel, 0, 0);
+ mainLayout->addWidget(m_serialPortComboBox, 0, 1);
+ mainLayout->addWidget(m_waitRequestLabel, 1, 0);
+ mainLayout->addWidget(m_waitRequestSpinBox, 1, 1);
+ mainLayout->addWidget(m_runButton, 0, 2, 2, 1);
+ mainLayout->addWidget(m_responseLabel, 2, 0);
+ mainLayout->addWidget(m_responseLineEdit, 2, 1, 1, 3);
+ mainLayout->addWidget(m_trafficLabel, 3, 0, 1, 4);
+ mainLayout->addWidget(m_statusLabel, 4, 0, 1, 5);
+ setLayout(mainLayout);
+
+ setWindowTitle(tr("Blocking Receiver"));
+ m_serialPortComboBox->setFocus();
+
+ connect(m_runButton, &QPushButton::clicked, this, &Dialog::startReceiver);
+ connect(&m_thread, &ReceiverThread::request, this,&Dialog::showRequest);
+ connect(&m_thread, &ReceiverThread::error, this, &Dialog::processError);
+ connect(&m_thread, &ReceiverThread::timeout, this, &Dialog::processTimeout);
+
+ connect(m_serialPortComboBox, &QComboBox::currentIndexChanged, this, &Dialog::activateRunButton);
+ connect(m_waitRequestSpinBox, &QSpinBox::textChanged, this, &Dialog::activateRunButton);
+ connect(m_responseLineEdit, &QLineEdit::textChanged, this, &Dialog::activateRunButton);
+}
+
+void Dialog::startReceiver()
+{
+ m_runButton->setEnabled(false);
+ m_statusLabel->setText(tr("Status: Running, connected to port %1.")
+ .arg(m_serialPortComboBox->currentText()));
+ m_thread.startReceiver(m_serialPortComboBox->currentText(),
+ m_waitRequestSpinBox->value(),
+ m_responseLineEdit->text());
+}
+
+void Dialog::showRequest(const QString &s)
+{
+ m_trafficLabel->setText(tr("Traffic, transaction #%1:"
+ "\n\r-request: %2"
+ "\n\r-response: %3")
+ .arg(++m_transactionCount)
+ .arg(s)
+ .arg(m_responseLineEdit->text()));
+}
+
+void Dialog::processError(const QString &s)
+{
+ activateRunButton();
+ m_statusLabel->setText(tr("Status: Not running, %1.").arg(s));
+ m_trafficLabel->setText(tr("No traffic."));
+}
+
+void Dialog::processTimeout(const QString &s)
+{
+ m_statusLabel->setText(tr("Status: Running, %1.").arg(s));
+ m_trafficLabel->setText(tr("No traffic."));
+}
+
+void Dialog::activateRunButton()
+{
+ m_runButton->setEnabled(true);
+}
diff --git a/examples/serialport/blockingreceiver/dialog.h b/examples/serialport/blockingreceiver/dialog.h
new file mode 100644
index 0000000..4fe032b
--- /dev/null
+++ b/examples/serialport/blockingreceiver/dialog.h
@@ -0,0 +1,50 @@
+// Copyright (C) 2012 Denis Shienkov <denis.shienkov@gmail.com>
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#ifndef DIALOG_H
+#define DIALOG_H
+
+#include "receiverthread.h"
+
+#include <QDialog>
+
+QT_BEGIN_NAMESPACE
+
+class QLabel;
+class QLineEdit;
+class QComboBox;
+class QSpinBox;
+class QPushButton;
+
+QT_END_NAMESPACE
+
+class Dialog : public QDialog
+{
+ Q_OBJECT
+
+public:
+ explicit Dialog(QWidget *parent = nullptr);
+
+private slots:
+ void startReceiver();
+ void showRequest(const QString &s);
+ void processError(const QString &s);
+ void processTimeout(const QString &s);
+ void activateRunButton();
+
+private:
+ int m_transactionCount = 0;
+ QLabel *m_serialPortLabel = nullptr;
+ QComboBox *m_serialPortComboBox = nullptr;
+ QLabel *m_waitRequestLabel = nullptr;
+ QSpinBox *m_waitRequestSpinBox = nullptr;
+ QLabel *m_responseLabel = nullptr;
+ QLineEdit *m_responseLineEdit = nullptr;
+ QLabel *m_trafficLabel = nullptr;
+ QLabel *m_statusLabel = nullptr;
+ QPushButton *m_runButton = nullptr;
+
+ ReceiverThread m_thread;
+};
+
+#endif // DIALOG_H
diff --git a/examples/serialport/blockingreceiver/main.cpp b/examples/serialport/blockingreceiver/main.cpp
new file mode 100644
index 0000000..f08a0ee
--- /dev/null
+++ b/examples/serialport/blockingreceiver/main.cpp
@@ -0,0 +1,14 @@
+// Copyright (C) 2012 Denis Shienkov <denis.shienkov@gmail.com>
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#include "dialog.h"
+
+#include <QApplication>
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ Dialog dialog;
+ dialog.show();
+ return app.exec();
+}
diff --git a/examples/serialport/blockingreceiver/receiverthread.cpp b/examples/serialport/blockingreceiver/receiverthread.cpp
new file mode 100644
index 0000000..6d7f24e
--- /dev/null
+++ b/examples/serialport/blockingreceiver/receiverthread.cpp
@@ -0,0 +1,107 @@
+// Copyright (C) 2012 Denis Shienkov <denis.shienkov@gmail.com>
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#include "receiverthread.h"
+
+#include <QSerialPort>
+#include <QTime>
+
+ReceiverThread::ReceiverThread(QObject *parent) :
+ QThread(parent)
+{
+}
+
+//! [0]
+ReceiverThread::~ReceiverThread()
+{
+ m_mutex.lock();
+ m_quit = true;
+ m_mutex.unlock();
+ wait();
+}
+//! [0]
+
+//! [1] //! [2]
+void ReceiverThread::startReceiver(const QString &portName, int waitTimeout, const QString &response)
+{
+ //! [1]
+ const QMutexLocker locker(&m_mutex);
+ m_portName = portName;
+ m_waitTimeout = waitTimeout;
+ m_response = response;
+ //! [3]
+ if (!isRunning())
+ start();
+}
+//! [2] //! [3]
+
+//! [4]
+void ReceiverThread::run()
+{
+ bool currentPortNameChanged = false;
+
+ m_mutex.lock();
+//! [4] //! [5]
+ QString currentPortName;
+ if (currentPortName != m_portName) {
+ currentPortName = m_portName;
+ currentPortNameChanged = true;
+ }
+
+ int currentWaitTimeout = m_waitTimeout;
+ QString currentRespone = m_response;
+ m_mutex.unlock();
+//! [5] //! [6]
+ QSerialPort serial;
+
+ while (!m_quit) {
+//![6] //! [7]
+ if (currentPortNameChanged) {
+ serial.close();
+ serial.setPortName(currentPortName);
+
+ if (!serial.open(QIODevice::ReadWrite)) {
+ emit error(tr("Can't open %1, error code %2")
+ .arg(m_portName).arg(serial.error()));
+ return;
+ }
+ }
+
+ if (serial.waitForReadyRead(currentWaitTimeout)) {
+//! [7] //! [8]
+ // read request
+ QByteArray requestData = serial.readAll();
+ while (serial.waitForReadyRead(10))
+ requestData += serial.readAll();
+//! [8] //! [10]
+ // write response
+ const QByteArray responseData = currentRespone.toUtf8();
+ serial.write(responseData);
+ if (serial.waitForBytesWritten(m_waitTimeout)) {
+ const QString request = QString::fromUtf8(requestData);
+//! [12]
+ emit this->request(request);
+//! [10] //! [11] //! [12]
+ } else {
+ emit timeout(tr("Wait write response timeout %1")
+ .arg(QTime::currentTime().toString()));
+ }
+//! [9] //! [11]
+ } else {
+ emit timeout(tr("Wait read request timeout %1")
+ .arg(QTime::currentTime().toString()));
+ }
+//! [9] //! [13]
+ m_mutex.lock();
+ if (currentPortName != m_portName) {
+ currentPortName = m_portName;
+ currentPortNameChanged = true;
+ } else {
+ currentPortNameChanged = false;
+ }
+ currentWaitTimeout = m_waitTimeout;
+ currentRespone = m_response;
+ m_mutex.unlock();
+ }
+//! [13]
+}
diff --git a/examples/serialport/blockingreceiver/receiverthread.h b/examples/serialport/blockingreceiver/receiverthread.h
new file mode 100644
index 0000000..0950946
--- /dev/null
+++ b/examples/serialport/blockingreceiver/receiverthread.h
@@ -0,0 +1,38 @@
+// Copyright (C) 2012 Denis Shienkov <denis.shienkov@gmail.com>
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#ifndef RECEIVERTHREAD_H
+#define RECEIVERTHREAD_H
+
+#include <QMutex>
+#include <QThread>
+#include <QWaitCondition>
+
+//! [0]
+class ReceiverThread : public QThread
+{
+ Q_OBJECT
+
+public:
+ explicit ReceiverThread(QObject *parent = nullptr);
+ ~ReceiverThread();
+
+ void startReceiver(const QString &portName, int waitTimeout, const QString &response);
+
+signals:
+ void request(const QString &s);
+ void error(const QString &s);
+ void timeout(const QString &s);
+
+private:
+ void run() override;
+
+ QString m_portName;
+ QString m_response;
+ int m_waitTimeout = 0;
+ QMutex m_mutex;
+ bool m_quit = false;
+};
+//! [0]
+
+#endif // RECEIVERTHREAD_H
diff --git a/examples/serialport/blockingsender/CMakeLists.txt b/examples/serialport/blockingsender/CMakeLists.txt
new file mode 100644
index 0000000..d982aa4
--- /dev/null
+++ b/examples/serialport/blockingsender/CMakeLists.txt
@@ -0,0 +1,39 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
+cmake_minimum_required(VERSION 3.16)
+project(blockingsender LANGUAGES CXX)
+
+if(NOT DEFINED INSTALL_EXAMPLESDIR)
+ set(INSTALL_EXAMPLESDIR "examples")
+endif()
+
+set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/serialport/blockingsender")
+
+find_package(Qt6 REQUIRED COMPONENTS Core Gui SerialPort Widgets)
+
+qt_standard_project_setup()
+
+qt_add_executable(blockingsender
+ dialog.cpp dialog.h
+ main.cpp
+ senderthread.cpp senderthread.h
+)
+
+set_target_properties(blockingsender PROPERTIES
+ WIN32_EXECUTABLE TRUE
+ MACOSX_BUNDLE TRUE
+)
+
+target_link_libraries(blockingsender PRIVATE
+ Qt::Core
+ Qt::Gui
+ Qt::SerialPort
+ Qt::Widgets
+)
+
+install(TARGETS blockingsender
+ RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
+ BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
+ LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
+)
diff --git a/examples/serialport/blockingmaster/blockingmaster.pro b/examples/serialport/blockingsender/blockingsender.pro
index 8e3356b..41e6068 100644
--- a/examples/serialport/blockingmaster/blockingmaster.pro
+++ b/examples/serialport/blockingsender/blockingsender.pro
@@ -1,17 +1,17 @@
QT += widgets serialport
requires(qtConfig(combobox))
-TARGET = blockingmaster
+TARGET = blockingsender
TEMPLATE = app
HEADERS += \
dialog.h \
- masterthread.h
+ senderthread.h
SOURCES += \
main.cpp \
dialog.cpp \
- masterthread.cpp
+ senderthread.cpp
-target.path = $$[QT_INSTALL_EXAMPLES]/serialport/blockingmaster
+target.path = $$[QT_INSTALL_EXAMPLES]/serialport/blockingsender
INSTALLS += target
diff --git a/examples/serialport/blockingmaster/dialog.cpp b/examples/serialport/blockingsender/dialog.cpp
index 2617da7..dd7bee3 100644
--- a/examples/serialport/blockingmaster/dialog.cpp
+++ b/examples/serialport/blockingsender/dialog.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Denis Shienkov <denis.shienkov@gmail.com>
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtSerialPort module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2012 Denis Shienkov <denis.shienkov@gmail.com>
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "dialog.h"
@@ -89,13 +42,13 @@ Dialog::Dialog(QWidget *parent) :
mainLayout->addWidget(m_statusLabel, 4, 0, 1, 5);
setLayout(mainLayout);
- setWindowTitle(tr("Blocking Master"));
+ setWindowTitle(tr("Blocking Sender"));
m_serialPortComboBox->setFocus();
connect(m_runButton, &QPushButton::clicked, this, &Dialog::transaction);
- connect(&m_thread, &MasterThread::response, this, &Dialog::showResponse);
- connect(&m_thread, &MasterThread::error, this, &Dialog::processError);
- connect(&m_thread, &MasterThread::timeout, this, &Dialog::processTimeout);
+ connect(&m_thread, &SenderThread::response, this, &Dialog::showResponse);
+ connect(&m_thread, &SenderThread::error, this, &Dialog::processError);
+ connect(&m_thread, &SenderThread::timeout, this, &Dialog::processTimeout);
}
void Dialog::transaction()
diff --git a/examples/serialport/blockingsender/dialog.h b/examples/serialport/blockingsender/dialog.h
new file mode 100644
index 0000000..4d64be9
--- /dev/null
+++ b/examples/serialport/blockingsender/dialog.h
@@ -0,0 +1,52 @@
+// Copyright (C) 2012 Denis Shienkov <denis.shienkov@gmail.com>
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#ifndef DIALOG_H
+#define DIALOG_H
+
+#include "senderthread.h"
+
+#include <QDialog>
+
+QT_BEGIN_NAMESPACE
+
+class QLabel;
+class QLineEdit;
+class QSpinBox;
+class QPushButton;
+class QComboBox;
+
+QT_END_NAMESPACE
+
+class Dialog : public QDialog
+{
+ Q_OBJECT
+
+public:
+ explicit Dialog(QWidget *parent = nullptr);
+
+private slots:
+ void transaction();
+ void showResponse(const QString &s);
+ void processError(const QString &s);
+ void processTimeout(const QString &s);
+
+private:
+ void setControlsEnabled(bool enable);
+
+private:
+ int m_transactionCount = 0;
+ QLabel *m_serialPortLabel = nullptr;
+ QComboBox *m_serialPortComboBox = nullptr;
+ QLabel *m_waitResponseLabel = nullptr;
+ QSpinBox *m_waitResponseSpinBox = nullptr;
+ QLabel *m_requestLabel = nullptr;
+ QLineEdit *m_requestLineEdit = nullptr;
+ QLabel *m_trafficLabel = nullptr;
+ QLabel *m_statusLabel = nullptr;
+ QPushButton *m_runButton = nullptr;
+
+ SenderThread m_thread;
+};
+
+#endif // DIALOG_H
diff --git a/examples/serialport/blockingsender/main.cpp b/examples/serialport/blockingsender/main.cpp
new file mode 100644
index 0000000..f08a0ee
--- /dev/null
+++ b/examples/serialport/blockingsender/main.cpp
@@ -0,0 +1,14 @@
+// Copyright (C) 2012 Denis Shienkov <denis.shienkov@gmail.com>
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#include "dialog.h"
+
+#include <QApplication>
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ Dialog dialog;
+ dialog.show();
+ return app.exec();
+}
diff --git a/examples/serialport/blockingmaster/masterthread.cpp b/examples/serialport/blockingsender/senderthread.cpp
index 25aa848..055b965 100644
--- a/examples/serialport/blockingmaster/masterthread.cpp
+++ b/examples/serialport/blockingsender/senderthread.cpp
@@ -1,65 +1,18 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Denis Shienkov <denis.shienkov@gmail.com>
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtSerialPort module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2012 Denis Shienkov <denis.shienkov@gmail.com>
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-#include "masterthread.h"
+#include "senderthread.h"
#include <QSerialPort>
#include <QTime>
-MasterThread::MasterThread(QObject *parent) :
+SenderThread::SenderThread(QObject *parent) :
QThread(parent)
{
}
//! [0]
-MasterThread::~MasterThread()
+SenderThread::~SenderThread()
{
m_mutex.lock();
m_quit = true;
@@ -70,7 +23,7 @@ MasterThread::~MasterThread()
//! [0]
//! [1] //! [2]
-void MasterThread::transaction(const QString &portName, int waitTimeout, const QString &request)
+void SenderThread::transaction(const QString &portName, int waitTimeout, const QString &request)
{
//! [1]
const QMutexLocker locker(&m_mutex);
@@ -86,7 +39,7 @@ void MasterThread::transaction(const QString &portName, int waitTimeout, const Q
//! [2] //! [3]
//! [4]
-void MasterThread::run()
+void SenderThread::run()
{
bool currentPortNameChanged = false;
diff --git a/examples/serialport/blockingsender/senderthread.h b/examples/serialport/blockingsender/senderthread.h
new file mode 100644
index 0000000..1617014
--- /dev/null
+++ b/examples/serialport/blockingsender/senderthread.h
@@ -0,0 +1,39 @@
+// Copyright (C) 2012 Denis Shienkov <denis.shienkov@gmail.com>
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#ifndef SENDERTHREAD_H
+#define SENDERTHREAD_H
+
+#include <QMutex>
+#include <QThread>
+#include <QWaitCondition>
+
+//! [0]
+class SenderThread : public QThread
+{
+ Q_OBJECT
+
+public:
+ explicit SenderThread(QObject *parent = nullptr);
+ ~SenderThread();
+
+ void transaction(const QString &portName, int waitTimeout, const QString &request);
+
+signals:
+ void response(const QString &s);
+ void error(const QString &s);
+ void timeout(const QString &s);
+
+private:
+ void run() override;
+
+ QString m_portName;
+ QString m_request;
+ int m_waitTimeout = 0;
+ QMutex m_mutex;
+ QWaitCondition m_cond;
+ bool m_quit = false;
+};
+//! [0]
+
+#endif // SENDERTHREAD_H
diff --git a/examples/serialport/blockingslave/dialog.cpp b/examples/serialport/blockingslave/dialog.cpp
deleted file mode 100644
index fa7ce97..0000000
--- a/examples/serialport/blockingslave/dialog.cpp
+++ /dev/null
@@ -1,141 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Denis Shienkov <denis.shienkov@gmail.com>
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtSerialPort module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "dialog.h"
-
-#include <QComboBox>
-#include <QGridLayout>
-#include <QLabel>
-#include <QLineEdit>
-#include <QPushButton>
-#include <QSerialPortInfo>
-#include <QSpinBox>
-
-Dialog::Dialog(QWidget *parent) :
- QDialog(parent),
- m_serialPortLabel(new QLabel(tr("Serial port:"))),
- m_serialPortComboBox(new QComboBox),
- m_waitRequestLabel(new QLabel(tr("Wait request, msec:"))),
- m_waitRequestSpinBox(new QSpinBox),
- m_responseLabel(new QLabel(tr("Response:"))),
- m_responseLineEdit(new QLineEdit(tr("Hello, I'm Slave."))),
- m_trafficLabel(new QLabel(tr("No traffic."))),
- m_statusLabel(new QLabel(tr("Status: Not running."))),
- m_runButton(new QPushButton(tr("Start")))
-{
- m_waitRequestSpinBox->setRange(0, 10000);
- m_waitRequestSpinBox->setValue(10000);
-
- const auto infos = QSerialPortInfo::availablePorts();
- for (const QSerialPortInfo &info : infos)
- m_serialPortComboBox->addItem(info.portName());
-
- auto mainLayout = new QGridLayout;
- mainLayout->addWidget(m_serialPortLabel, 0, 0);
- mainLayout->addWidget(m_serialPortComboBox, 0, 1);
- mainLayout->addWidget(m_waitRequestLabel, 1, 0);
- mainLayout->addWidget(m_waitRequestSpinBox, 1, 1);
- mainLayout->addWidget(m_runButton, 0, 2, 2, 1);
- mainLayout->addWidget(m_responseLabel, 2, 0);
- mainLayout->addWidget(m_responseLineEdit, 2, 1, 1, 3);
- mainLayout->addWidget(m_trafficLabel, 3, 0, 1, 4);
- mainLayout->addWidget(m_statusLabel, 4, 0, 1, 5);
- setLayout(mainLayout);
-
- setWindowTitle(tr("Blocking Slave"));
- m_serialPortComboBox->setFocus();
-
- connect(m_runButton, &QPushButton::clicked, this, &Dialog::startSlave);
- connect(&m_thread, &SlaveThread::request, this,&Dialog::showRequest);
- connect(&m_thread, &SlaveThread::error, this, &Dialog::processError);
- connect(&m_thread, &SlaveThread::timeout, this, &Dialog::processTimeout);
-
- connect(m_serialPortComboBox, &QComboBox::currentIndexChanged, this, &Dialog::activateRunButton);
- connect(m_waitRequestSpinBox, &QSpinBox::textChanged, this, &Dialog::activateRunButton);
- connect(m_responseLineEdit, &QLineEdit::textChanged, this, &Dialog::activateRunButton);
-}
-
-void Dialog::startSlave()
-{
- m_runButton->setEnabled(false);
- m_statusLabel->setText(tr("Status: Running, connected to port %1.")
- .arg(m_serialPortComboBox->currentText()));
- m_thread.startSlave(m_serialPortComboBox->currentText(),
- m_waitRequestSpinBox->value(),
- m_responseLineEdit->text());
-}
-
-void Dialog::showRequest(const QString &s)
-{
- m_trafficLabel->setText(tr("Traffic, transaction #%1:"
- "\n\r-request: %2"
- "\n\r-response: %3")
- .arg(++m_transactionCount)
- .arg(s)
- .arg(m_responseLineEdit->text()));
-}
-
-void Dialog::processError(const QString &s)
-{
- activateRunButton();
- m_statusLabel->setText(tr("Status: Not running, %1.").arg(s));
- m_trafficLabel->setText(tr("No traffic."));
-}
-
-void Dialog::processTimeout(const QString &s)
-{
- m_statusLabel->setText(tr("Status: Running, %1.").arg(s));
- m_trafficLabel->setText(tr("No traffic."));
-}
-
-void Dialog::activateRunButton()
-{
- m_runButton->setEnabled(true);
-}
diff --git a/examples/serialport/blockingslave/dialog.h b/examples/serialport/blockingslave/dialog.h
deleted file mode 100644
index c8f80a6..0000000
--- a/examples/serialport/blockingslave/dialog.h
+++ /dev/null
@@ -1,97 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Denis Shienkov <denis.shienkov@gmail.com>
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtSerialPort module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef DIALOG_H
-#define DIALOG_H
-
-#include "slavethread.h"
-
-#include <QDialog>
-
-QT_BEGIN_NAMESPACE
-
-class QLabel;
-class QLineEdit;
-class QComboBox;
-class QSpinBox;
-class QPushButton;
-
-QT_END_NAMESPACE
-
-class Dialog : public QDialog
-{
- Q_OBJECT
-
-public:
- explicit Dialog(QWidget *parent = nullptr);
-
-private slots:
- void startSlave();
- void showRequest(const QString &s);
- void processError(const QString &s);
- void processTimeout(const QString &s);
- void activateRunButton();
-
-private:
- int m_transactionCount = 0;
- QLabel *m_serialPortLabel = nullptr;
- QComboBox *m_serialPortComboBox = nullptr;
- QLabel *m_waitRequestLabel = nullptr;
- QSpinBox *m_waitRequestSpinBox = nullptr;
- QLabel *m_responseLabel = nullptr;
- QLineEdit *m_responseLineEdit = nullptr;
- QLabel *m_trafficLabel = nullptr;
- QLabel *m_statusLabel = nullptr;
- QPushButton *m_runButton = nullptr;
-
- SlaveThread m_thread;
-};
-
-#endif // DIALOG_H
diff --git a/examples/serialport/blockingslave/main.cpp b/examples/serialport/blockingslave/main.cpp
deleted file mode 100644
index 8e68c73..0000000
--- a/examples/serialport/blockingslave/main.cpp
+++ /dev/null
@@ -1,61 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Denis Shienkov <denis.shienkov@gmail.com>
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtSerialPort module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "dialog.h"
-
-#include <QApplication>
-
-int main(int argc, char *argv[])
-{
- QApplication app(argc, argv);
- Dialog dialog;
- dialog.show();
- return app.exec();
-}
diff --git a/examples/serialport/blockingslave/slavethread.cpp b/examples/serialport/blockingslave/slavethread.cpp
deleted file mode 100644
index 85b010a..0000000
--- a/examples/serialport/blockingslave/slavethread.cpp
+++ /dev/null
@@ -1,154 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Denis Shienkov <denis.shienkov@gmail.com>
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtSerialPort module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "slavethread.h"
-
-#include <QSerialPort>
-#include <QTime>
-
-SlaveThread::SlaveThread(QObject *parent) :
- QThread(parent)
-{
-}
-
-//! [0]
-SlaveThread::~SlaveThread()
-{
- m_mutex.lock();
- m_quit = true;
- m_mutex.unlock();
- wait();
-}
-//! [0]
-
-//! [1] //! [2]
-void SlaveThread::startSlave(const QString &portName, int waitTimeout, const QString &response)
-{
- //! [1]
- const QMutexLocker locker(&m_mutex);
- m_portName = portName;
- m_waitTimeout = waitTimeout;
- m_response = response;
- //! [3]
- if (!isRunning())
- start();
-}
-//! [2] //! [3]
-
-//! [4]
-void SlaveThread::run()
-{
- bool currentPortNameChanged = false;
-
- m_mutex.lock();
-//! [4] //! [5]
- QString currentPortName;
- if (currentPortName != m_portName) {
- currentPortName = m_portName;
- currentPortNameChanged = true;
- }
-
- int currentWaitTimeout = m_waitTimeout;
- QString currentRespone = m_response;
- m_mutex.unlock();
-//! [5] //! [6]
- QSerialPort serial;
-
- while (!m_quit) {
-//![6] //! [7]
- if (currentPortNameChanged) {
- serial.close();
- serial.setPortName(currentPortName);
-
- if (!serial.open(QIODevice::ReadWrite)) {
- emit error(tr("Can't open %1, error code %2")
- .arg(m_portName).arg(serial.error()));
- return;
- }
- }
-
- if (serial.waitForReadyRead(currentWaitTimeout)) {
-//! [7] //! [8]
- // read request
- QByteArray requestData = serial.readAll();
- while (serial.waitForReadyRead(10))
- requestData += serial.readAll();
-//! [8] //! [10]
- // write response
- const QByteArray responseData = currentRespone.toUtf8();
- serial.write(responseData);
- if (serial.waitForBytesWritten(m_waitTimeout)) {
- const QString request = QString::fromUtf8(requestData);
-//! [12]
- emit this->request(request);
-//! [10] //! [11] //! [12]
- } else {
- emit timeout(tr("Wait write response timeout %1")
- .arg(QTime::currentTime().toString()));
- }
-//! [9] //! [11]
- } else {
- emit timeout(tr("Wait read request timeout %1")
- .arg(QTime::currentTime().toString()));
- }
-//! [9] //! [13]
- m_mutex.lock();
- if (currentPortName != m_portName) {
- currentPortName = m_portName;
- currentPortNameChanged = true;
- } else {
- currentPortNameChanged = false;
- }
- currentWaitTimeout = m_waitTimeout;
- currentRespone = m_response;
- m_mutex.unlock();
- }
-//! [13]
-}
diff --git a/examples/serialport/blockingslave/slavethread.h b/examples/serialport/blockingslave/slavethread.h
deleted file mode 100644
index 737e7cb..0000000
--- a/examples/serialport/blockingslave/slavethread.h
+++ /dev/null
@@ -1,85 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Denis Shienkov <denis.shienkov@gmail.com>
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtSerialPort module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef SLAVETHREAD_H
-#define SLAVETHREAD_H
-
-#include <QMutex>
-#include <QThread>
-#include <QWaitCondition>
-
-//! [0]
-class SlaveThread : public QThread
-{
- Q_OBJECT
-
-public:
- explicit SlaveThread(QObject *parent = nullptr);
- ~SlaveThread();
-
- void startSlave(const QString &portName, int waitTimeout, const QString &response);
-
-signals:
- void request(const QString &s);
- void error(const QString &s);
- void timeout(const QString &s);
-
-private:
- void run() override;
-
- QString m_portName;
- QString m_response;
- int m_waitTimeout = 0;
- QMutex m_mutex;
- bool m_quit = false;
-};
-//! [0]
-
-#endif // SLAVETHREAD_H
diff --git a/examples/serialport/cenumerator/cenumerator.pro b/examples/serialport/cenumerator/cenumerator.pro
deleted file mode 100644
index 75a43e3..0000000
--- a/examples/serialport/cenumerator/cenumerator.pro
+++ /dev/null
@@ -1,14 +0,0 @@
-QT = core
-QT += serialport
-
-CONFIG += console
-CONFIG -= app_bundle
-
-TARGET = cenumerator
-TEMPLATE = app
-
-SOURCES += \
- main.cpp
-
-target.path = $$[QT_INSTALL_EXAMPLES]/serialport/cenumerator
-INSTALLS += target
diff --git a/examples/serialport/cenumerator/main.cpp b/examples/serialport/cenumerator/main.cpp
deleted file mode 100644
index 05a3715..0000000
--- a/examples/serialport/cenumerator/main.cpp
+++ /dev/null
@@ -1,87 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Laszlo Papp <lpapp@kde.org>
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtSerialPort module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QCoreApplication>
-#include <QSerialPortInfo>
-#include <QTextStream>
-
-int main(int argc, char *argv[])
-{
- QCoreApplication coreApplication(argc, argv);
- QTextStream out(stdout);
- const auto serialPortInfos = QSerialPortInfo::availablePorts();
-
- out << "Total number of ports available: " << serialPortInfos.count() << Qt::endl;
-
- const QString blankString = "N/A";
- QString description;
- QString manufacturer;
- QString serialNumber;
-
- for (const QSerialPortInfo &serialPortInfo : serialPortInfos) {
- description = serialPortInfo.description();
- manufacturer = serialPortInfo.manufacturer();
- serialNumber = serialPortInfo.serialNumber();
- out << Qt::endl
- << "Port: " << serialPortInfo.portName() << Qt::endl
- << "Location: " << serialPortInfo.systemLocation() << Qt::endl
- << "Description: " << (!description.isEmpty() ? description : blankString) << Qt::endl
- << "Manufacturer: " << (!manufacturer.isEmpty() ? manufacturer : blankString) << Qt::endl
- << "Serial number: " << (!serialNumber.isEmpty() ? serialNumber : blankString) << Qt::endl
- << "Vendor Identifier: " << (serialPortInfo.hasVendorIdentifier()
- ? QByteArray::number(serialPortInfo.vendorIdentifier(), 16)
- : blankString) << Qt::endl
- << "Product Identifier: " << (serialPortInfo.hasProductIdentifier()
- ? QByteArray::number(serialPortInfo.productIdentifier(), 16)
- : blankString) << Qt::endl;
- }
-
- return 0;
-}
diff --git a/examples/serialport/creaderasync/creaderasync.pro b/examples/serialport/creaderasync/creaderasync.pro
deleted file mode 100644
index 38d8b52..0000000
--- a/examples/serialport/creaderasync/creaderasync.pro
+++ /dev/null
@@ -1,18 +0,0 @@
-QT = core
-QT += serialport
-
-CONFIG += console
-CONFIG -= app_bundle
-
-TARGET = creaderasync
-TEMPLATE = app
-
-HEADERS += \
- serialportreader.h
-
-SOURCES += \
- main.cpp \
- serialportreader.cpp
-
-target.path = $$[QT_INSTALL_EXAMPLES]/serialport/creaderasync
-INSTALLS += target
diff --git a/examples/serialport/creaderasync/main.cpp b/examples/serialport/creaderasync/main.cpp
deleted file mode 100644
index 5e98bde..0000000
--- a/examples/serialport/creaderasync/main.cpp
+++ /dev/null
@@ -1,92 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2013 Laszlo Papp <lpapp@kde.org>
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtSerialPort module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "serialportreader.h"
-
-#include <QCoreApplication>
-#include <QSerialPort>
-#include <QStringList>
-#include <QTextStream>
-
-int main(int argc, char *argv[])
-{
- QCoreApplication coreApplication(argc, argv);
- const int argumentCount = QCoreApplication::arguments().size();
- const QStringList argumentList = QCoreApplication::arguments();
-
- QTextStream standardOutput(stdout);
-
- if (argumentCount == 1) {
- standardOutput << QObject::tr("Usage: %1 <serialportname> [baudrate]")
- .arg(argumentList.first())
- << Qt::endl;
- return 1;
- }
-
- QSerialPort serialPort;
- const QString serialPortName = argumentList.at(1);
- serialPort.setPortName(serialPortName);
-
- const int serialPortBaudRate = (argumentCount > 2)
- ? argumentList.at(2).toInt() : QSerialPort::Baud9600;
- serialPort.setBaudRate(serialPortBaudRate);
-
- if (!serialPort.open(QIODevice::ReadOnly)) {
- standardOutput << QObject::tr("Failed to open port %1, error: %2")
- .arg(serialPortName)
- .arg(serialPort.errorString())
- << Qt::endl;
- return 1;
- }
-
- SerialPortReader serialPortReader(&serialPort);
-
- return coreApplication.exec();
-}
diff --git a/examples/serialport/creaderasync/serialportreader.cpp b/examples/serialport/creaderasync/serialportreader.cpp
deleted file mode 100644
index dd683d5..0000000
--- a/examples/serialport/creaderasync/serialportreader.cpp
+++ /dev/null
@@ -1,102 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2013 Laszlo Papp <lpapp@kde.org>
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtSerialPort module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "serialportreader.h"
-
-#include <QCoreApplication>
-
-SerialPortReader::SerialPortReader(QSerialPort *serialPort, QObject *parent) :
- QObject(parent),
- m_serialPort(serialPort),
- m_standardOutput(stdout)
-{
- connect(m_serialPort, &QSerialPort::readyRead, this, &SerialPortReader::handleReadyRead);
- connect(m_serialPort, &QSerialPort::errorOccurred, this, &SerialPortReader::handleError);
- connect(&m_timer, &QTimer::timeout, this, &SerialPortReader::handleTimeout);
-
- m_timer.start(5000);
-}
-
-void SerialPortReader::handleReadyRead()
-{
- m_readData.append(m_serialPort->readAll());
-
- if (!m_timer.isActive())
- m_timer.start(5000);
-}
-
-void SerialPortReader::handleTimeout()
-{
- if (m_readData.isEmpty()) {
- m_standardOutput << QObject::tr("No data was currently available "
- "for reading from port %1")
- .arg(m_serialPort->portName())
- << Qt::endl;
- } else {
- m_standardOutput << QObject::tr("Data successfully received from port %1")
- .arg(m_serialPort->portName())
- << Qt::endl;
- m_standardOutput << m_readData << Qt::endl;
- }
-
- QCoreApplication::quit();
-}
-
-void SerialPortReader::handleError(QSerialPort::SerialPortError serialPortError)
-{
- if (serialPortError == QSerialPort::ReadError) {
- m_standardOutput << QObject::tr("An I/O error occurred while reading "
- "the data from port %1, error: %2")
- .arg(m_serialPort->portName())
- .arg(m_serialPort->errorString())
- << Qt::endl;
- QCoreApplication::exit(1);
- }
-}
diff --git a/examples/serialport/creaderasync/serialportreader.h b/examples/serialport/creaderasync/serialportreader.h
deleted file mode 100644
index 53074f1..0000000
--- a/examples/serialport/creaderasync/serialportreader.h
+++ /dev/null
@@ -1,82 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2013 Laszlo Papp <lpapp@kde.org>
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtSerialPort module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef SERIALPORTREADER_H
-#define SERIALPORTREADER_H
-
-#include <QByteArray>
-#include <QSerialPort>
-#include <QTextStream>
-#include <QTimer>
-
-QT_BEGIN_NAMESPACE
-
-QT_END_NAMESPACE
-
-class SerialPortReader : public QObject
-{
- Q_OBJECT
-
-public:
- explicit SerialPortReader(QSerialPort *serialPort, QObject *parent = nullptr);
-
-private slots:
- void handleReadyRead();
- void handleTimeout();
- void handleError(QSerialPort::SerialPortError error);
-
-private:
- QSerialPort *m_serialPort = nullptr;
- QByteArray m_readData;
- QTextStream m_standardOutput;
- QTimer m_timer;
-};
-
-#endif // SERIALPORTREADER_H
diff --git a/examples/serialport/creadersync/creadersync.pro b/examples/serialport/creadersync/creadersync.pro
deleted file mode 100644
index a2690aa..0000000
--- a/examples/serialport/creadersync/creadersync.pro
+++ /dev/null
@@ -1,14 +0,0 @@
-QT = core
-QT += serialport
-
-CONFIG += console
-CONFIG -= app_bundle
-
-TARGET = creadersync
-TEMPLATE = app
-
-SOURCES += \
- main.cpp
-
-target.path = $$[QT_INSTALL_EXAMPLES]/serialport/creadersync
-INSTALLS += target
diff --git a/examples/serialport/creadersync/main.cpp b/examples/serialport/creadersync/main.cpp
deleted file mode 100644
index 7c7c150..0000000
--- a/examples/serialport/creadersync/main.cpp
+++ /dev/null
@@ -1,104 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2013 Laszlo Papp <lpapp@kde.org>
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtSerialPort module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QCoreApplication>
-#include <QSerialPort>
-#include <QStringList>
-#include <QTextStream>
-
-int main(int argc, char *argv[])
-{
- QCoreApplication coreApplication(argc, argv);
- const int argumentCount = QCoreApplication::arguments().size();
- const QStringList argumentList = QCoreApplication::arguments();
-
- QTextStream standardOutput(stdout);
-
- if (argumentCount == 1) {
- standardOutput << QObject::tr("Usage: %1 <serialportname> [baudrate]")
- .arg(argumentList.first()) << Qt::endl;
- return 1;
- }
-
- QSerialPort serialPort;
- const QString serialPortName = argumentList.at(1);
- serialPort.setPortName(serialPortName);
-
- const int serialPortBaudRate = (argumentCount > 2)
- ? argumentList.at(2).toInt() : QSerialPort::Baud9600;
- serialPort.setBaudRate(serialPortBaudRate);
-
- if (!serialPort.open(QIODevice::ReadOnly)) {
- standardOutput << QObject::tr("Failed to open port %1, error: %2")
- .arg(serialPortName).arg(serialPort.error()) << Qt::endl;
- return 1;
- }
-
- QByteArray readData = serialPort.readAll();
- while (serialPort.waitForReadyRead(5000))
- readData.append(serialPort.readAll());
-
- if (serialPort.error() == QSerialPort::ReadError) {
- standardOutput << QObject::tr("Failed to read from port %1, error: %2")
- .arg(serialPortName).arg(serialPort.errorString()) << Qt::endl;
- return 1;
- } else if (serialPort.error() == QSerialPort::TimeoutError && readData.isEmpty()) {
- standardOutput << QObject::tr("No data was currently available"
- " for reading from port %1")
- .arg(serialPortName) << Qt::endl;
- return 0;
- }
-
- standardOutput << QObject::tr("Data successfully received from port %1")
- .arg(serialPortName) << Qt::endl;
- standardOutput << readData << Qt::endl;
-
- return 0;
-}
diff --git a/examples/serialport/cwriterasync/cwriterasync.pro b/examples/serialport/cwriterasync/cwriterasync.pro
deleted file mode 100644
index f6105bc..0000000
--- a/examples/serialport/cwriterasync/cwriterasync.pro
+++ /dev/null
@@ -1,18 +0,0 @@
-QT = core
-QT += serialport
-
-CONFIG += console
-CONFIG -= app_bundle
-
-TARGET = cwriterasync
-TEMPLATE = app
-
-HEADERS += \
- serialportwriter.h
-
-SOURCES += \
- main.cpp \
- serialportwriter.cpp
-
-target.path = $$[QT_INSTALL_EXAMPLES]/serialport/cwriterasync
-INSTALLS += target
diff --git a/examples/serialport/cwriterasync/main.cpp b/examples/serialport/cwriterasync/main.cpp
deleted file mode 100644
index 763b18a..0000000
--- a/examples/serialport/cwriterasync/main.cpp
+++ /dev/null
@@ -1,104 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2013 Laszlo Papp <lpapp@kde.org>
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtSerialPort module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "serialportwriter.h"
-
-#include <QCoreApplication>
-#include <QFile>
-#include <QSerialPort>
-#include <QStringList>
-#include <QTextStream>
-
-int main(int argc, char *argv[])
-{
- QCoreApplication coreApplication(argc, argv);
- const int argumentCount = QCoreApplication::arguments().size();
- const QStringList argumentList = QCoreApplication::arguments();
-
- QTextStream standardOutput(stdout);
-
- if (argumentCount == 1) {
- standardOutput << QObject::tr("Usage: %1 <serialportname> [baudrate]")
- .arg(argumentList.first()) << Qt::endl;
- return 1;
- }
-
- QSerialPort serialPort;
- const QString serialPortName = argumentList.at(1);
- serialPort.setPortName(serialPortName);
-
- const int serialPortBaudRate = (argumentCount > 2)
- ? argumentList.at(2).toInt() : QSerialPort::Baud9600;
- serialPort.setBaudRate(serialPortBaudRate);
-
- serialPort.open(QIODevice::WriteOnly);
-
- QFile dataFile;
- if (!dataFile.open(stdin, QIODevice::ReadOnly)) {
- standardOutput << QObject::tr("Failed to open stdin for reading") << Qt::endl;
- return 1;
- }
-
- const QByteArray writeData(dataFile.readAll());
- dataFile.close();
-
- if (writeData.isEmpty()) {
- standardOutput << QObject::tr("Either no data was currently available on "
- "the standard input for reading, "
- "or an error occurred for port %1, error: %2")
- .arg(serialPortName).arg(serialPort.errorString()) << Qt::endl;
- return 1;
- }
-
- SerialPortWriter serialPortWriter(&serialPort);
- serialPortWriter.write(writeData);
-
- return coreApplication.exec();
-}
diff --git a/examples/serialport/cwriterasync/serialportwriter.cpp b/examples/serialport/cwriterasync/serialportwriter.cpp
deleted file mode 100644
index 489370e..0000000
--- a/examples/serialport/cwriterasync/serialportwriter.cpp
+++ /dev/null
@@ -1,121 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2013 Laszlo Papp <lpapp@kde.org>
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtSerialPort module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "serialportwriter.h"
-
-#include <QCoreApplication>
-
-SerialPortWriter::SerialPortWriter(QSerialPort *serialPort, QObject *parent) :
- QObject(parent),
- m_serialPort(serialPort),
- m_standardOutput(stdout)
-{
- m_timer.setSingleShot(true);
- connect(m_serialPort, &QSerialPort::bytesWritten,
- this, &SerialPortWriter::handleBytesWritten);
- connect(m_serialPort, &QSerialPort::errorOccurred,
- this, &SerialPortWriter::handleError);
- connect(&m_timer, &QTimer::timeout, this, &SerialPortWriter::handleTimeout);
-}
-
-void SerialPortWriter::handleBytesWritten(qint64 bytes)
-{
- m_bytesWritten += bytes;
- if (m_bytesWritten == m_writeData.size()) {
- m_bytesWritten = 0;
- m_standardOutput << QObject::tr("Data successfully sent to port %1")
- .arg(m_serialPort->portName()) << Qt::endl;
- QCoreApplication::quit();
- }
-}
-
-void SerialPortWriter::handleTimeout()
-{
- m_standardOutput << QObject::tr("Operation timed out for port %1, error: %2")
- .arg(m_serialPort->portName())
- .arg(m_serialPort->errorString())
- << Qt::endl;
- QCoreApplication::exit(1);
-}
-
-void SerialPortWriter::handleError(QSerialPort::SerialPortError serialPortError)
-{
- if (serialPortError == QSerialPort::WriteError) {
- m_standardOutput << QObject::tr("An I/O error occurred while writing"
- " the data to port %1, error: %2")
- .arg(m_serialPort->portName())
- .arg(m_serialPort->errorString())
- << Qt::endl;
- QCoreApplication::exit(1);
- }
-}
-
-void SerialPortWriter::write(const QByteArray &writeData)
-{
- m_writeData = writeData;
-
- const qint64 bytesWritten = m_serialPort->write(writeData);
-
- if (bytesWritten == -1) {
- m_standardOutput << QObject::tr("Failed to write the data to port %1, error: %2")
- .arg(m_serialPort->portName())
- .arg(m_serialPort->errorString())
- << Qt::endl;
- QCoreApplication::exit(1);
- } else if (bytesWritten != m_writeData.size()) {
- m_standardOutput << QObject::tr("Failed to write all the data to port %1, error: %2")
- .arg(m_serialPort->portName())
- .arg(m_serialPort->errorString())
- << Qt::endl;
- QCoreApplication::exit(1);
- }
-
- m_timer.start(5000);
-}
diff --git a/examples/serialport/cwriterasync/serialportwriter.h b/examples/serialport/cwriterasync/serialportwriter.h
deleted file mode 100644
index 1e94c0f..0000000
--- a/examples/serialport/cwriterasync/serialportwriter.h
+++ /dev/null
@@ -1,85 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2013 Laszlo Papp <lpapp@kde.org>
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtSerialPort module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef SERIALPORTWRITER_H
-#define SERIALPORTWRITER_H
-
-#include <QByteArray>
-#include <QObject>
-#include <QSerialPort>
-#include <QTextStream>
-#include <QTimer>
-
-QT_BEGIN_NAMESPACE
-
-QT_END_NAMESPACE
-
-class SerialPortWriter : public QObject
-{
- Q_OBJECT
-
-public:
- explicit SerialPortWriter(QSerialPort *serialPort, QObject *parent = nullptr);
- void write(const QByteArray &writeData);
-
-private slots:
- void handleBytesWritten(qint64 bytes);
- void handleTimeout();
- void handleError(QSerialPort::SerialPortError error);
-
-private:
- QSerialPort *m_serialPort = nullptr;
- QByteArray m_writeData;
- QTextStream m_standardOutput;
- qint64 m_bytesWritten = 0;
- QTimer m_timer;
-};
-
-#endif // SERIALPORTWRITER_H
diff --git a/examples/serialport/cwritersync/cwritersync.pro b/examples/serialport/cwritersync/cwritersync.pro
deleted file mode 100644
index 1e0996d..0000000
--- a/examples/serialport/cwritersync/cwritersync.pro
+++ /dev/null
@@ -1,14 +0,0 @@
-QT = core
-QT += serialport
-
-CONFIG += console
-CONFIG -= app_bundle
-
-TARGET = cwritersync
-TEMPLATE = app
-
-SOURCES += \
- main.cpp
-
-target.path = $$[QT_INSTALL_EXAMPLES]/serialport/cwritersync
-INSTALLS += target
diff --git a/examples/serialport/cwritersync/main.cpp b/examples/serialport/cwritersync/main.cpp
deleted file mode 100644
index 9d4511a..0000000
--- a/examples/serialport/cwritersync/main.cpp
+++ /dev/null
@@ -1,125 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2013 Laszlo Papp <lpapp@kde.org>
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtSerialPort module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QCoreApplication>
-#include <QFile>
-#include <QSerialPort>
-#include <QStringList>
-#include <QTextStream>
-
-int main(int argc, char *argv[])
-{
- QCoreApplication coreApplication(argc, argv);
- const int argumentCount = QCoreApplication::arguments().size();
- const QStringList argumentList = QCoreApplication::arguments();
-
- QTextStream standardOutput(stdout);
-
- if (argumentCount == 1) {
- standardOutput << QObject::tr("Usage: %1 <serialportname> [baudrate]")
- .arg(argumentList.first()) << Qt::endl;
- return 1;
- }
-
- QSerialPort serialPort;
- const QString serialPortName = argumentList.at(1);
- serialPort.setPortName(serialPortName);
-
- const int serialPortBaudRate = (argumentCount > 2)
- ? argumentList.at(2).toInt() : QSerialPort::Baud9600;
- serialPort.setBaudRate(serialPortBaudRate);
-
- if (!serialPort.open(QIODevice::WriteOnly)) {
- standardOutput << QObject::tr("Failed to open port %1, error: %2")
- .arg(serialPortName).arg(serialPort.errorString())
- << Qt::endl;
- return 1;
- }
-
- QFile dataFile;
- if (!dataFile.open(stdin, QIODevice::ReadOnly)) {
- standardOutput << QObject::tr("Failed to open stdin for reading")
- << Qt::endl;
- return 1;
- }
-
- QByteArray writeData(dataFile.readAll());
- dataFile.close();
-
- if (writeData.isEmpty()) {
- standardOutput << QObject::tr("Either no data was currently available on "
- "the standard input for reading, or an error "
- "occurred for port %1, error: %2")
- .arg(serialPortName).arg(serialPort.errorString()) << Qt::endl;
- return 1;
- }
-
- const qint64 bytesWritten = serialPort.write(writeData);
-
- if (bytesWritten == -1) {
- standardOutput << QObject::tr("Failed to write the data to port %1, error: %2")
- .arg(serialPortName).arg(serialPort.errorString()) << Qt::endl;
- return 1;
- } else if (bytesWritten != writeData.size()) {
- standardOutput << QObject::tr("Failed to write all the data to port %1, error: %2")
- .arg(serialPortName).arg(serialPort.errorString()) << Qt::endl;
- return 1;
- } else if (!serialPort.waitForBytesWritten(5000)) {
- standardOutput << QObject::tr("Operation timed out or an error "
- "occurred for port %1, error: %2")
- .arg(serialPortName).arg(serialPort.errorString()) << Qt::endl;
- return 1;
- }
-
- standardOutput << QObject::tr("Data successfully sent to port %1")
- .arg(serialPortName) << Qt::endl;
-
- return 0;
-}
diff --git a/examples/serialport/doc/blockingslave.qdoc b/examples/serialport/doc/blockingreceiver.qdoc
index f15f8e3..71a2084 100644
--- a/examples/serialport/doc/blockingslave.qdoc
+++ b/examples/serialport/doc/blockingreceiver.qdoc
@@ -1,41 +1,19 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 - 2012 Denis Shienkov <denis.shienkov@gmail.com>
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2011 - 2012 Denis Shienkov <denis.shienkov@gmail.com>
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
- \example blockingslave
- \title Blocking Slave Example
+ \example blockingreceiver
+ \title Blocking Receiver
\ingroup qtserialport-examples
+ \examplecategory Connectivity
+
\brief Shows how to use the synchronous API of QSerialPort in a non-GUI thread.
- \e{Blocking Slave} shows how to create an application for a serial interface
+ \e{Blocking Receiver} shows how to create an application for a serial interface
using QSerialPort's synchronous API in a non-GUI thread.
- \image blockingslave-example.png
+ \image blockingreceiver-example.png
QSerialPort supports two general programming approaches:
@@ -66,55 +44,55 @@
But contrary to what many think, using threads with QThread does not
necessarily add unmanageable complexity to your application.
- This application is a Slave, that demonstrate the work paired with Master
- application \l{Blocking Master Example}.
+ This application is a Receiver, that demonstrate the work paired with the
+ sender application \l{blockingsender}{Blocking Sender example}.
- The Slave application is receives the request via serial port from
- the Master application and send a response to it.
+ The Receiver application receives the request via serial port from
+ the Sender application and send a response to it.
- We will start with the SlaveThread class, which handles the serial
+ We will start with the ReceiverThread class, which handles the serial
programming code.
- \snippet blockingslave/slavethread.h 0
+ \snippet blockingreceiver/receiverthread.h 0
- SlaveThread is a QThread subclass that provides an API for receive requests
- from Master, and it has signals for delivering responses and reporting
+ ReceiverThread is a QThread subclass that provides an API for receive requests
+ from Sender, and it has signals for delivering responses and reporting
errors.
- You should be call startSlave() to startup Slave application. This method
- transfers to the SlaveThread desired parameters for configure and startup
- the serial interface. When SlaveThread received from Master any request then
+ You should call startReceiver() to startup Receiver application. This method
+ transfers to the ReceiverThread desired parameters for configure and startup
+ the serial interface. When ReceiverThread received from Sender any request then
emitted the request() signal. If any error occurs, the error() or timeout()
signals is emitted.
- It's important to notice that startSlave() is called from the main, GUI
+ It's important to notice that startReceiver() is called from the main, GUI
thread, but the response data and other parameters will be accessed from
- SlaveThread's thread. SlaveThread's data members are read and written
+ ReceiverThread's thread. ReceiverThread's data members are read and written
from different threads concurrently, so it is advisable to use QMutex to
synchronize access.
- \snippet blockingslave/slavethread.cpp 2
+ \snippet blockingreceiver/receiverthread.cpp 2
- The startSlave() function stores the serial port name, timeout and response
+ The startReceiver() function stores the serial port name, timeout and response
data, and QMutexLocker locks the mutex to protect these data. We then
start the thread, unless it is already running. QWaitCondition::wakeOne()
will be discussed later.
- \snippet blockingslave/slavethread.cpp 4
- \snippet blockingslave/slavethread.cpp 5
+ \snippet blockingreceiver/receiverthread.cpp 4
+ \snippet blockingreceiver/receiverthread.cpp 5
In the run() function, start by acquiring the mutex lock, fetch the
serial port name, timeout and response data from the member data, and then
- release the lock again. Under no circumstance should the method \c startSlave()
+ release the lock again. Under no circumstance should the method \c startReceiver()
be called simultaneously with a process fetching these data. QString is reentrant
but not thread-safe, and it is not recommended to read the serial port name
- from one startup, call and timeout or response data of another. SlaveThread
+ from one startup, call and timeout or response data of another. ReceiverThread
can only handle one startup at a time.
The QSerialPort object we construct on stack into run() function before loop
enter:
- \snippet blockingslave/slavethread.cpp 6
+ \snippet blockingreceiver/receiverthread.cpp 6
This allows us once to create an object, while running loop, and also means
that all the methods of the object will be executed in the context of the
@@ -123,24 +101,24 @@
In the loop, check whether the name of the serial port for the current
startup has changed or not. If it has, re-open and reconfigure the serial port.
- \snippet blockingslave/slavethread.cpp 7
+ \snippet blockingreceiver/receiverthread.cpp 7
The loop will continue waiting for request data:
- \snippet blockingslave/slavethread.cpp 8
+ \snippet blockingreceiver/receiverthread.cpp 8
\warning The method waitForReadyRead() should be used before each read()
call for the blocking approach, because it processes all the I/O routines
instead of Qt event-loop.
- The timeout() signal is emitted if error occurs when reading data.
+ The timeout() signal is emitted if an error occurs when reading data.
- \snippet blockingslave/slavethread.cpp 9
+ \snippet blockingreceiver/receiverthread.cpp 9
After a successful read, try to send a response and wait for completion of the
transfer:
- \snippet blockingslave/slavethread.cpp 10
+ \snippet blockingreceiver/receiverthread.cpp 10
\warning The method waitForBytesWritten() should be used after each write()
call for the blocking approach, because it processes all the I/O routines
@@ -148,20 +126,20 @@
The timeout() signal is emitted if an error occurs when writing data.
- \snippet blockingslave/slavethread.cpp 11
+ \snippet blockingreceiver/receiverthread.cpp 11
After a successful writing is emitted, request() signal containing the
- data received from the Master application:
+ data received from the Sender application:
- \snippet blockingslave/slavethread.cpp 12
+ \snippet blockingreceiver/receiverthread.cpp 12
Next, the thread switches to reading the current parameters for the serial
interface, because they can already have been updated, and run the loop
from the beginning.
- \snippet blockingslave/slavethread.cpp 13
+ \snippet blockingreceiver/receiverthread.cpp 13
- \sa {Terminal Example}, {Blocking Master Example}
+ \sa {Serial Terminal}, {Blocking Sender}
\include examples-run.qdocinc
*/
diff --git a/examples/serialport/doc/blockingmaster.qdoc b/examples/serialport/doc/blockingsender.qdoc
index d3f7e4e..db28b72 100644
--- a/examples/serialport/doc/blockingmaster.qdoc
+++ b/examples/serialport/doc/blockingsender.qdoc
@@ -1,42 +1,20 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 - 2012 Denis Shienkov <denis.shienkov@gmail.com>
-** Copyright (C) 2012 - 2013 Laszlo Papp <lpapp@kde.org>
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2011 - 2012 Denis Shienkov <denis.shienkov@gmail.com>
+// Copyright (C) 2012 - 2013 Laszlo Papp <lpapp@kde.org>
+// Copyright (C) 2023 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
- \example blockingmaster
- \title Blocking Master Example
+ \example blockingsender
+ \title Blocking Sender
\ingroup qtserialport-examples
+ \examplecategory Connectivity
+
\brief Shows how to use the synchronous API of QSerialPort in a worker thread.
- \e{Blocking Master} shows how to create an application for a serial
+ \e{Blocking Sender} shows how to create an application for a serial
interface using the synchronous API of QSerialPort in a worker thread.
- \image blockingmaster-example.png
+ \image blockingsender-example.png
QSerialPort supports two programming alternatives:
@@ -65,35 +43,35 @@
should only be used in non-GUI threads to keep the user interface
responsive.
- This application is the master which demonstrates the work paired with the slave
- application \l{blockingslave}{Blocking Slave Example}.
+ This application is the sender which demonstrates the work paired with the
+ receiver application \l{blockingreceiver}{Blocking Receiver example}.
- The master application initiates the transfer request via the serial port to
- the slave application and waits for response.
+ The sender application initiates the transfer request via the serial port to
+ the receiver application and waits for response.
- \snippet blockingmaster/masterthread.h 0
+ \snippet blockingsender/senderthread.h 0
- MasterThread is a QThread subclass that provides API for scheduling
- requests to the slave. This class provides signals for responding and
+ SenderThread is a QThread subclass that provides API for scheduling
+ requests to the receiver. This class provides signals for responding and
reporting errors. The transaction() method can be called to start up the
- new master transaction with the desired request. The result is provided by
+ new sender transaction with the desired request. The result is provided by
the response() signal. In case of any issues, the error() or timeout()
signal is emitted.
Note, the transaction() method is called in the main thread, but the
- request is provided in the MasterThread thread. The MasterThread
+ request is provided in the SenderThread thread. The SenderThread
data members are read and written concurrently in different threads, thus
the QMutex class is used to synchronize the access.
- \snippet blockingmaster/masterthread.cpp 2
+ \snippet blockingsender/senderthread.cpp 2
The transaction() method stores the serial port name, timeout and request
data. The mutex can be locked with QMutexLocker to protect this data. The
thread can be started then, unless it is already running. The
\l{QWaitCondition::wakeOne()}{wakeOne()} method is discussed later.
- \snippet blockingmaster/masterthread.cpp 4
- \snippet blockingmaster/masterthread.cpp 5
+ \snippet blockingsender/senderthread.cpp 4
+ \snippet blockingsender/senderthread.cpp 5
In the run() function, the first is to lock the QMutex object, then fetch the
serial port name, timeout and request data by using the member data. Having
@@ -103,13 +81,13 @@
simultaneously with a process fetching the data. Note, while the QString
class is reentrant, it is not thread-safe. Thereby, it is not recommended to
read the serial port name in a request thread, and timeout or request data
- in another thread. The MasterThread class can only handle one request at a
+ in another thread. The SenderThread class can only handle one request at a
time.
The QSerialPort object is constructed on stack in the run() method before
entering the loop:
- \snippet blockingmaster/masterthread.cpp 6
+ \snippet blockingsender/senderthread.cpp 6
This makes it possible to create an object while running the loop. It also
means that all the object methods are executed in the scope of the run()
@@ -119,12 +97,12 @@
current transaction has changed. If this has changed, the serial port is
reopened and then reconfigured.
- \snippet blockingmaster/masterthread.cpp 7
+ \snippet blockingsender/senderthread.cpp 7
The loop will continue to request data, write to the serial port and wait
until all data is transferred.
- \snippet blockingmaster/masterthread.cpp 8
+ \snippet blockingsender/senderthread.cpp 8
\warning As for the blocking transfer, the
\l{QSerialPort::waitForBytesWritten()}{waitForBytesWritten()} method should be
@@ -134,12 +112,12 @@
The timeout() signal is emitted if a timeout error occurs when transferring
data.
- \snippet blockingmaster/masterthread.cpp 9
+ \snippet blockingsender/senderthread.cpp 9
There is a waiting period for response after a successful request, and then
it is read again.
- \snippet blockingmaster/masterthread.cpp 10
+ \snippet blockingsender/senderthread.cpp 10
\warning As for the blocking alternative, the
\l{QSerialPort::waitForReadyRead()}{waitForReadyRead()} method should be
@@ -148,20 +126,20 @@
The timeout() signal is emitted if a timeout error occurs when receiving data.
- \snippet blockingmaster/masterthread.cpp 11
+ \snippet blockingsender/senderthread.cpp 11
When a transaction has been completed successfully, the response() signal contains
- the data received from the slave application:
+ the data received from the receiver application:
- \snippet blockingmaster/masterthread.cpp 12
+ \snippet blockingsender/senderthread.cpp 12
Afterwards, the thread goes to sleep until the next transaction appears.
The thread reads the new data after waking up by using the members and
runs the loop from the beginning.
- \snippet blockingmaster/masterthread.cpp 13
+ \snippet blockingsender/senderthread.cpp 13
- \sa {Terminal Example}, {Blocking Slave Example}
+ \sa {Serial Terminal}, {Blocking Receiver}
\include examples-run.qdocinc
*/
diff --git a/examples/serialport/doc/cenumerator.qdoc b/examples/serialport/doc/cenumerator.qdoc
deleted file mode 100644
index 1b1d6dc..0000000
--- a/examples/serialport/doc/cenumerator.qdoc
+++ /dev/null
@@ -1,47 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Laszlo Papp <lpapp@kde.org>
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-/*!
- \example cenumerator
- \title Command Line Enumerator Example
- \ingroup qtserialport-examples
- \brief Shows how to get information about serial devices in a system.
-
- \e{Command Line Enumerator} shows how to use the class QSerialPortInfo for
- getting information about serial devices that are present in the system.
-
- \image cenumerator-example.png
-
- This command line example displays information about serial ports in a
- console, provided by the class QSerialPortInfo.
-
- For getting information about the available ports, use the static method
- \l{QSerialPortInfo::availablePorts()}{availablePorts()}.
-
- \include examples-run.qdocinc
-*/
diff --git a/examples/serialport/doc/creaderasync.qdoc b/examples/serialport/doc/creaderasync.qdoc
deleted file mode 100644
index fdcbc24..0000000
--- a/examples/serialport/doc/creaderasync.qdoc
+++ /dev/null
@@ -1,49 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2013 Laszlo Papp <lpapp@kde.org>
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-/*!
- \example creaderasync
- \title Command Line Reader Async Example
- \ingroup qtserialport-examples
- \brief Shows how to receive data asynchronously over serial port.
-
- \e{Command Line Reader Async} shows how to use the QSerialPort class for
- receiving data asynchronously over the selected serial port with the desired
- settings.
-
- \image creaderasync-example.png
-
- This command line reader async example receives data asynchronously over the
- selected serial port in a console, provided by the QSerialPort class.
-
- For receiving data synchronously over the selected serial port, use the
- \l{QSerialPort::read()}{read()} or \l{QSerialPort::readAll()}{readAll()}
- methods, and \l{QIODevice::readyRead()}{readyRead()} signal.
-
- \include examples-run.qdocinc
-*/
diff --git a/examples/serialport/doc/creadersync.qdoc b/examples/serialport/doc/creadersync.qdoc
deleted file mode 100644
index cb4c79a..0000000
--- a/examples/serialport/doc/creadersync.qdoc
+++ /dev/null
@@ -1,49 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2013 Laszlo Papp <lpapp@kde.org>
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-/*!
- \example creadersync
- \title Command Line Reader Sync Example
- \ingroup qtserialport-examples
- \brief Shows how to receive data synchronously over serial port.
-
- \e{Command Line Reader Sync} shows how to use the QSerialPort class
- for receiving data synchronously over the selected serial port with the
- desired settings.
-
- \image creadersync-example.png
-
- This command line reader sync example receives data synchronously over the
- selected serial port in a console, provided by the QSerialPort class.
-
- For receiving data synchronously over the selected serial port, use the
- \l{QSerialPort::read()}{read()} or \l{QSerialPort::readAll()}{readAll()},
- and \l{QIODevice::waitForReadyRead()}{waitForReadyRead()} methods.
-
- \include examples-run.qdocinc
-*/
diff --git a/examples/serialport/doc/cwriterasync.qdoc b/examples/serialport/doc/cwriterasync.qdoc
deleted file mode 100644
index 30d77c8..0000000
--- a/examples/serialport/doc/cwriterasync.qdoc
+++ /dev/null
@@ -1,49 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2013 Laszlo Papp <lpapp@kde.org>
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-/*!
- \example cwriterasync
- \title Command Line Writer Async Example
- \ingroup qtserialport-examples
- \brief Shows how to send data asynchronously over serial port.
-
- \e{Command Line Writer Async} shows how to use the QSerialPort class for
- sending data asynchronously over the selected serial port with the desired
- settings.
-
- \image cwriterasync-example.png
-
- This command line writer async example sends data asynchronously over the
- selected serial port in a console, provided by the QSerialPort class.
-
- For sending data asynchronously over the selected serial port, use the
- \l{QIODevice::write()}{write()} method and
- \l{QIODevice::bytesWritten()}{bytesWritten()} signal.
-
- \include examples-run.qdocinc
-*/
diff --git a/examples/serialport/doc/cwritersync.qdoc b/examples/serialport/doc/cwritersync.qdoc
deleted file mode 100644
index b46a508..0000000
--- a/examples/serialport/doc/cwritersync.qdoc
+++ /dev/null
@@ -1,49 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2013 Laszlo Papp <lpapp@kde.org>
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-/*!
- \example cwritersync
- \title Command Line Writer Sync Example
- \ingroup qtserialport-examples
- \brief Shows how to send data synchronously over serial port.
-
- \e{Command Line Writer Sync} shows how to use the QSerialPort class for
- sending data synchronously over the selected serial port with the desired
- settings.
-
- \image cwritersync-example.png
-
- This command line writer sync example sends data synchronously over the
- selected serial port in a console, provided by the QSerialPort class.
-
- For sending data synchronously over the selected serial port, use the
- \l{QIODevice::write()}{write()} and
- \l{QIODevice::waitForBytesWritten()}{waitForBytesWritten()} methods.
-
- \include examples-run.qdocinc
-*/
diff --git a/examples/serialport/doc/enumerator.qdoc b/examples/serialport/doc/enumerator.qdoc
deleted file mode 100644
index 1a5fce5..0000000
--- a/examples/serialport/doc/enumerator.qdoc
+++ /dev/null
@@ -1,47 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 - 2012 Denis Shienkov <denis.shienkov@gmail.com>
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-/*!
- \example enumerator
- \title Enumerator Example
- \ingroup qtserialport-examples
- \brief Shows how to display information about serial devices in a system.
-
- \e Enumerator shows how to use the class QSerialPortInfo for
- getting information about serial devices that are present in the system.
-
- \image enumerator-example.png
-
- This GUI example displays information about serial ports in a widget,
- provided by the class QSerialPortInfo.
-
- For getting information about the available ports, use the static method
- \l{QSerialPortInfo::availablePorts()}{availablePorts()}.
-
- \include examples-run.qdocinc
-*/
diff --git a/examples/serialport/doc/terminal.qdoc b/examples/serialport/doc/terminal.qdoc
index 0215677..c90a3c0 100644
--- a/examples/serialport/doc/terminal.qdoc
+++ b/examples/serialport/doc/terminal.qdoc
@@ -1,35 +1,13 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 - 2012 Denis Shienkov <denis.shienkov@gmail.com>
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2011 - 2012 Denis Shienkov <denis.shienkov@gmail.com>
+// Copyright (C) 2023 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
\example terminal
- \title Terminal Example
+ \title Serial Terminal
\ingroup qtserialport-examples
+ \examplecategory Connectivity
+
\brief Shows how to use various features of QSerialPort.
\e Terminal shows how to create a terminal for a simple serial interface by
@@ -60,7 +38,7 @@
\endlist
In this example, the asynchronous approach is demonstrated. The
- \l{blockingslave}{Blocking Slave} example illustrates the synchronous
+ \l{blockingreceiver}{Blocking Receiver} example illustrates the synchronous
approach.
Our example contains some GUI widgets:
@@ -87,12 +65,16 @@
happens automatically according to the parent and child mechanism in Qt:
\snippet terminal/mainwindow.cpp 0
- \dots
\snippet terminal/mainwindow.cpp 1
+ \dots
- The only QSerialPort signal invoked in this example is
- \l{QIODevice::}{readyRead()}, which shows that new data has been
- received and hence available:
+ This example demonstrates the following \l QSerialPort signals:
+ \list
+ \li \l {QIODevice::}{readyRead()} - shows that new data has been
+ received and hence available
+ \li \l {QIODevice::}{bytesWritten()} - used to check that all data was
+ written successfully
+ \endlist
\dots
\snippet terminal/mainwindow.cpp 2
@@ -103,7 +85,8 @@
\snippet terminal/mainwindow.cpp 4
- In this slot, the settings are read from \c{SettingsDialog} and an attempt is made to open and initialize the serial
+ In this slot, the settings are read from \c{SettingsDialog} and an attempt
+ is made to open and initialize the serial
port accordingly. If successful, the status bar displays a message that the
opening was successful with the given configuration; otherwise, a messagebox
is displayed with the appropriate error code and message. If the serial port
@@ -117,12 +100,30 @@
In this case, handled by the closure of the serial port.
+ Clicking on the \b{Configure} button invokes the \c{show()} slot which
+ belongs to the \c{SettingsDialog} widget.
+
+ This method (\c{terminal/settingsdialog.cpp}) displays the \c{SettingsDialog},
+ in which the user can choose the desired serial port, see the information
+ about the selected port, and set the desired parameters of the given serial
+ port.
+
+ \section2 Writing Data
+
Typing characters in the console invokes the \c writeData() slot:
\snippet terminal/mainwindow.cpp 6
This slot sends the characters typed in the given
Console widget to the serial port - see \c terminal/console.cpp.
+ It also starts a timer to track if the write actually succeeded or not.
+ We use the \l {QIODevice::}{bytesWritten()} signal to make sure that all
+ bytes are actually written. It is connected to the
+ \c {MainWindow::handleBytesWritten()} slot:
+
+ \snippet terminal/mainwindow.cpp 9
+
+ \section2 Reading Data
When the serial port receives new data, the signal
\l{QIODevice::}{readyRead()} is emitted, and that signal is
@@ -133,15 +134,7 @@
This slot reads the data from the serial port and displays that in the
Console widget.
- Clicking on the \b{Configure} button invokes the \c{show()} slot which
- belongs to the \c{SettingsDialog} widget.
-
- This method (\c{terminal/settingsdialog.cpp}) displays the \c{SettingsDialog},
- in which the user can choose the desired serial port, see the information
- about the selected port, and set the desired parameters of the given serial
- port.
-
- \sa {Blocking Slave Example}
+ \sa {Blocking Receiver}
\include examples-run.qdocinc
*/
diff --git a/examples/serialport/enumerator/enumerator.pro b/examples/serialport/enumerator/enumerator.pro
deleted file mode 100644
index 3989335..0000000
--- a/examples/serialport/enumerator/enumerator.pro
+++ /dev/null
@@ -1,10 +0,0 @@
-QT += widgets serialport
-
-TARGET = enumerator
-TEMPLATE = app
-
-SOURCES += \
- main.cpp
-
-target.path = $$[QT_INSTALL_EXAMPLES]/serialport/enumerator
-INSTALLS += target
diff --git a/examples/serialport/enumerator/main.cpp b/examples/serialport/enumerator/main.cpp
deleted file mode 100644
index ee21351..0000000
--- a/examples/serialport/enumerator/main.cpp
+++ /dev/null
@@ -1,88 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Denis Shienkov <denis.shienkov@gmail.com>
-** Copyright (C) 2012 Laszlo Papp <lpapp@kde.org>
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtSerialPort module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QApplication>
-#include <QLabel>
-#include <QScrollArea>
-#include <QSerialPortInfo>
-#include <QVBoxLayout>
-#include <QWidget>
-
-int main(int argc, char *argv[])
-{
- QApplication a(argc, argv);
-
- auto layout = new QVBoxLayout;
-
- const auto infos = QSerialPortInfo::availablePorts();
- for (const QSerialPortInfo &info : infos) {
- QString s = QObject::tr("Port: ") + info.portName() + "\n"
- + QObject::tr("Location: ") + info.systemLocation() + "\n"
- + QObject::tr("Description: ") + info.description() + "\n"
- + QObject::tr("Manufacturer: ") + info.manufacturer() + "\n"
- + QObject::tr("Serial number: ") + info.serialNumber() + "\n"
- + QObject::tr("Vendor Identifier: ") + (info.hasVendorIdentifier() ? QString::number(info.vendorIdentifier(), 16) : QString()) + "\n"
- + QObject::tr("Product Identifier: ") + (info.hasProductIdentifier() ? QString::number(info.productIdentifier(), 16) : QString()) + "\n";
-
- auto label = new QLabel(s);
- layout->addWidget(label);
- }
-
- auto workPage = new QWidget;
- workPage->setLayout(layout);
-
- QScrollArea area;
- area.setWindowTitle(QObject::tr("Info about all available serial ports."));
- area.setWidget(workPage);
- area.show();
-
- return a.exec();
-}
diff --git a/examples/serialport/master/dialog.h b/examples/serialport/master/dialog.h
deleted file mode 100644
index 2fb2e8e..0000000
--- a/examples/serialport/master/dialog.h
+++ /dev/null
@@ -1,101 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Denis Shienkov <denis.shienkov@gmail.com>
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtSerialPort module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef DIALOG_H
-#define DIALOG_H
-
-#include <QDialog>
-#include <QSerialPort>
-#include <QTimer>
-
-QT_BEGIN_NAMESPACE
-
-class QLabel;
-class QLineEdit;
-class QSpinBox;
-class QPushButton;
-class QComboBox;
-
-QT_END_NAMESPACE
-
-class Dialog : public QDialog
-{
- Q_OBJECT
-
-public:
- explicit Dialog(QWidget *parent = nullptr);
-
-private slots:
- void sendRequest();
- void readResponse();
- void processTimeout();
-
-private:
- void setControlsEnabled(bool enable);
- void processError(const QString &error);
-
-private:
- int m_transactionCount = 0;
- QLabel *m_serialPortLabel = nullptr;
- QComboBox *m_serialPortComboBox = nullptr;
- QLabel *m_waitResponseLabel = nullptr;
- QSpinBox *m_waitResponseSpinBox = nullptr;
- QLabel *m_requestLabel = nullptr;
- QLineEdit *m_requestLineEdit = nullptr;
- QLabel *m_trafficLabel = nullptr;
- QLabel *m_statusLabel = nullptr;
- QPushButton *m_runButton = nullptr;
-
- QSerialPort m_serial;
- QByteArray m_response;
- QTimer m_timer;
-};
-
-#endif // DIALOG_H
diff --git a/examples/serialport/master/main.cpp b/examples/serialport/master/main.cpp
deleted file mode 100644
index 8e68c73..0000000
--- a/examples/serialport/master/main.cpp
+++ /dev/null
@@ -1,61 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Denis Shienkov <denis.shienkov@gmail.com>
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtSerialPort module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "dialog.h"
-
-#include <QApplication>
-
-int main(int argc, char *argv[])
-{
- QApplication app(argc, argv);
- Dialog dialog;
- dialog.show();
- return app.exec();
-}
diff --git a/examples/serialport/master/master.pro b/examples/serialport/master/master.pro
deleted file mode 100644
index 3eb9dda..0000000
--- a/examples/serialport/master/master.pro
+++ /dev/null
@@ -1,19 +0,0 @@
-greaterThan(QT_MAJOR_VERSION, 4) {
- QT += widgets serialport
- requires(qtConfig(combobox))
-} else {
- include($$QTSERIALPORT_PROJECT_ROOT/src/serialport/qt4support/serialport.prf)
-}
-
-TARGET = master
-TEMPLATE = app
-
-HEADERS += \
- dialog.h
-
-SOURCES += \
- main.cpp \
- dialog.cpp
-
-target.path = $$[QT_INSTALL_EXAMPLES]/serialport/master
-INSTALLS += target
diff --git a/examples/serialport/serialport.pro b/examples/serialport/serialport.pro
index 6d00a22..7a70fbb 100644
--- a/examples/serialport/serialport.pro
+++ b/examples/serialport/serialport.pro
@@ -1,3 +1,2 @@
TEMPLATE = subdirs
-SUBDIRS = cenumerator creaderasync creadersync cwriterasync cwritersync
-!isEmpty(QT.widgets.name):SUBDIRS += enumerator terminal blockingmaster blockingslave master slave
+!isEmpty(QT.widgets.name):SUBDIRS += terminal blockingsender blockingreceiver
diff --git a/examples/serialport/slave/dialog.h b/examples/serialport/slave/dialog.h
deleted file mode 100644
index 13909c7..0000000
--- a/examples/serialport/slave/dialog.h
+++ /dev/null
@@ -1,101 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Denis Shienkov <denis.shienkov@gmail.com>
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtSerialPort module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef DIALOG_H
-#define DIALOG_H
-
-#include <QDialog>
-#include <QSerialPort>
-#include <QTimer>
-
-QT_BEGIN_NAMESPACE
-
-class QLabel;
-class QLineEdit;
-class QComboBox;
-class QSpinBox;
-class QPushButton;
-
-QT_END_NAMESPACE
-
-class Dialog : public QDialog
-{
- Q_OBJECT
-
-public:
- explicit Dialog(QWidget *parent = nullptr);
-
-private slots:
- void startSlave();
- void readRequest();
- void processTimeout();
- void activateRunButton();
-
-private:
- void processError(const QString &s);
-
-private:
- int m_transactionCount = 0;
- QLabel *m_serialPortLabel = nullptr;
- QComboBox *m_serialPortComboBox = nullptr;
- QLabel *m_waitRequestLabel = nullptr;
- QSpinBox *m_waitRequestSpinBox = nullptr;
- QLabel *m_responseLabel = nullptr;
- QLineEdit *m_responseLineEdit = nullptr;
- QLabel *m_trafficLabel = nullptr;
- QLabel *m_statusLabel = nullptr;
- QPushButton *m_runButton = nullptr;
-
- QSerialPort m_serial;
- QByteArray m_request;
- QTimer m_timer;
-};
-
-#endif // DIALOG_H
diff --git a/examples/serialport/slave/main.cpp b/examples/serialport/slave/main.cpp
deleted file mode 100644
index 8e68c73..0000000
--- a/examples/serialport/slave/main.cpp
+++ /dev/null
@@ -1,61 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Denis Shienkov <denis.shienkov@gmail.com>
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtSerialPort module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "dialog.h"
-
-#include <QApplication>
-
-int main(int argc, char *argv[])
-{
- QApplication app(argc, argv);
- Dialog dialog;
- dialog.show();
- return app.exec();
-}
diff --git a/examples/serialport/slave/slave.pro b/examples/serialport/slave/slave.pro
deleted file mode 100644
index eb684ff..0000000
--- a/examples/serialport/slave/slave.pro
+++ /dev/null
@@ -1,19 +0,0 @@
-greaterThan(QT_MAJOR_VERSION, 4) {
- QT += widgets serialport
- requires(qtConfig(combobox))
-} else {
- include($$QTSERIALPORT_PROJECT_ROOT/src/serialport/qt4support/serialport.prf)
-}
-
-TARGET = slave
-TEMPLATE = app
-
-HEADERS += \
- dialog.h
-
-SOURCES += \
- main.cpp \
- dialog.cpp
-
-target.path = $$[QT_INSTALL_EXAMPLES]/serialport/slave
-INSTALLS += target
diff --git a/examples/serialport/slave/slavethread.cpp b/examples/serialport/slave/slavethread.cpp
deleted file mode 100644
index b6394c6..0000000
--- a/examples/serialport/slave/slavethread.cpp
+++ /dev/null
@@ -1,146 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Denis Shienkov <denis.shienkov@gmail.com>
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtSerialPort module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "slavethread.h"
-
-#include <QtSerialPort/QSerialPort>
-
-#include <QTime>
-
-QT_USE_NAMESPACE
-
-SlaveThread::SlaveThread(QObject *parent)
- : QThread(parent), waitTimeout(0), quit(false)
-{
-}
-
-SlaveThread::~SlaveThread()
-{
- mutex.lock();
- quit = true;
- mutex.unlock();
- wait();
-}
-
-void SlaveThread::startSlave(const QString &portName, int waitTimeout, const QString &response)
-{
- QMutexLocker locker(&mutex);
- this->portName = portName;
- this->waitTimeout = waitTimeout;
- this->response = response;
-
- if (!isRunning())
- start();
-}
-
-void SlaveThread::run()
-{
- bool currentPortNameChanged = false;
-
- mutex.lock();
- QString currentPortName;
- if (currentPortName != portName) {
- currentPortName = portName;
- currentPortNameChanged = true;
- }
-
- int currentWaitTimeout = waitTimeout;
- QString currentRespone = response;
- mutex.unlock();
-
- QSerialPort serial;
-
- while (!quit) {
-
- if (currentPortNameChanged) {
- serial.close();
- serial.setPortName(currentPortName);
-
- if (!serial.open(QIODevice::ReadWrite)) {
- emit error(tr("Can't open %1, error code %2")
- .arg(portName).arg(serial.error()));
- return;
- }
- }
-
- if (serial.waitForReadyRead(currentWaitTimeout)) {
-
- // read all request
- QByteArray requestData = serial.readAll();
- while (serial.waitForReadyRead(10))
- requestData += serial.readAll();
-
- // write all response
- QByteArray responseData = currentRespone.toLocal8Bit();
- serial.write(responseData);
- if (serial.waitForBytesWritten(waitTimeout)) {
- QString request(requestData);
- emit this->request(request);
- } else {
- emit timeout(tr("Wait write response timeout %1")
- .arg(QTime::currentTime().toString()));
- }
- } else {
- emit timeout(tr("Wait read request timeout %1")
- .arg(QTime::currentTime().toString()));
- }
-
- mutex.lock();
- if (currentPortName != portName) {
- currentPortName = portName;
- currentPortNameChanged = true;
- } else {
- currentPortNameChanged = false;
- }
- currentWaitTimeout = waitTimeout;
- currentRespone = response;
- mutex.unlock();
- }
-}
diff --git a/examples/serialport/slave/slavethread.h b/examples/serialport/slave/slavethread.h
deleted file mode 100644
index 6ef9d2b..0000000
--- a/examples/serialport/slave/slavethread.h
+++ /dev/null
@@ -1,82 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Denis Shienkov <denis.shienkov@gmail.com>
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtSerialPort module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef SLAVETHREAD_H
-#define SLAVETHREAD_H
-
-#include <QThread>
-#include <QMutex>
-#include <QWaitCondition>
-
-class SlaveThread : public QThread
-{
- Q_OBJECT
-
-public:
- SlaveThread(QObject *parent = 0);
- ~SlaveThread();
-
- void startSlave(const QString &portName, int waitTimeout, const QString &response);
- void run();
-
-signals:
- void request(const QString &s);
- void error(const QString &s);
- void timeout(const QString &s);
-
-private:
- QString portName;
- QString response;
- int waitTimeout;
- QMutex mutex;
- bool quit;
-};
-
-#endif // SLAVETHREAD_H
diff --git a/examples/serialport/terminal/CMakeLists.txt b/examples/serialport/terminal/CMakeLists.txt
new file mode 100644
index 0000000..e430780
--- /dev/null
+++ b/examples/serialport/terminal/CMakeLists.txt
@@ -0,0 +1,56 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
+cmake_minimum_required(VERSION 3.16)
+project(terminal LANGUAGES CXX)
+
+if(NOT DEFINED INSTALL_EXAMPLESDIR)
+ set(INSTALL_EXAMPLESDIR "examples")
+endif()
+
+set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/serialport/terminal")
+
+find_package(Qt6 REQUIRED COMPONENTS Core Gui SerialPort Widgets)
+
+qt_standard_project_setup()
+
+qt_add_executable(terminal
+ console.cpp console.h
+ main.cpp
+ mainwindow.cpp mainwindow.h mainwindow.ui
+ settingsdialog.cpp settingsdialog.h settingsdialog.ui
+)
+
+set_target_properties(terminal PROPERTIES
+ WIN32_EXECUTABLE TRUE
+ MACOSX_BUNDLE TRUE
+)
+
+target_link_libraries(terminal PRIVATE
+ Qt::Core
+ Qt::Gui
+ Qt::SerialPort
+ Qt::Widgets
+)
+
+# Resources:
+set(terminal_resource_files
+ "images/application-exit.png"
+ "images/clear.png"
+ "images/connect.png"
+ "images/disconnect.png"
+ "images/settings.png"
+)
+
+qt_add_resources(terminal "terminal"
+ PREFIX
+ "/"
+ FILES
+ ${terminal_resource_files}
+)
+
+install(TARGETS terminal
+ RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
+ BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
+ LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
+)
diff --git a/examples/serialport/terminal/console.cpp b/examples/serialport/terminal/console.cpp
index 23d7899..ce87f1a 100644
--- a/examples/serialport/terminal/console.cpp
+++ b/examples/serialport/terminal/console.cpp
@@ -1,53 +1,6 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Denis Shienkov <denis.shienkov@gmail.com>
-** Copyright (C) 2012 Laszlo Papp <lpapp@kde.org>
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtSerialPort module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2012 Denis Shienkov <denis.shienkov@gmail.com>
+// Copyright (C) 2012 Laszlo Papp <lpapp@kde.org>
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "console.h"
diff --git a/examples/serialport/terminal/console.h b/examples/serialport/terminal/console.h
index b9fe553..8cbc7d6 100644
--- a/examples/serialport/terminal/console.h
+++ b/examples/serialport/terminal/console.h
@@ -1,53 +1,6 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Denis Shienkov <denis.shienkov@gmail.com>
-** Copyright (C) 2012 Laszlo Papp <lpapp@kde.org>
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtSerialPort module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2012 Denis Shienkov <denis.shienkov@gmail.com>
+// Copyright (C) 2012 Laszlo Papp <lpapp@kde.org>
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef CONSOLE_H
#define CONSOLE_H
diff --git a/examples/serialport/terminal/main.cpp b/examples/serialport/terminal/main.cpp
index a6e901a..ac6f48c 100644
--- a/examples/serialport/terminal/main.cpp
+++ b/examples/serialport/terminal/main.cpp
@@ -1,53 +1,6 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Denis Shienkov <denis.shienkov@gmail.com>
-** Copyright (C) 2012 Laszlo Papp <lpapp@kde.org>
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtSerialPort module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2012 Denis Shienkov <denis.shienkov@gmail.com>
+// Copyright (C) 2012 Laszlo Papp <lpapp@kde.org>
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "mainwindow.h"
diff --git a/examples/serialport/terminal/mainwindow.cpp b/examples/serialport/terminal/mainwindow.cpp
index e8ac9d7..d8c0212 100644
--- a/examples/serialport/terminal/mainwindow.cpp
+++ b/examples/serialport/terminal/mainwindow.cpp
@@ -1,53 +1,6 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Denis Shienkov <denis.shienkov@gmail.com>
-** Copyright (C) 2012 Laszlo Papp <lpapp@kde.org>
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtSerialPort module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2012 Denis Shienkov <denis.shienkov@gmail.com>
+// Copyright (C) 2012 Laszlo Papp <lpapp@kde.org>
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "mainwindow.h"
#include "ui_mainwindow.h"
@@ -56,19 +9,25 @@
#include <QLabel>
#include <QMessageBox>
+#include <QTimer>
+
+#include <chrono>
+
+static constexpr std::chrono::seconds kWriteTimeout = std::chrono::seconds{5};
//! [0]
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
m_ui(new Ui::MainWindow),
+//! [0]
m_status(new QLabel),
m_console(new Console),
- m_settings(new SettingsDialog),
+ m_settings(new SettingsDialog(this)),
+ m_timer(new QTimer(this)),
//! [1]
m_serial(new QSerialPort(this))
-//! [1]
{
-//! [0]
+//! [1]
m_ui->setupUi(this);
m_console->setEnabled(false);
setCentralWidget(m_console);
@@ -83,9 +42,12 @@ MainWindow::MainWindow(QWidget *parent) :
initActionsConnections();
connect(m_serial, &QSerialPort::errorOccurred, this, &MainWindow::handleError);
+ connect(m_timer, &QTimer::timeout, this, &MainWindow::handleWriteTimeout);
+ m_timer->setSingleShot(true);
//! [2]
connect(m_serial, &QSerialPort::readyRead, this, &MainWindow::readData);
+ connect(m_serial, &QSerialPort::bytesWritten, this, &MainWindow::handleBytesWritten);
//! [2]
connect(m_console, &Console::getData, this, &MainWindow::writeData);
//! [3]
@@ -115,8 +77,8 @@ void MainWindow::openSerialPort()
m_ui->actionDisconnect->setEnabled(true);
m_ui->actionConfigure->setEnabled(false);
showStatusMessage(tr("Connected to %1 : %2, %3, %4, %5, %6")
- .arg(p.name).arg(p.stringBaudRate).arg(p.stringDataBits)
- .arg(p.stringParity).arg(p.stringStopBits).arg(p.stringFlowControl));
+ .arg(p.name, p.stringBaudRate, p.stringDataBits,
+ p.stringParity, p.stringStopBits, p.stringFlowControl));
} else {
QMessageBox::critical(this, tr("Error"), m_serial->errorString());
@@ -140,8 +102,8 @@ void MainWindow::closeSerialPort()
void MainWindow::about()
{
- QMessageBox::about(this, tr("About Simple Terminal"),
- tr("The <b>Simple Terminal</b> example demonstrates how to "
+ QMessageBox::about(this, tr("About Serial Terminal"),
+ tr("The <b>Serial Terminal</b> example demonstrates how to "
"use the Qt Serial Port module in modern GUI applications "
"using Qt, with a menu bar, toolbars, and a status bar."));
}
@@ -149,7 +111,16 @@ void MainWindow::about()
//! [6]
void MainWindow::writeData(const QByteArray &data)
{
- m_serial->write(data);
+ const qint64 written = m_serial->write(data);
+ if (written == data.size()) {
+ m_bytesToWrite += written;
+ m_timer->start(kWriteTimeout);
+ } else {
+ const QString error = tr("Failed to write all data to port %1.\n"
+ "Error: %2").arg(m_serial->portName(),
+ m_serial->errorString());
+ showWriteError(error);
+ }
}
//! [6]
@@ -171,6 +142,23 @@ void MainWindow::handleError(QSerialPort::SerialPortError error)
}
//! [8]
+//! [9]
+void MainWindow::handleBytesWritten(qint64 bytes)
+{
+ m_bytesToWrite -= bytes;
+ if (m_bytesToWrite == 0)
+ m_timer->stop();
+}
+//! [9]
+
+void MainWindow::handleWriteTimeout()
+{
+ const QString error = tr("Write operation timed out for port %1.\n"
+ "Error: %2").arg(m_serial->portName(),
+ m_serial->errorString());
+ showWriteError(error);
+}
+
void MainWindow::initActionsConnections()
{
connect(m_ui->actionConnect, &QAction::triggered, this, &MainWindow::openSerialPort);
@@ -186,3 +174,8 @@ void MainWindow::showStatusMessage(const QString &message)
{
m_status->setText(message);
}
+
+void MainWindow::showWriteError(const QString &message)
+{
+ QMessageBox::warning(this, tr("Warning"), message);
+}
diff --git a/examples/serialport/terminal/mainwindow.h b/examples/serialport/terminal/mainwindow.h
index eebae8c..975f9a4 100644
--- a/examples/serialport/terminal/mainwindow.h
+++ b/examples/serialport/terminal/mainwindow.h
@@ -1,53 +1,6 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Denis Shienkov <denis.shienkov@gmail.com>
-** Copyright (C) 2012 Laszlo Papp <lpapp@kde.org>
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtSerialPort module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2012 Denis Shienkov <denis.shienkov@gmail.com>
+// Copyright (C) 2012 Laszlo Papp <lpapp@kde.org>
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
@@ -58,6 +11,7 @@
QT_BEGIN_NAMESPACE
class QLabel;
+class QTimer;
namespace Ui {
class MainWindow;
@@ -84,17 +38,22 @@ private slots:
void readData();
void handleError(QSerialPort::SerialPortError error);
+ void handleBytesWritten(qint64 bytes);
+ void handleWriteTimeout();
private:
void initActionsConnections();
private:
void showStatusMessage(const QString &message);
+ void showWriteError(const QString &message);
Ui::MainWindow *m_ui = nullptr;
QLabel *m_status = nullptr;
Console *m_console = nullptr;
SettingsDialog *m_settings = nullptr;
+ qint64 m_bytesToWrite = 0;
+ QTimer *m_timer = nullptr;
QSerialPort *m_serial = nullptr;
};
diff --git a/examples/serialport/terminal/mainwindow.ui b/examples/serialport/terminal/mainwindow.ui
index 452fdd5..be0861f 100644
--- a/examples/serialport/terminal/mainwindow.ui
+++ b/examples/serialport/terminal/mainwindow.ui
@@ -11,7 +11,7 @@
</rect>
</property>
<property name="windowTitle">
- <string>Simple Terminal</string>
+ <string>Serial Terminal</string>
</property>
<widget class="QWidget" name="centralWidget">
<layout class="QVBoxLayout" name="verticalLayout"/>
diff --git a/examples/serialport/terminal/settingsdialog.cpp b/examples/serialport/terminal/settingsdialog.cpp
index ad06004..c949e2c 100644
--- a/examples/serialport/terminal/settingsdialog.cpp
+++ b/examples/serialport/terminal/settingsdialog.cpp
@@ -1,53 +1,6 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Denis Shienkov <denis.shienkov@gmail.com>
-** Copyright (C) 2012 Laszlo Papp <lpapp@kde.org>
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtSerialPort module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2012 Denis Shienkov <denis.shienkov@gmail.com>
+// Copyright (C) 2012 Laszlo Papp <lpapp@kde.org>
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "settingsdialog.h"
#include "ui_settingsdialog.h"
@@ -97,13 +50,15 @@ void SettingsDialog::showPortInfo(int idx)
if (idx == -1)
return;
+ const QString blankString = tr(::blankString);
+
const QStringList list = m_ui->serialPortInfoListBox->itemData(idx).toStringList();
- m_ui->descriptionLabel->setText(tr("Description: %1").arg(list.count() > 1 ? list.at(1) : tr(blankString)));
- m_ui->manufacturerLabel->setText(tr("Manufacturer: %1").arg(list.count() > 2 ? list.at(2) : tr(blankString)));
- m_ui->serialNumberLabel->setText(tr("Serial number: %1").arg(list.count() > 3 ? list.at(3) : tr(blankString)));
- m_ui->locationLabel->setText(tr("Location: %1").arg(list.count() > 4 ? list.at(4) : tr(blankString)));
- m_ui->vidLabel->setText(tr("Vendor Identifier: %1").arg(list.count() > 5 ? list.at(5) : tr(blankString)));
- m_ui->pidLabel->setText(tr("Product Identifier: %1").arg(list.count() > 6 ? list.at(6) : tr(blankString)));
+ m_ui->descriptionLabel->setText(tr("Description: %1").arg(list.value(1, blankString)));
+ m_ui->manufacturerLabel->setText(tr("Manufacturer: %1").arg(list.value(2, blankString)));
+ m_ui->serialNumberLabel->setText(tr("Serial number: %1").arg(list.value(3, blankString)));
+ m_ui->locationLabel->setText(tr("Location: %1").arg(list.value(4, blankString)));
+ m_ui->vidLabel->setText(tr("Vendor Identifier: %1").arg(list.value(5, blankString)));
+ m_ui->pidLabel->setText(tr("Product Identifier: %1").arg(list.value(6, blankString)));
}
void SettingsDialog::apply()
@@ -165,24 +120,25 @@ void SettingsDialog::fillPortsParameters()
void SettingsDialog::fillPortsInfo()
{
m_ui->serialPortInfoListBox->clear();
- QString description;
- QString manufacturer;
- QString serialNumber;
+ const QString blankString = tr(::blankString);
const auto infos = QSerialPortInfo::availablePorts();
+
for (const QSerialPortInfo &info : infos) {
QStringList list;
- description = info.description();
- manufacturer = info.manufacturer();
- serialNumber = info.serialNumber();
+ const QString description = info.description();
+ const QString manufacturer = info.manufacturer();
+ const QString serialNumber = info.serialNumber();
+ const auto vendorId = info.vendorIdentifier();
+ const auto productId = info.productIdentifier();
list << info.portName()
<< (!description.isEmpty() ? description : blankString)
<< (!manufacturer.isEmpty() ? manufacturer : blankString)
<< (!serialNumber.isEmpty() ? serialNumber : blankString)
<< info.systemLocation()
- << (info.vendorIdentifier() ? QString::number(info.vendorIdentifier(), 16) : blankString)
- << (info.productIdentifier() ? QString::number(info.productIdentifier(), 16) : blankString);
+ << (vendorId ? QString::number(vendorId, 16) : blankString)
+ << (productId ? QString::number(productId, 16) : blankString);
- m_ui->serialPortInfoListBox->addItem(list.first(), list);
+ m_ui->serialPortInfoListBox->addItem(list.constFirst(), list);
}
m_ui->serialPortInfoListBox->addItem(tr("Custom"));
@@ -195,25 +151,25 @@ void SettingsDialog::updateSettings()
if (m_ui->baudRateBox->currentIndex() == 4) {
m_currentSettings.baudRate = m_ui->baudRateBox->currentText().toInt();
} else {
- m_currentSettings.baudRate = static_cast<QSerialPort::BaudRate>(
- m_ui->baudRateBox->itemData(m_ui->baudRateBox->currentIndex()).toInt());
+ const auto baudRateData = m_ui->baudRateBox->currentData();
+ m_currentSettings.baudRate = baudRateData.value<QSerialPort::BaudRate>();
}
m_currentSettings.stringBaudRate = QString::number(m_currentSettings.baudRate);
- m_currentSettings.dataBits = static_cast<QSerialPort::DataBits>(
- m_ui->dataBitsBox->itemData(m_ui->dataBitsBox->currentIndex()).toInt());
+ const auto dataBitsData = m_ui->dataBitsBox->currentData();
+ m_currentSettings.dataBits = dataBitsData.value<QSerialPort::DataBits>();
m_currentSettings.stringDataBits = m_ui->dataBitsBox->currentText();
- m_currentSettings.parity = static_cast<QSerialPort::Parity>(
- m_ui->parityBox->itemData(m_ui->parityBox->currentIndex()).toInt());
+ const auto parityData = m_ui->parityBox->currentData();
+ m_currentSettings.parity = parityData.value<QSerialPort::Parity>();
m_currentSettings.stringParity = m_ui->parityBox->currentText();
- m_currentSettings.stopBits = static_cast<QSerialPort::StopBits>(
- m_ui->stopBitsBox->itemData(m_ui->stopBitsBox->currentIndex()).toInt());
+ const auto stopBitsData = m_ui->stopBitsBox->currentData();
+ m_currentSettings.stopBits = stopBitsData.value<QSerialPort::StopBits>();
m_currentSettings.stringStopBits = m_ui->stopBitsBox->currentText();
- m_currentSettings.flowControl = static_cast<QSerialPort::FlowControl>(
- m_ui->flowControlBox->itemData(m_ui->flowControlBox->currentIndex()).toInt());
+ const auto flowControlData = m_ui->flowControlBox->currentData();
+ m_currentSettings.flowControl = flowControlData.value<QSerialPort::FlowControl>();
m_currentSettings.stringFlowControl = m_ui->flowControlBox->currentText();
m_currentSettings.localEchoEnabled = m_ui->localEchoCheckBox->isChecked();
diff --git a/examples/serialport/terminal/settingsdialog.h b/examples/serialport/terminal/settingsdialog.h
index 4c0cda1..fac74c4 100644
--- a/examples/serialport/terminal/settingsdialog.h
+++ b/examples/serialport/terminal/settingsdialog.h
@@ -1,53 +1,6 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Denis Shienkov <denis.shienkov@gmail.com>
-** Copyright (C) 2012 Laszlo Papp <lpapp@kde.org>
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtSerialPort module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2012 Denis Shienkov <denis.shienkov@gmail.com>
+// Copyright (C) 2012 Laszlo Papp <lpapp@kde.org>
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef SETTINGSDIALOG_H
#define SETTINGSDIALOG_H
diff --git a/qt_cmdline.cmake b/qt_cmdline.cmake
new file mode 100644
index 0000000..e58ed67
--- /dev/null
+++ b/qt_cmdline.cmake
@@ -0,0 +1 @@
+qt_commandline_subconfig(src/serialport)
diff --git a/qtserialport.pro b/qtserialport.pro
deleted file mode 100644
index 5b7cd41..0000000
--- a/qtserialport.pro
+++ /dev/null
@@ -1,15 +0,0 @@
-lessThan(QT_MAJOR_VERSION, 5) {
- message("Cannot build current QtSerialPort sources with Qt version $${QT_VERSION}.")
- error("Use at least Qt 5.0.0 or try to download QtSerialPort for Qt4.")
-}
-
-requires(!integrity)
-requires(!vxworks)
-requires(!winrt)
-requires(!uikit)
-requires(!emscripten)
-
-load(configure)
-qtCompileTest(ntddmodm)
-
-load(qt_parts)
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
new file mode 100644
index 0000000..ebdbadf
--- /dev/null
+++ b/src/CMakeLists.txt
@@ -0,0 +1 @@
+add_subdirectory(serialport)
diff --git a/src/serialport/CMakeLists.txt b/src/serialport/CMakeLists.txt
new file mode 100644
index 0000000..b7957f3
--- /dev/null
+++ b/src/serialport/CMakeLists.txt
@@ -0,0 +1,72 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
+#####################################################################
+## SerialPort Module:
+#####################################################################
+qt_find_package(Libudev)
+
+qt_internal_add_module(SerialPort
+ SOURCES
+ qserialport.cpp qserialport.h qserialport_p.h
+ qserialportglobal.h
+ qserialportinfo.cpp qserialportinfo.h qserialportinfo_p.h
+ INCLUDE_DIRECTORIES
+ ${CMAKE_CURRENT_SOURCE_DIR}
+ LIBRARIES
+ Qt::CorePrivate
+ PUBLIC_LIBRARIES
+ Qt::Core
+ PRIVATE_MODULE_INTERFACE
+ Qt::CorePrivate
+ GENERATE_CPP_EXPORTS
+)
+
+## Scopes:
+#####################################################################
+
+qt_internal_extend_target(SerialPort CONDITION QT_FEATURE_libudev AND UNIX
+ DEFINES
+ LINK_LIBUDEV
+ LIBRARIES
+ PkgConfig::Libudev
+)
+
+qt_internal_extend_target(SerialPort CONDITION WIN32
+ SOURCES
+ qserialport_win.cpp
+ qserialportinfo_win.cpp
+ qwinoverlappedionotifier.cpp
+ qwinoverlappedionotifier_p.h
+ LIBRARIES
+ advapi32
+ setupapi
+)
+
+qt_internal_extend_target(SerialPort CONDITION UNIX
+ SOURCES
+ qserialport_unix.cpp
+)
+
+qt_internal_extend_target(SerialPort CONDITION MACOS
+ SOURCES
+ qserialportinfo_osx.cpp
+ LIBRARIES
+ ${FWCoreFoundation}
+ ${FWIOKit}
+)
+
+qt_internal_extend_target(SerialPort CONDITION FREEBSD
+ SOURCES
+ qserialportinfo_freebsd.cpp
+)
+
+qt_internal_extend_target(SerialPort CONDITION UNIX AND NOT FREEBSD AND NOT MACOS
+ SOURCES
+ qserialportinfo_unix.cpp
+)
+
+qt_internal_add_docs(SerialPort
+ doc/qtserialport.qdocconf
+)
+
diff --git a/src/serialport/configure.cmake b/src/serialport/configure.cmake
new file mode 100644
index 0000000..2160603
--- /dev/null
+++ b/src/serialport/configure.cmake
@@ -0,0 +1,46 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
+
+
+#### Inputs
+
+
+
+#### Libraries
+
+
+
+#### Tests
+
+# ntddmodm
+qt_config_compile_test(ntddmodm
+ LABEL "ntddmodm"
+ CODE
+"
+#include <windows.h>
+#include <ntddmodm.h>
+
+int main(int argc, char **argv)
+{
+ (void)argc; (void)argv;
+ /* BEGIN TEST: */
+GUID guid = GUID_DEVINTERFACE_MODEM;
+ /* END TEST: */
+ return 0;
+}
+")
+
+
+
+#### Features
+
+qt_feature("ntddmodm" PRIVATE
+ LABEL "ntddmodm"
+ CONDITION TEST_ntddmodm
+ DISABLE INPUT_ntddmodm STREQUAL 'no'
+)
+qt_feature_definition("ntddmodm" "QT_NO_REDEFINE_GUID_DEVINTERFACE_MODEM")
+qt_configure_add_summary_section(NAME "Serial Port")
+qt_configure_add_summary_entry(ARGS "ntddmodm")
+qt_configure_end_summary_section() # end of "Serial Port" section
diff --git a/src/serialport/configure.json b/src/serialport/configure.json
deleted file mode 100644
index c969b86..0000000
--- a/src/serialport/configure.json
+++ /dev/null
@@ -1,41 +0,0 @@
-{
- "module": "serialport",
- "condition": "!config.integrity && !config.vxworks && !config.winrt && !config.uikit && !config.wasm",
- "depends": [
- "core"
- ],
-
- "tests": {
- "ntddmodm": {
- "label": "ntddmodm",
- "type": "compile",
- "test": {
- "include": [ "windows.h", "ntddmodm.h"],
- "main": [
- "GUID guid = GUID_DEVINTERFACE_MODEM;"
- ]
- }
- }
- },
-
- "features": {
- "ntddmodm": {
- "label": "ntddmodm",
- "disable": "input.ntddmodm == 'no'",
- "condition": "tests.ntddmodm",
- "output": [
- "privateFeature",
- { "type": "define", "negative": true, "name": "QT_NO_REDEFINE_GUID_DEVINTERFACE_MODEM" }
- ]
- }
- },
-
- "summary": [
- {
- "section": "Serial Port",
- "entries": [
- "ntddmodm"
- ]
- }
- ]
-}
diff --git a/src/serialport/doc/images/blockingmaster-example.png b/src/serialport/doc/images/blockingmaster-example.png
deleted file mode 100644
index 9b5fc4a..0000000
--- a/src/serialport/doc/images/blockingmaster-example.png
+++ /dev/null
Binary files differ
diff --git a/src/serialport/doc/images/blockingreceiver-example.png b/src/serialport/doc/images/blockingreceiver-example.png
new file mode 100644
index 0000000..7bdafde
--- /dev/null
+++ b/src/serialport/doc/images/blockingreceiver-example.png
Binary files differ
diff --git a/src/serialport/doc/images/blockingsender-example.png b/src/serialport/doc/images/blockingsender-example.png
new file mode 100644
index 0000000..14ee55c
--- /dev/null
+++ b/src/serialport/doc/images/blockingsender-example.png
Binary files differ
diff --git a/src/serialport/doc/images/blockingslave-example.png b/src/serialport/doc/images/blockingslave-example.png
deleted file mode 100644
index c02ae85..0000000
--- a/src/serialport/doc/images/blockingslave-example.png
+++ /dev/null
Binary files differ
diff --git a/src/serialport/doc/images/cenumerator-example.png b/src/serialport/doc/images/cenumerator-example.png
deleted file mode 100644
index 03792e7..0000000
--- a/src/serialport/doc/images/cenumerator-example.png
+++ /dev/null
Binary files differ
diff --git a/src/serialport/doc/images/creaderasync-example.png b/src/serialport/doc/images/creaderasync-example.png
deleted file mode 100644
index ffa3636..0000000
--- a/src/serialport/doc/images/creaderasync-example.png
+++ /dev/null
Binary files differ
diff --git a/src/serialport/doc/images/creadersync-example.png b/src/serialport/doc/images/creadersync-example.png
deleted file mode 100644
index 476dcbe..0000000
--- a/src/serialport/doc/images/creadersync-example.png
+++ /dev/null
Binary files differ
diff --git a/src/serialport/doc/images/cwriterasync-example.png b/src/serialport/doc/images/cwriterasync-example.png
deleted file mode 100644
index ebe11dc..0000000
--- a/src/serialport/doc/images/cwriterasync-example.png
+++ /dev/null
Binary files differ
diff --git a/src/serialport/doc/images/cwritersync-example.png b/src/serialport/doc/images/cwritersync-example.png
deleted file mode 100644
index 669985d..0000000
--- a/src/serialport/doc/images/cwritersync-example.png
+++ /dev/null
Binary files differ
diff --git a/src/serialport/doc/images/enumerator-example.png b/src/serialport/doc/images/enumerator-example.png
deleted file mode 100644
index c96d990..0000000
--- a/src/serialport/doc/images/enumerator-example.png
+++ /dev/null
Binary files differ
diff --git a/src/serialport/doc/images/terminal-example.png b/src/serialport/doc/images/terminal-example.png
index 9affaae..7cdbd21 100644
--- a/src/serialport/doc/images/terminal-example.png
+++ b/src/serialport/doc/images/terminal-example.png
Binary files differ
diff --git a/src/serialport/doc/qtserialport.qdocconf b/src/serialport/doc/qtserialport.qdocconf
index fbb8e42..a852fb3 100644
--- a/src/serialport/doc/qtserialport.qdocconf
+++ b/src/serialport/doc/qtserialport.qdocconf
@@ -13,10 +13,6 @@ qhp.QtSerialPort.virtualFolder = qtserialport
qhp.QtSerialPort.indexTitle = Qt Serial Port
qhp.QtSerialPort.indexRoot =
-qhp.QtSerialPort.filterAttributes = qtserialport $QT_VERSION qtrefdoc
-qhp.QtSerialPort.customFilters.Qt.name = QtSerialPort $QT_VERSION
-qhp.QtSerialPort.customFilters.Qt.filterAttributes = qtserialport $QT_VERSION
-
qhp.QtSerialPort.subprojects = classes examples
qhp.QtSerialPort.subprojects.classes.title = C++ Classes
@@ -31,13 +27,16 @@ qhp.QtSerialPort.subprojects.examples.sortPages = true
headerdirs += ..
sourcedirs += ..
-exampledirs += ../../../examples/serialport
+exampledirs += \
+ ../../../examples/serialport \
+ snippets
+
+excludedirs += snippets
imagedirs += images
-excludedirs += ../qt4support
examplesinstallpath = serialport
-depends += qtcore qtdoc qtnetwork qmake
+depends += qtcore qtdoc qtnetwork qmake qtcmake
navigation.landingpage = "Qt Serial Port"
navigation.cppclassespage = "Qt Serial Port C++ Classes"
diff --git a/src/serialport/doc/snippets/doc_src_serialport.cpp b/src/serialport/doc/snippets/doc_src_serialport.cpp
new file mode 100644
index 0000000..11476c9
--- /dev/null
+++ b/src/serialport/doc/snippets/doc_src_serialport.cpp
@@ -0,0 +1,41 @@
+// Copyright (C) 2023 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#include <QtCore/qcoreapplication.h>
+#include <QtCore/qdebug.h>
+
+#include <QtSerialPort/qserialportinfo.h>
+
+void enumeratePorts()
+{
+//! [enumerate_ports]
+ const auto serialPortInfos = QSerialPortInfo::availablePorts();
+ for (const QSerialPortInfo &portInfo : serialPortInfos) {
+ qDebug() << "\n"
+ << "Port:" << portInfo.portName() << "\n"
+ << "Location:" << portInfo.systemLocation() << "\n"
+ << "Description:" << portInfo.description() << "\n"
+ << "Manufacturer:" << portInfo.manufacturer() << "\n"
+ << "Serial number:" << portInfo.serialNumber() << "\n"
+ << "Vendor Identifier:"
+ << (portInfo.hasVendorIdentifier()
+ ? QByteArray::number(portInfo.vendorIdentifier(), 16)
+ : QByteArray()) << "\n"
+ << "Product Identifier:"
+ << (portInfo.hasProductIdentifier()
+ ? QByteArray::number(portInfo.productIdentifier(), 16)
+ : QByteArray());
+ }
+//! [enumerate_ports]
+}
+
+int main(int argc, char **argv)
+{
+ QCoreApplication app(argc, argv);
+
+ enumeratePorts();
+
+ return app.exec();
+}
+
+#include "doc_src_serialport.moc"
diff --git a/src/serialport/doc/src/index.qdoc b/src/serialport/doc/src/index.qdoc
index 041188e..d91f25c 100644
--- a/src/serialport/doc/src/index.qdoc
+++ b/src/serialport/doc/src/index.qdoc
@@ -1,29 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 - 2012 Denis Shienkov <denis.shienkov@gmail.com>
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2011 - 2012 Denis Shienkov <denis.shienkov@gmail.com>
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
\page qtserialport-index.html
@@ -31,9 +7,9 @@
\title Qt Serial Port
\brief Provides an API to make serial programming simple and portable.
- Qt Serial Port provides the basic functionality, which includes
- configuring, I/O operations, getting and setting the control signals of the
- RS-232 pinouts.
+ Qt Serial Port provides basic functionality for configuration, I/O
+ operations, and getting and setting the control signals of the RS-232
+ pinouts.
The following items are not supported by this module:
\list
@@ -43,26 +19,21 @@
\li Pinout signal change notification.
\endlist
- To use the serial port in your application, add the following include
- statement:
+ \section1 Using the Module
- \code
- #include <QSerialPort>
- \endcode
+ \include {module-use.qdocinc} {using the c++ api}
- For information about available serial ports, use the following include
- statement:
+ \section2 Building with Cmake
- \code
- #include <QSerialPortInfo>
- \endcode
+ \include {module-use.qdocinc} {building with cmake} {SerialPort}
- To link against the module, add this line to your \l qmake \c
- .pro file:
+ \section2 Building with qmake
- \code
- QT += serialport
- \endcode
+ \include {module-use.qdocinc} {building_with_qmake} {serialport}
+
+ \section1 Module Evolution
+ \l{Changes to Qt SerialPort} lists important changes in the module API
+ and functionality that were done for the Qt 6 series of Qt.
\section1 Related Information
\list
diff --git a/src/serialport/doc/src/qt6-changes.qdoc b/src/serialport/doc/src/qt6-changes.qdoc
new file mode 100644
index 0000000..d3ded94
--- /dev/null
+++ b/src/serialport/doc/src/qt6-changes.qdoc
@@ -0,0 +1,26 @@
+// Copyright (C) 2021 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
+/*!
+ \page qtserialport-changes-qt6.html
+
+ \title Changes to Qt SerialPort
+ \ingroup changes-qt-5-to-6
+ \brief Migrate Qt SerialPort to Qt 6.
+
+ Qt 6 is a result of the conscious effort to make the framework more
+ efficient and easy to use.
+ We try to maintain binary and source compatibility for all the public
+ APIs in each release. But some changes were inevitable in an effort to
+ make Qt a better framework.
+ In this topic we summarize those changes in Qt SerialPort module, and
+ provide guidance to handle them.
+
+ \section1 Changes overview
+ The Qt SerialPort module is generally speaking source compatible with the
+ Qt5 version and users of the library should be able to continue with no or
+ minor changes to their project.
+
+ \section1 Build system
+ As with Qt6 in general, the Qt SerialPort module has cmake support in
+ addition to qmake.
+*/
diff --git a/src/serialport/doc/src/qtserialport-examples.qdoc b/src/serialport/doc/src/qtserialport-examples.qdoc
index c680224..51bd949 100644
--- a/src/serialport/doc/src/qtserialport-examples.qdoc
+++ b/src/serialport/doc/src/qtserialport-examples.qdoc
@@ -1,31 +1,7 @@
-/****************************************************************************
-**
-** Copyright (C) 2011-2012 Denis Shienkov <denis.shienkov@gmail.com>
-** Copyright (C) 2012 Laszlo Papp <lpapp@kde.org>
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2011-2012 Denis Shienkov <denis.shienkov@gmail.com>
+// Copyright (C) 2012 Laszlo Papp <lpapp@kde.org>
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
\title Qt Serial Port Examples
diff --git a/src/serialport/doc/src/qtserialport-module-use.qdocinc b/src/serialport/doc/src/qtserialport-module-use.qdocinc
new file mode 100644
index 0000000..e723fd9
--- /dev/null
+++ b/src/serialport/doc/src/qtserialport-module-use.qdocinc
@@ -0,0 +1,15 @@
+// Copyright (C) 2021 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
+
+//! [cmakebuild]
+ \code
+ find_package(Qt6 REQUIRED COMPONENTS SerialPort)
+ target_link_libraries(mytarget PRIVATE Qt6::SerialPort)
+ \endcode
+//! [cmakebuild]
+
+//! [qmakebuild]
+ \code
+ QT += serialport
+ \endcode
+//! [qmakebuild]
diff --git a/src/serialport/doc/src/qtserialport-module.qdoc b/src/serialport/doc/src/qtserialport-module.qdoc
index 6c153a0..cf4523b 100644
--- a/src/serialport/doc/src/qtserialport-module.qdoc
+++ b/src/serialport/doc/src/qtserialport-module.qdoc
@@ -1,35 +1,12 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 - 2012 Denis Shienkov <denis.shienkov@gmail.com>
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2011 - 2012 Denis Shienkov <denis.shienkov@gmail.com>
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
\module QtSerialPort
\title Qt Serial Port C++ Classes
\ingroup modules
\qtvariable serialport
+ \qtcmakepackage SerialPort
\brief List of C++ classes that enable access to a serial port.
To use QSerialPort in your application, add the following include
@@ -45,10 +22,11 @@
#include <QSerialPortInfo>
\endcode
- To link against the module, add this line to your \l qmake \c
- .pro file:
+ To use the module with cmake, use the \c{find_package()} command to locate
+ the needed module components in the \c{Qt6} package:
+ \include qtserialport-module-use.qdocinc cmakebuild
- \code
- QT += serialport
- \endcode
+ To use the module for building with qmake, add the module as a value of the
+ \c QT variable in the project's .pro file:
+ \include qtserialport-module-use.qdocinc qmakebuild
*/
diff --git a/src/serialport/qserialport.cpp b/src/serialport/qserialport.cpp
index 44d6cd1..d4265b6 100644
--- a/src/serialport/qserialport.cpp
+++ b/src/serialport/qserialport.cpp
@@ -1,44 +1,8 @@
-/****************************************************************************
-**
-** Copyright (C) 2011-2012 Denis Shienkov <denis.shienkov@gmail.com>
-** Copyright (C) 2011 Sergey Belyashov <Sergey.Belyashov@gmail.com>
-** Copyright (C) 2012 Laszlo Papp <lpapp@kde.org>
-** Copyright (C) 2012 Andre Hartmann <aha_1980@gmx.de>
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtSerialPort module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2011-2012 Denis Shienkov <denis.shienkov@gmail.com>
+// Copyright (C) 2011 Sergey Belyashov <Sergey.Belyashov@gmail.com>
+// Copyright (C) 2012 Laszlo Papp <lpapp@kde.org>
+// Copyright (C) 2012 Andre Hartmann <aha_1980@gmx.de>
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#include "qserialport.h"
#include "qserialportinfo.h"
@@ -99,12 +63,10 @@ void QSerialPortPrivate::setError(const QSerialPortErrorInfo &errorInfo)
{
Q_Q(QSerialPort);
- error = errorInfo.errorCode;
q->setErrorString(errorInfo.errorString);
+ error.setValue(errorInfo.errorCode);
+ error.notify();
emit q->errorOccurred(error);
-#if QT_DEPRECATED_SINCE(5, 8)
- emit q->error(error);
-#endif
}
/*!
@@ -235,9 +197,6 @@ void QSerialPortPrivate::setError(const QSerialPortErrorInfo &errorInfo)
\value Baud38400 38400 baud.
\value Baud57600 57600 baud.
\value Baud115200 115200 baud.
- \value UnknownBaud Unknown baud. This value is obsolete. It is provided to
- keep old source code working. We strongly advise against
- using it in new code.
\sa QSerialPort::baudRate
*/
@@ -259,9 +218,6 @@ void QSerialPortPrivate::setError(const QSerialPortErrorInfo &errorInfo)
is used for most kinds of data, as this size matches
the size of a byte. It is almost universally used in
newer applications.
- \value UnknownDataBits Unknown number of bits. This value is obsolete. It
- is provided to keep old source code working. We
- strongly advise against using it in new code.
\sa QSerialPort::dataBits
*/
@@ -285,9 +241,6 @@ void QSerialPortPrivate::setError(const QSerialPortErrorInfo &errorInfo)
\value MarkParity Mark parity. The parity bit is always set to the
mark signal condition (logical 1). It does not
provide error detection information.
- \value UnknownParity Unknown parity. This value is obsolete. It is
- provided to keep old source code working. We
- strongly advise against using it in new code.
\sa QSerialPort::parity
*/
@@ -300,9 +253,6 @@ void QSerialPortPrivate::setError(const QSerialPortErrorInfo &errorInfo)
\value OneStop 1 stop bit.
\value OneAndHalfStop 1.5 stop bits. This is only for the Windows platform.
\value TwoStop 2 stop bits.
- \value UnknownStopBits Unknown number of stop bits. This value is obsolete.
- It is provided to keep old source code working. We
- strongly advise against using it in new code.
\sa QSerialPort::stopBits
*/
@@ -315,9 +265,6 @@ void QSerialPortPrivate::setError(const QSerialPortErrorInfo &errorInfo)
\value NoFlowControl No flow control.
\value HardwareControl Hardware flow control (RTS/CTS).
\value SoftwareControl Software flow control (XON/XOFF).
- \value UnknownFlowControl Unknown flow control. This value is obsolete. It
- is provided to keep old source code working. We
- strongly advise against using it in new code.
\sa QSerialPort::flowControl
*/
@@ -328,14 +275,6 @@ void QSerialPortPrivate::setError(const QSerialPortErrorInfo &errorInfo)
This enum describes the possible RS-232 pinout signals.
\value NoSignal No line active
- \value TransmittedDataSignal TxD (Transmitted Data). This value is
- obsolete. It is provided to keep old
- source code working. We strongly
- advise against using it in new code.
- \value ReceivedDataSignal RxD (Received Data). This value is
- obsolete. It is provided to keep old
- source code working. We strongly
- advise against using it in new code.
\value DataTerminalReadySignal DTR (Data Terminal Ready).
\value DataCarrierDetectSignal DCD (Data Carrier Detect).
\value DataSetReadySignal DSR (Data Set Ready).
@@ -349,24 +288,6 @@ void QSerialPortPrivate::setError(const QSerialPortErrorInfo &errorInfo)
QSerialPort::requestToSend
*/
-#if QT_DEPRECATED_SINCE(5, 2)
-/*!
- \enum QSerialPort::DataErrorPolicy
- \obsolete
-
- This enum describes the policies for the received symbols
- while parity errors were detected.
-
- \value SkipPolicy Skips the bad character.
- \value PassZeroPolicy Replaces bad character with zero.
- \value IgnorePolicy Ignores the error for a bad character.
- \value StopReceivingPolicy Stops data reception on error.
- \value UnknownPolicy Unknown policy.
-
- \sa QSerialPort::dataErrorPolicy
-*/
-#endif
-
/*!
\enum QSerialPort::SerialPortError
@@ -391,18 +312,6 @@ void QSerialPortPrivate::setError(const QSerialPortErrorInfo &errorInfo)
device is open. This value was introduced in
QtSerialPort 5.2.
- \value ParityError Parity error detected by the hardware while
- reading data. This value is obsolete. We strongly
- advise against using it in new code.
-
- \value FramingError Framing error detected by the hardware while
- reading data. This value is obsolete. We strongly
- advise against using it in new code.
-
- \value BreakConditionError Break condition detected by the hardware on
- the input line. This value is obsolete. We strongly
- advise against using it in new code.
-
\value WriteError An I/O error occurred while writing the data.
\value ReadError An I/O error occurred while reading the data.
@@ -429,7 +338,6 @@ void QSerialPortPrivate::setError(const QSerialPortErrorInfo &errorInfo)
*/
QSerialPort::QSerialPort(QObject *parent)
: QIODevice(*new QSerialPortPrivate, parent)
- , d_dummy(0)
{
}
@@ -441,7 +349,6 @@ QSerialPort::QSerialPort(QObject *parent)
*/
QSerialPort::QSerialPort(const QString &name, QObject *parent)
: QIODevice(*new QSerialPortPrivate, parent)
- , d_dummy(0)
{
setPortName(name);
}
@@ -453,7 +360,6 @@ QSerialPort::QSerialPort(const QString &name, QObject *parent)
*/
QSerialPort::QSerialPort(const QSerialPortInfo &serialPortInfo, QObject *parent)
: QIODevice(*new QSerialPortPrivate, parent)
- , d_dummy(0)
{
setPort(serialPortInfo);
}
@@ -531,10 +437,10 @@ QString QSerialPort::portName() const
not set any of the port settings successfully. In that case, the port is
closed automatically not to leave the port around with incorrect settings.
- \warning The \a mode has to be QIODevice::ReadOnly, QIODevice::WriteOnly,
- or QIODevice::ReadWrite. Other modes are unsupported.
+ \warning The \a mode has to be QIODeviceBase::ReadOnly, QIODeviceBase::WriteOnly,
+ or QIODeviceBase::ReadWrite. Other modes are unsupported.
- \sa QIODevice::OpenMode, setPort()
+ \sa QIODeviceBase::OpenMode, setPort()
*/
bool QSerialPort::open(OpenMode mode)
{
@@ -577,57 +483,10 @@ void QSerialPort::close()
}
d->close();
- d->isBreakEnabled = false;
+ d->isBreakEnabled.setValue(false);
QIODevice::close();
}
-QT_WARNING_PUSH
-QT_WARNING_DISABLE_DEPRECATED
-
-#if QT_DEPRECATED_SINCE(5, 3)
-/*!
- \property QSerialPort::settingsRestoredOnClose
- \brief the flag which specifies to restore the previous settings when closing
- the serial port.
- \obsolete
-
- If this flag is \c true, the settings will be restored; otherwise not.
- The default state of the QSerialPort class is to restore the
- settings.
-*/
-void QSerialPort::setSettingsRestoredOnClose(bool restore)
-{
- Q_D(QSerialPort);
-
- if (d->settingsRestoredOnClose != restore) {
- d->settingsRestoredOnClose = restore;
- emit settingsRestoredOnCloseChanged(d->settingsRestoredOnClose);
- }
-}
-
-QT_WARNING_POP
-
-bool QSerialPort::settingsRestoredOnClose() const
-{
- Q_D(const QSerialPort);
- return d->settingsRestoredOnClose;
-}
-#endif // QT_DEPRECATED_SINCE(5,3)
-
-#if QT_DEPRECATED_SINCE(5, 5)
-/*!
- \fn void QSerialPort::settingsRestoredOnCloseChanged(bool restore)
- \obsolete
-
- This signal is emitted after the flag which specifies to restore the
- previous settings while closing the serial port has been changed. The new
- flag which specifies to restore the previous settings while closing the serial
- port is passed as \a restore.
-
- \sa QSerialPort::settingsRestoredOnClose
-*/
-#endif // QT_DEPRECATED_SINCE(5, 5)
-
/*!
\property QSerialPort::baudRate
\brief the data baud rate for the desired direction
@@ -712,15 +571,16 @@ qint32 QSerialPort::baudRate(Directions directions) const
bool QSerialPort::setDataBits(DataBits dataBits)
{
Q_D(QSerialPort);
-
+ d->dataBits.removeBindingUnlessInWrapper();
+ const auto currentDataBits = d->dataBits.value();
if (!isOpen() || d->setDataBits(dataBits)) {
- if (d->dataBits != dataBits) {
- d->dataBits = dataBits;
- emit dataBitsChanged(d->dataBits);
+ d->dataBits.setValueBypassingBindings(dataBits);
+ if (currentDataBits != dataBits) {
+ d->dataBits.notify();
+ emit dataBitsChanged(dataBits);
}
return true;
}
-
return false;
}
@@ -730,6 +590,11 @@ QSerialPort::DataBits QSerialPort::dataBits() const
return d->dataBits;
}
+QBindable<QSerialPort::DataBits> QSerialPort::bindableDataBits()
+{
+ return &d_func()->dataBits;
+}
+
/*!
\fn void QSerialPort::dataBitsChanged(DataBits dataBits)
@@ -757,15 +622,16 @@ QSerialPort::DataBits QSerialPort::dataBits() const
bool QSerialPort::setParity(Parity parity)
{
Q_D(QSerialPort);
-
+ d->parity.removeBindingUnlessInWrapper();
+ const auto currentParity = d->parity.value();
if (!isOpen() || d->setParity(parity)) {
- if (d->parity != parity) {
- d->parity = parity;
- emit parityChanged(d->parity);
+ d->parity.setValueBypassingBindings(parity);
+ if (currentParity != parity) {
+ d->parity.notify();
+ emit parityChanged(parity);
}
return true;
}
-
return false;
}
@@ -775,6 +641,11 @@ QSerialPort::Parity QSerialPort::parity() const
return d->parity;
}
+QBindable<QSerialPort::Parity> QSerialPort::bindableParity()
+{
+ return &d_func()->parity;
+}
+
/*!
\fn void QSerialPort::parityChanged(Parity parity)
@@ -801,15 +672,16 @@ QSerialPort::Parity QSerialPort::parity() const
bool QSerialPort::setStopBits(StopBits stopBits)
{
Q_D(QSerialPort);
-
+ d->stopBits.removeBindingUnlessInWrapper();
+ const auto currentStopBits = d->stopBits.value();
if (!isOpen() || d->setStopBits(stopBits)) {
- if (d->stopBits != stopBits) {
- d->stopBits = stopBits;
- emit stopBitsChanged(d->stopBits);
+ d->stopBits.setValueBypassingBindings(stopBits);
+ if (currentStopBits != stopBits) {
+ d->stopBits.notify();
+ emit stopBitsChanged(stopBits);
}
return true;
}
-
return false;
}
@@ -819,6 +691,11 @@ QSerialPort::StopBits QSerialPort::stopBits() const
return d->stopBits;
}
+QBindable<bool> QSerialPort::bindableStopBits()
+{
+ return &d_func()->stopBits;
+}
+
/*!
\fn void QSerialPort::stopBitsChanged(StopBits stopBits)
@@ -845,15 +722,16 @@ QSerialPort::StopBits QSerialPort::stopBits() const
bool QSerialPort::setFlowControl(FlowControl flowControl)
{
Q_D(QSerialPort);
-
+ d->flowControl.removeBindingUnlessInWrapper();
+ const auto currentFlowControl = d->flowControl.value();
if (!isOpen() || d->setFlowControl(flowControl)) {
- if (d->flowControl != flowControl) {
- d->flowControl = flowControl;
- emit flowControlChanged(d->flowControl);
+ d->flowControl.setValueBypassingBindings(flowControl);
+ if (currentFlowControl != flowControl) {
+ d->flowControl.notify();
+ emit flowControlChanged(flowControl);
}
return true;
}
-
return false;
}
@@ -863,6 +741,11 @@ QSerialPort::FlowControl QSerialPort::flowControl() const
return d->flowControl;
}
+QBindable<QSerialPort::FlowControl> QSerialPort::bindableFlowControl()
+{
+ return &d_func()->flowControl;
+}
+
/*!
\fn void QSerialPort::flowControlChanged(FlowControl flow)
@@ -1061,89 +944,6 @@ bool QSerialPort::clear(Directions directions)
}
/*!
- \reimp
-
- Returns \c true if no more data is currently available for reading; otherwise
- returns \c false.
-
- This function is most commonly used when reading data from the
- serial port in a loop. For example:
-
- \code
- // This slot is connected to QSerialPort::readyRead()
- void QSerialPortClass::readyReadSlot()
- {
- while (!port.atEnd()) {
- QByteArray data = port.read(100);
- ....
- }
- }
- \endcode
-
- \sa bytesAvailable(), readyRead()
- */
-bool QSerialPort::atEnd() const
-{
- return QIODevice::atEnd();
-}
-
-#if QT_DEPRECATED_SINCE(5, 2)
-/*!
- \property QSerialPort::dataErrorPolicy
- \brief the error policy for how the process receives characters in the case where
- a parity error is detected.
- \obsolete
-
- If the setting is successful, returns \c true; otherwise returns \c false. The
- default policy set is IgnorePolicy.
-
- \note The serial port has to be open before trying to set this property;
- otherwise returns \c false and sets the NotOpenError error code. This is a bit
- unusual as opposed to the regular Qt property settings of a class. However,
- this is a special use case since the property is set through the interaction
- with the kernel and hardware. Hence, the two scenarios cannot be completely
- compared to each other.
-*/
-bool QSerialPort::setDataErrorPolicy(DataErrorPolicy policy)
-{
- Q_D(QSerialPort);
-
- if (!isOpen()) {
- d->setError(QSerialPortErrorInfo(QSerialPort::NotOpenError));
- qWarning("%s: device not open", Q_FUNC_INFO);
- return false;
- }
-
- if (policy != QSerialPort::IgnorePolicy) {
- d->setError(QSerialPortErrorInfo(QSerialPort::UnsupportedOperationError,
- tr("The device supports only the ignoring policy")));
- return false;
- }
-
- return true;
-}
-
-QSerialPort::DataErrorPolicy QSerialPort::dataErrorPolicy() const
-{
- return QSerialPort::IgnorePolicy;
-}
-#endif // QT_DEPRECATED_SINCE(5, 2)
-
-#if QT_DEPRECATED_SINCE(5, 5)
-/*!
- \fn void QSerialPort::dataErrorPolicyChanged(DataErrorPolicy policy)
- \obsolete
-
- This signal is emitted after the error policy for how the process receives
- characters in case of parity error detection has been changed. The new error
- policy for how the process receives the character in case of parity error
- detection is passed as \a policy.
-
- \sa QSerialPort::dataErrorPolicy
-*/
-#endif // QT_DEPRECATED_SINCE(5, 5)
-
-/*!
\property QSerialPort::error
\brief the error status of the serial port
@@ -1166,14 +966,10 @@ void QSerialPort::clearError()
d->setError(QSerialPortErrorInfo(QSerialPort::NoError));
}
-#if QT_DEPRECATED_SINCE(5, 8)
-/*!
- \fn void QSerialPort::error(SerialPortError error)
- \obsolete
-
- Use errorOccurred() instead.
-*/
-#endif
+QBindable<QSerialPort::SerialPortError> QSerialPort::bindableError() const
+{
+ return &d_func()->error;
+}
/*!
\fn void QSerialPort::errorOccurred(SerialPortError error)
@@ -1327,37 +1123,6 @@ bool QSerialPort::waitForBytesWritten(int msecs)
return d->waitForBytesWritten(msecs);
}
-#if QT_DEPRECATED_SINCE(5, 5)
-/*!
- Sends a continuous stream of zero bits during a specified period
- of time \a duration in msec if the terminal is using asynchronous
- serial data. If successful, returns \c true; otherwise returns \c false.
-
- If the duration is zero then zero bits are transmitted by at least
- \c 0.25 seconds, but no more than \c 0.5 seconds.
-
- If the duration is non zero then zero bits are transmitted within a certain
- period of time depending on the implementation.
-
- \note The serial port has to be open before trying to send a break
- duration; otherwise returns \c false and sets the NotOpenError error code.
-
- \sa setBreakEnabled()
-*/
-bool QSerialPort::sendBreak(int duration)
-{
- Q_D(QSerialPort);
-
- if (!isOpen()) {
- d->setError(QSerialPortErrorInfo(QSerialPort::NotOpenError));
- qWarning("%s: device not open", Q_FUNC_INFO);
- return false;
- }
-
- return d->sendBreak(duration);
-}
-#endif // QT_DEPRECATED_SINCE(5, 5)
-
/*!
\property QSerialPort::breakEnabled
\since 5.5
@@ -1377,19 +1142,20 @@ bool QSerialPort::sendBreak(int duration)
bool QSerialPort::setBreakEnabled(bool set)
{
Q_D(QSerialPort);
-
- if (!isOpen()) {
+ d->isBreakEnabled.removeBindingUnlessInWrapper();
+ const auto currentSet = d->isBreakEnabled.value();
+ if (isOpen()) {
+ if (d->setBreakEnabled(set)) {
+ d->isBreakEnabled.setValueBypassingBindings(set);
+ if (currentSet != set) {
+ d->isBreakEnabled.notify();
+ emit breakEnabledChanged(set);
+ }
+ return true;
+ }
+ } else {
d->setError(QSerialPortErrorInfo(QSerialPort::NotOpenError));
qWarning("%s: device not open", Q_FUNC_INFO);
- return false;
- }
-
- if (d->setBreakEnabled(set)) {
- if (d->isBreakEnabled != set) {
- d->isBreakEnabled = set;
- emit breakEnabledChanged(d->isBreakEnabled);
- }
- return true;
}
return false;
}
@@ -1400,6 +1166,11 @@ bool QSerialPort::isBreakEnabled() const
return d->isBreakEnabled;
}
+QBindable<bool> QSerialPort::bindableIsBreakEnabled()
+{
+ return &d_func()->isBreakEnabled;
+}
+
/*!
\reimp
diff --git a/src/serialport/qserialport.h b/src/serialport/qserialport.h
index c4c7367..3352fdb 100644
--- a/src/serialport/qserialport.h
+++ b/src/serialport/qserialport.h
@@ -1,42 +1,6 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Denis Shienkov <denis.shienkov@gmail.com>
-** Copyright (C) 2013 Laszlo Papp <lpapp@kde.org>
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtSerialPort module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2012 Denis Shienkov <denis.shienkov@gmail.com>
+// Copyright (C) 2013 Laszlo Papp <lpapp@kde.org>
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#ifndef QSERIALPORT_H
#define QSERIALPORT_H
@@ -56,20 +20,19 @@ class Q_SERIALPORT_EXPORT QSerialPort : public QIODevice
Q_DECLARE_PRIVATE(QSerialPort)
Q_PROPERTY(qint32 baudRate READ baudRate WRITE setBaudRate NOTIFY baudRateChanged)
- Q_PROPERTY(DataBits dataBits READ dataBits WRITE setDataBits NOTIFY dataBitsChanged)
- Q_PROPERTY(Parity parity READ parity WRITE setParity NOTIFY parityChanged)
- Q_PROPERTY(StopBits stopBits READ stopBits WRITE setStopBits NOTIFY stopBitsChanged)
- Q_PROPERTY(FlowControl flowControl READ flowControl WRITE setFlowControl NOTIFY flowControlChanged)
-#if QT_DEPRECATED_SINCE(5, 2)
- Q_PROPERTY(DataErrorPolicy dataErrorPolicy READ dataErrorPolicy WRITE setDataErrorPolicy NOTIFY dataErrorPolicyChanged)
-#endif
- Q_PROPERTY(bool dataTerminalReady READ isDataTerminalReady WRITE setDataTerminalReady NOTIFY dataTerminalReadyChanged)
+ Q_PROPERTY(DataBits dataBits READ dataBits WRITE setDataBits NOTIFY dataBitsChanged
+ BINDABLE bindableDataBits)
+ Q_PROPERTY(Parity parity READ parity WRITE setParity NOTIFY parityChanged BINDABLE bindableParity)
+ Q_PROPERTY(StopBits stopBits READ stopBits WRITE setStopBits NOTIFY stopBitsChanged
+ BINDABLE bindableStopBits)
+ Q_PROPERTY(FlowControl flowControl READ flowControl WRITE setFlowControl NOTIFY flowControlChanged
+ BINDABLE bindableFlowControl)
+ Q_PROPERTY(bool dataTerminalReady READ isDataTerminalReady WRITE setDataTerminalReady
+ NOTIFY dataTerminalReadyChanged)
Q_PROPERTY(bool requestToSend READ isRequestToSend WRITE setRequestToSend NOTIFY requestToSendChanged)
- Q_PROPERTY(SerialPortError error READ error RESET clearError NOTIFY error)
-#if QT_DEPRECATED_SINCE(5, 3)
- Q_PROPERTY(bool settingsRestoredOnClose READ settingsRestoredOnClose WRITE setSettingsRestoredOnClose NOTIFY settingsRestoredOnCloseChanged)
-#endif
- Q_PROPERTY(bool breakEnabled READ isBreakEnabled WRITE setBreakEnabled NOTIFY breakEnabledChanged)
+ Q_PROPERTY(SerialPortError error READ error RESET clearError NOTIFY errorOccurred BINDABLE bindableError)
+ Q_PROPERTY(bool breakEnabled READ isBreakEnabled WRITE setBreakEnabled NOTIFY breakEnabledChanged
+ BINDABLE bindableIsBreakEnabled)
#if defined(Q_OS_WIN32)
typedef void* Handle;
@@ -95,8 +58,7 @@ public:
Baud19200 = 19200,
Baud38400 = 38400,
Baud57600 = 57600,
- Baud115200 = 115200,
- UnknownBaud = -1
+ Baud115200 = 115200
};
Q_ENUM(BaudRate)
@@ -104,8 +66,7 @@ public:
Data5 = 5,
Data6 = 6,
Data7 = 7,
- Data8 = 8,
- UnknownDataBits = -1
+ Data8 = 8
};
Q_ENUM(DataBits)
@@ -114,31 +75,26 @@ public:
EvenParity = 2,
OddParity = 3,
SpaceParity = 4,
- MarkParity = 5,
- UnknownParity = -1
+ MarkParity = 5
};
Q_ENUM(Parity)
enum StopBits {
OneStop = 1,
OneAndHalfStop = 3,
- TwoStop = 2,
- UnknownStopBits = -1
+ TwoStop = 2
};
Q_ENUM(StopBits)
enum FlowControl {
NoFlowControl,
HardwareControl,
- SoftwareControl,
- UnknownFlowControl = -1
+ SoftwareControl
};
Q_ENUM(FlowControl)
enum PinoutSignal {
NoSignal = 0x00,
- TransmittedDataSignal = 0x01,
- ReceivedDataSignal = 0x02,
DataTerminalReadySignal = 0x04,
DataCarrierDetectSignal = 0x08,
DataSetReadySignal = 0x10,
@@ -151,37 +107,11 @@ public:
Q_FLAG(PinoutSignal)
Q_DECLARE_FLAGS(PinoutSignals, PinoutSignal)
-#if QT_DEPRECATED_SINCE(5, 2)
-#if defined(Q_CC_MSVC) && !defined(Q_CC_CLANG)
-#pragma deprecated(UnknownBaud)
-#pragma deprecated(UnknownDataBits)
-#pragma deprecated(UnknownParity)
-#pragma deprecated(UnknownStopBits)
-#pragma deprecated(UnknownFlowControl)
-#pragma deprecated(TransmittedDataSignal)
-#pragma deprecated(ReceivedDataSignal)
-#endif
-#endif
-
-#if QT_DEPRECATED_SINCE(5, 2)
- enum DataErrorPolicy {
- SkipPolicy,
- PassZeroPolicy,
- IgnorePolicy,
- StopReceivingPolicy,
- UnknownPolicy = -1
- };
- Q_ENUM(DataErrorPolicy)
-#endif
-
enum SerialPortError {
NoError,
DeviceNotFoundError,
PermissionError,
OpenError,
- ParityError,
- FramingError,
- BreakConditionError,
WriteError,
ReadError,
ResourceError,
@@ -192,14 +122,6 @@ public:
};
Q_ENUM(SerialPortError)
-#if QT_DEPRECATED_SINCE(5, 6)
-#if defined(Q_CC_MSVC) && !defined(Q_CC_CLANG)
-#pragma deprecated(ParityError)
-#pragma deprecated(FramingError)
-#pragma deprecated(BreakConditionError)
-#endif
-#endif
-
explicit QSerialPort(QObject *parent = nullptr);
explicit QSerialPort(const QString &name, QObject *parent = nullptr);
explicit QSerialPort(const QSerialPortInfo &info, QObject *parent = nullptr);
@@ -213,25 +135,24 @@ public:
bool open(OpenMode mode) override;
void close() override;
-#if QT_DEPRECATED_SINCE(5, 3)
- QT_DEPRECATED void setSettingsRestoredOnClose(bool restore);
- QT_DEPRECATED bool settingsRestoredOnClose() const;
-#endif
-
bool setBaudRate(qint32 baudRate, Directions directions = AllDirections);
qint32 baudRate(Directions directions = AllDirections) const;
bool setDataBits(DataBits dataBits);
DataBits dataBits() const;
+ QBindable<DataBits> bindableDataBits();
bool setParity(Parity parity);
Parity parity() const;
+ QBindable<Parity> bindableParity();
bool setStopBits(StopBits stopBits);
StopBits stopBits() const;
+ QBindable<bool> bindableStopBits();
bool setFlowControl(FlowControl flowControl);
FlowControl flowControl() const;
+ QBindable<FlowControl> bindableFlowControl();
bool setDataTerminalReady(bool set);
bool isDataTerminalReady();
@@ -243,15 +164,10 @@ public:
bool flush();
bool clear(Directions directions = AllDirections);
- bool atEnd() const override; // ### Qt6: remove me
-
-#if QT_DEPRECATED_SINCE(5, 2)
- QT_DEPRECATED bool setDataErrorPolicy(DataErrorPolicy policy = IgnorePolicy);
- QT_DEPRECATED DataErrorPolicy dataErrorPolicy() const;
-#endif
SerialPortError error() const;
void clearError();
+ QBindable<SerialPortError> bindableError() const;
qint64 readBufferSize() const;
void setReadBufferSize(qint64 size);
@@ -265,11 +181,9 @@ public:
bool waitForReadyRead(int msecs = 30000) override;
bool waitForBytesWritten(int msecs = 30000) override;
-#if QT_DEPRECATED_SINCE(5, 5)
- QT_DEPRECATED bool sendBreak(int duration = 0);
-#endif
bool setBreakEnabled(bool set = true);
bool isBreakEnabled() const;
+ QBindable<bool> bindableIsBreakEnabled();
Handle handle() const;
@@ -279,18 +193,9 @@ Q_SIGNALS:
void parityChanged(QSerialPort::Parity parity);
void stopBitsChanged(QSerialPort::StopBits stopBits);
void flowControlChanged(QSerialPort::FlowControl flowControl);
-#if QT_DEPRECATED_SINCE(5, 5)
- QT_DEPRECATED void dataErrorPolicyChanged(QSerialPort::DataErrorPolicy policy);
-#endif
void dataTerminalReadyChanged(bool set);
void requestToSendChanged(bool set);
-#if QT_DEPRECATED_SINCE(5, 8)
- void error(QSerialPort::SerialPortError serialPortError);
-#endif
void errorOccurred(QSerialPort::SerialPortError error);
-#if QT_DEPRECATED_SINCE(5, 5)
- QT_DEPRECATED void settingsRestoredOnCloseChanged(bool restore);
-#endif
void breakEnabledChanged(bool set);
protected:
@@ -299,13 +204,11 @@ protected:
qint64 writeData(const char *data, qint64 maxSize) override;
private:
- // ### Qt6: remove me.
- QSerialPortPrivate * const d_dummy;
-
Q_DISABLE_COPY(QSerialPort)
#if defined(Q_OS_WIN32)
Q_PRIVATE_SLOT(d_func(), bool _q_startAsyncWrite())
+ Q_PRIVATE_SLOT(d_func(), void _q_notified(quint32, quint32, OVERLAPPED*))
#endif
};
diff --git a/src/serialport/qserialport_p.h b/src/serialport/qserialport_p.h
index 7348aed..fd9fee3 100644
--- a/src/serialport/qserialport_p.h
+++ b/src/serialport/qserialport_p.h
@@ -1,43 +1,7 @@
-/****************************************************************************
-**
-** Copyright (C) 2011-2012 Denis Shienkov <denis.shienkov@gmail.com>
-** Copyright (C) 2011 Sergey Belyashov <Sergey.Belyashov@gmail.com>
-** Copyright (C) 2012 Laszlo Papp <lpapp@kde.org>
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtSerialPort module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2011-2012 Denis Shienkov <denis.shienkov@gmail.com>
+// Copyright (C) 2011 Sergey Belyashov <Sergey.Belyashov@gmail.com>
+// Copyright (C) 2012 Laszlo Papp <lpapp@kde.org>
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#ifndef QSERIALPORT_P_H
#define QSERIALPORT_P_H
@@ -55,14 +19,17 @@
#include "qserialport.h"
-#include <private/qiodevice_p.h>
#include <qdeadlinetimer.h>
+#include <private/qiodevice_p.h>
+#include <private/qproperty_p.h>
+
+#include <memory>
+
#if defined(Q_OS_WIN32)
# include <qt_windows.h>
#elif defined(Q_OS_UNIX)
# include <QtCore/qlockfile.h>
-# include <QtCore/qscopedpointer.h>
# include <QtCore/qfileinfo.h>
# include <QtCore/qstringlist.h>
# include <limits.h>
@@ -104,6 +71,7 @@ struct serial_struct {
QT_BEGIN_NAMESPACE
+class QWinOverlappedIoNotifier;
class QTimer;
class QSocketNotifier;
@@ -114,7 +82,7 @@ QString serialPortLockFilePath(const QString &portName);
class QSerialPortErrorInfo
{
public:
- explicit QSerialPortErrorInfo(QSerialPort::SerialPortError newErrorCode = QSerialPort::UnknownError,
+ QSerialPortErrorInfo(QSerialPort::SerialPortError newErrorCode = QSerialPort::UnknownError,
const QString &newErrorString = QString());
QSerialPort::SerialPortError errorCode = QSerialPort::UnknownError;
QString errorString;
@@ -122,8 +90,9 @@ public:
class QSerialPortPrivate : public QIODevicePrivate
{
- Q_DECLARE_PUBLIC(QSerialPort)
public:
+ Q_DECLARE_PUBLIC(QSerialPort)
+
QSerialPortPrivate();
bool open(QIODevice::OpenMode mode);
@@ -164,16 +133,42 @@ public:
static QList<qint32> standardBaudRates();
qint64 readBufferMaxSize = 0;
- QSerialPort::SerialPortError error = QSerialPort::NoError;
+
+ void setBindableError(QSerialPort::SerialPortError error)
+ { setError(error); }
+ Q_OBJECT_COMPAT_PROPERTY_WITH_ARGS(QSerialPortPrivate, QSerialPort::SerialPortError, error,
+ &QSerialPortPrivate::setBindableError, QSerialPort::NoError)
+
QString systemLocation;
qint32 inputBaudRate = QSerialPort::Baud9600;
qint32 outputBaudRate = QSerialPort::Baud9600;
- QSerialPort::DataBits dataBits = QSerialPort::Data8;
- QSerialPort::Parity parity = QSerialPort::NoParity;
- QSerialPort::StopBits stopBits = QSerialPort::OneStop;
- QSerialPort::FlowControl flowControl = QSerialPort::NoFlowControl;
+
+ bool setBindableDataBits(QSerialPort::DataBits dataBits)
+ { return q_func()->setDataBits(dataBits); }
+ Q_OBJECT_COMPAT_PROPERTY_WITH_ARGS(QSerialPortPrivate, QSerialPort::DataBits, dataBits,
+ &QSerialPortPrivate::setBindableDataBits, QSerialPort::Data8)
+
+ bool setBindableParity(QSerialPort::Parity parity)
+ { return q_func()->setParity(parity); }
+ Q_OBJECT_COMPAT_PROPERTY_WITH_ARGS(QSerialPortPrivate, QSerialPort::Parity, parity,
+ &QSerialPortPrivate::setBindableParity, QSerialPort::NoParity)
+
+ bool setBindableStopBits(QSerialPort::StopBits stopBits)
+ { return q_func()->setStopBits(stopBits); }
+ Q_OBJECT_COMPAT_PROPERTY_WITH_ARGS(QSerialPortPrivate, QSerialPort::StopBits, stopBits,
+ &QSerialPortPrivate::setBindableStopBits, QSerialPort::OneStop)
+
+ bool setBindableFlowControl(QSerialPort::FlowControl flowControl)
+ { return q_func()->setFlowControl(flowControl); }
+ Q_OBJECT_COMPAT_PROPERTY_WITH_ARGS(QSerialPortPrivate, QSerialPort::FlowControl, flowControl,
+ &QSerialPortPrivate::setBindableFlowControl, QSerialPort::NoFlowControl)
+
bool settingsRestoredOnClose = true;
- bool isBreakEnabled = false;
+
+ bool setBindableBreakEnabled(bool isBreakEnabled)
+ { return q_func()->setBreakEnabled(isBreakEnabled); }
+ Q_OBJECT_COMPAT_PROPERTY_WITH_ARGS(QSerialPortPrivate, bool, isBreakEnabled,
+ &QSerialPortPrivate::setBindableBreakEnabled, false)
bool startAsyncRead();
@@ -181,6 +176,7 @@ public:
bool setDcb(DCB *dcb);
bool getDcb(DCB *dcb);
+ OVERLAPPED *waitForNotified(QDeadlineTimer deadline);
qint64 queuedBytesCount(QSerialPort::Direction direction) const;
@@ -190,15 +186,10 @@ public:
bool startAsyncCommunication();
bool _q_startAsyncWrite();
- void handleNotification(DWORD bytesTransferred, DWORD errorCode,
- OVERLAPPED *overlapped);
+ void _q_notified(DWORD numberOfBytes, DWORD errorCode, OVERLAPPED *overlapped);
void emitReadyRead();
- static void CALLBACK ioCompletionRoutine(
- DWORD errorCode, DWORD bytesTransfered,
- OVERLAPPED *overlappedBase);
-
DCB restoredDcb;
COMMTIMEOUTS currentCommTimeouts;
COMMTIMEOUTS restoredCommTimeouts;
@@ -208,12 +199,11 @@ public:
bool communicationStarted = false;
bool writeStarted = false;
bool readStarted = false;
- qint64 writeBytesTransferred = 0;
- qint64 readBytesTransferred = 0;
+ QWinOverlappedIoNotifier *notifier = nullptr;
QTimer *startAsyncWriteTimer = nullptr;
- class Overlapped *communicationCompletionOverlapped = nullptr;
- class Overlapped *readCompletionOverlapped = nullptr;
- class Overlapped *writeCompletionOverlapped = nullptr;
+ OVERLAPPED communicationOverlapped;
+ OVERLAPPED readCompletionOverlapped;
+ OVERLAPPED writeCompletionOverlapped;
DWORD triggeredEventMask = 0;
#elif defined(Q_OS_UNIX)
@@ -262,7 +252,7 @@ public:
qint64 pendingBytesWritten = 0;
bool writeSequenceStarted = false;
- QScopedPointer<QLockFile> lockFileScopedPointer;
+ std::unique_ptr<QLockFile> lockFileScopedPointer;
#endif
};
diff --git a/src/serialport/qserialport_unix.cpp b/src/serialport/qserialport_unix.cpp
index 294782b..e0f2e79 100644
--- a/src/serialport/qserialport_unix.cpp
+++ b/src/serialport/qserialport_unix.cpp
@@ -1,43 +1,7 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Denis Shienkov <denis.shienkov@gmail.com>
-** Copyright (C) 2012 Laszlo Papp <lpapp@kde.org>
-** Copyright (C) 2012 Andre Hartmann <aha_1980@gmx.de>
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtSerialPort module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2012 Denis Shienkov <denis.shienkov@gmail.com>
+// Copyright (C) 2012 Laszlo Papp <lpapp@kde.org>
+// Copyright (C) 2012 Andre Hartmann <aha_1980@gmx.de>
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#include "qserialport_p.h"
#include "qserialportinfo_p.h"
@@ -316,7 +280,7 @@ bool QSerialPortPrivate::open(QIODevice::OpenMode mode)
return false;
}
- QScopedPointer<QLockFile> newLockFileScopedPointer(new QLockFile(lockFilePath));
+ auto newLockFileScopedPointer = std::make_unique<QLockFile>(lockFilePath);
if (!newLockFileScopedPointer->tryLock()) {
setError(QSerialPortErrorInfo(QSerialPort::PermissionError, QSerialPort::tr("Permission error while locking the device")));
@@ -349,7 +313,7 @@ bool QSerialPortPrivate::open(QIODevice::OpenMode mode)
return false;
}
- lockFileScopedPointer.swap(newLockFileScopedPointer);
+ lockFileScopedPointer = std::move(newLockFileScopedPointer);
return true;
}
diff --git a/src/serialport/qserialport_win.cpp b/src/serialport/qserialport_win.cpp
index c131641..5e7e0eb 100644
--- a/src/serialport/qserialport_win.cpp
+++ b/src/serialport/qserialport_win.cpp
@@ -1,46 +1,10 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Denis Shienkov <denis.shienkov@gmail.com>
-** Copyright (C) 2012 Laszlo Papp <lpapp@kde.org>
-** Copyright (C) 2012 Andre Hartmann <aha_1980@gmx.de>
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtSerialPort module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2012 Denis Shienkov <denis.shienkov@gmail.com>
+// Copyright (C) 2012 Laszlo Papp <lpapp@kde.org>
+// Copyright (C) 2012 Andre Hartmann <aha_1980@gmx.de>
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#include "qserialport_p.h"
-#include "qtntdll_p.h"
+#include "qwinoverlappedionotifier_p.h"
#include <QtCore/qcoreevent.h>
#include <QtCore/qelapsedtimer.h>
@@ -49,6 +13,37 @@
#include <QtCore/qtimer.h>
#include <algorithm>
+#ifndef CTL_CODE
+# define CTL_CODE(DeviceType, Function, Method, Access) ( \
+ ((DeviceType) << 16) | ((Access) << 14) | ((Function) << 2) | (Method) \
+ )
+#endif
+
+#ifndef FILE_DEVICE_SERIAL_PORT
+# define FILE_DEVICE_SERIAL_PORT 27
+#endif
+
+#ifndef METHOD_BUFFERED
+# define METHOD_BUFFERED 0
+#endif
+
+#ifndef FILE_ANY_ACCESS
+# define FILE_ANY_ACCESS 0x00000000
+#endif
+
+#ifndef IOCTL_SERIAL_GET_DTRRTS
+# define IOCTL_SERIAL_GET_DTRRTS \
+ CTL_CODE(FILE_DEVICE_SERIAL_PORT, 30, METHOD_BUFFERED, FILE_ANY_ACCESS)
+#endif
+
+#ifndef SERIAL_DTR_STATE
+# define SERIAL_DTR_STATE 0x00000001
+#endif
+
+#ifndef SERIAL_RTS_STATE
+# define SERIAL_RTS_STATE 0x00000002
+#endif
+
QT_BEGIN_NAMESPACE
static inline void qt_set_common_props(DCB *dcb)
@@ -143,117 +138,8 @@ static inline void qt_set_flowcontrol(DCB *dcb, QSerialPort::FlowControl flowcon
}
}
-// Translate NT-callbacks to Win32 callbacks.
-static VOID WINAPI qt_apc_routine(
- PVOID context,
- PIO_STATUS_BLOCK ioStatusBlock,
- DWORD reserved)
-{
- Q_UNUSED(reserved);
-
- const DWORD errorCode = ::RtlNtStatusToDosError(ioStatusBlock->Status);
- const DWORD bytesTransfered = NT_SUCCESS(ioStatusBlock->Status)
- ? DWORD(ioStatusBlock->Information) : 0;
- const LPOVERLAPPED overlapped = CONTAINING_RECORD(ioStatusBlock,
- OVERLAPPED, Internal);
-
- (reinterpret_cast<LPOVERLAPPED_COMPLETION_ROUTINE>(context))
- (errorCode, bytesTransfered, overlapped);
-}
-
-// Alertable analog of DeviceIoControl function.
-static BOOL qt_device_io_control_ex(
- HANDLE deviceHandle,
- DWORD ioControlCode,
- LPVOID inputBuffer,
- DWORD inputBufferSize,
- LPVOID outputBuffer,
- DWORD outputBufferSize,
- LPOVERLAPPED overlapped,
- LPOVERLAPPED_COMPLETION_ROUTINE completionRoutine)
-{
- const auto ioStatusBlock = reinterpret_cast<PIO_STATUS_BLOCK>(
- &overlapped->Internal);
- ioStatusBlock->Status = STATUS_PENDING;
-
- const NTSTATUS status = ::NtDeviceIoControlFile(
- deviceHandle,
- nullptr,
- qt_apc_routine,
- reinterpret_cast<PVOID>(completionRoutine),
- ioStatusBlock,
- ioControlCode,
- inputBuffer,
- inputBufferSize,
- outputBuffer,
- outputBufferSize);
-
- if (!NT_SUCCESS(status)) {
- ::SetLastError(::RtlNtStatusToDosError(status));
- return false;
- }
-
- return true;
-}
-
-// Alertable analog of WaitCommEvent function.
-static BOOL qt_wait_comm_event_ex(
- HANDLE deviceHandle,
- LPDWORD eventsMask,
- LPOVERLAPPED overlapped,
- LPOVERLAPPED_COMPLETION_ROUTINE completionRoutine)
-{
- return qt_device_io_control_ex(
- deviceHandle,
- IOCTL_SERIAL_WAIT_ON_MASK,
- nullptr,
- 0,
- eventsMask,
- sizeof(DWORD),
- overlapped,
- completionRoutine);
-}
-
-struct RuntimeHelper
-{
- QLibrary ntLibrary;
- QBasicMutex mutex;
-};
-
-Q_GLOBAL_STATIC(RuntimeHelper, helper)
-
-class Overlapped final : public OVERLAPPED
-{
- Q_DISABLE_COPY(Overlapped)
-public:
- explicit Overlapped(QSerialPortPrivate *d);
- void clear();
-
- QSerialPortPrivate *dptr = nullptr;
-};
-
-Overlapped::Overlapped(QSerialPortPrivate *d)
- : dptr(d)
-{
-}
-
-void Overlapped::clear()
-{
- ::ZeroMemory(this, sizeof(OVERLAPPED));
-}
-
bool QSerialPortPrivate::open(QIODevice::OpenMode mode)
{
- {
- QMutexLocker locker(&helper()->mutex);
- static bool symbolsResolved = resolveNtdllSymbols(&helper()->ntLibrary);
- if (!symbolsResolved) {
- setError(QSerialPortErrorInfo(QSerialPort::OpenError,
- helper()->ntLibrary.errorString()));
- return false;
- }
- }
-
DWORD desiredAccess = 0;
if (mode & QIODevice::ReadOnly)
@@ -278,44 +164,17 @@ bool QSerialPortPrivate::open(QIODevice::OpenMode mode)
void QSerialPortPrivate::close()
{
- delete startAsyncWriteTimer;
- startAsyncWriteTimer = nullptr;
+ ::CancelIo(handle);
- if (communicationStarted) {
- communicationCompletionOverlapped->dptr = nullptr;
- ::CancelIoEx(handle, communicationCompletionOverlapped);
- // The object will be deleted in the I/O callback.
- communicationCompletionOverlapped = nullptr;
- communicationStarted = false;
- } else {
- delete communicationCompletionOverlapped;
- communicationCompletionOverlapped = nullptr;
- }
+ delete notifier;
+ notifier = nullptr;
- if (readStarted) {
- readCompletionOverlapped->dptr = nullptr;
- ::CancelIoEx(handle, readCompletionOverlapped);
- // The object will be deleted in the I/O callback.
- readCompletionOverlapped = nullptr;
- readStarted = false;
- } else {
- delete readCompletionOverlapped;
- readCompletionOverlapped = nullptr;
- };
-
- if (writeStarted) {
- writeCompletionOverlapped->dptr = nullptr;
- ::CancelIoEx(handle, writeCompletionOverlapped);
- // The object will be deleted in the I/O callback.
- writeCompletionOverlapped = nullptr;
- writeStarted = false;
- } else {
- delete writeCompletionOverlapped;
- writeCompletionOverlapped = nullptr;
- }
+ delete startAsyncWriteTimer;
+ startAsyncWriteTimer = nullptr;
- readBytesTransferred = 0;
- writeBytesTransferred = 0;
+ communicationStarted = false;
+ readStarted = false;
+ writeStarted = false;
writeBuffer.clear();
if (settingsRestoredOnClose) {
@@ -447,25 +306,30 @@ bool QSerialPortPrivate::waitForReadyRead(int msecs)
if (!writeStarted && !_q_startAsyncWrite())
return false;
+ const qint64 initialReadBufferSize = buffer.size();
+ qint64 currentReadBufferSize = initialReadBufferSize;
+
QDeadlineTimer deadline(msecs);
do {
- if (readBytesTransferred <= 0) {
- const qint64 remaining = deadline.remainingTime();
- const DWORD result = ::SleepEx(
- remaining == -1 ? INFINITE : DWORD(remaining),
- TRUE);
- if (result != WAIT_IO_COMPLETION)
- continue;
- }
+ const OVERLAPPED *overlapped = waitForNotified(deadline);
+ if (!overlapped)
+ return false;
- if (readBytesTransferred > 0) {
- readBytesTransferred = 0;
- return true;
+ if (overlapped == &readCompletionOverlapped) {
+ const qint64 readBytesForOneReadOperation = qint64(buffer.size()) - currentReadBufferSize;
+ if (readBytesForOneReadOperation == QSERIALPORT_BUFFERSIZE) {
+ currentReadBufferSize = buffer.size();
+ } else if (readBytesForOneReadOperation == 0) {
+ if (initialReadBufferSize != currentReadBufferSize)
+ return true;
+ } else {
+ return true;
+ }
}
+
} while (!deadline.hasExpired());
- setError(getSystemError(WAIT_TIMEOUT));
return false;
}
@@ -479,23 +343,15 @@ bool QSerialPortPrivate::waitForBytesWritten(int msecs)
QDeadlineTimer deadline(msecs);
- do {
- if (writeBytesTransferred <= 0) {
- const qint64 remaining = deadline.remainingTime();
- const DWORD result = ::SleepEx(
- remaining == -1 ? INFINITE : DWORD(remaining),
- TRUE);
- if (result != WAIT_IO_COMPLETION)
- continue;
- }
+ for (;;) {
+ const OVERLAPPED *overlapped = waitForNotified(deadline);
+ if (!overlapped)
+ return false;
- if (writeBytesTransferred > 0) {
- writeBytesTransferred = 0;
+ if (overlapped == &writeCompletionOverlapped)
return true;
- }
- } while (!deadline.hasExpired());
+ }
- setError(getSystemError(WAIT_TIMEOUT));
return false;
}
@@ -576,10 +432,6 @@ bool QSerialPortPrivate::completeAsyncCommunication(qint64 bytesTransferred)
bool QSerialPortPrivate::completeAsyncRead(qint64 bytesTransferred)
{
- // Store the number of transferred bytes which are
- // required only in waitForReadyRead() method.
- readBytesTransferred = bytesTransferred;
-
if (bytesTransferred == qint64(-1)) {
readStarted = false;
return false;
@@ -607,10 +459,6 @@ bool QSerialPortPrivate::completeAsyncWrite(qint64 bytesTransferred)
{
Q_Q(QSerialPort);
- // Store the number of transferred bytes which are
- // required only in waitForBytesWritten() method.
- writeBytesTransferred = bytesTransferred;
-
if (writeStarted) {
if (bytesTransferred == qint64(-1)) {
writeChunkBuffer.clear();
@@ -631,16 +479,8 @@ bool QSerialPortPrivate::startAsyncCommunication()
if (communicationStarted)
return true;
- if (!communicationCompletionOverlapped)
- communicationCompletionOverlapped = new Overlapped(this);
-
- communicationCompletionOverlapped->clear();
- communicationStarted = true;
- if (!::qt_wait_comm_event_ex(handle,
- &triggeredEventMask,
- communicationCompletionOverlapped,
- ioCompletionRoutine)) {
- communicationStarted = false;
+ ::ZeroMemory(&communicationOverlapped, sizeof(communicationOverlapped));
+ if (!::WaitCommEvent(handle, &triggeredEventMask, &communicationOverlapped)) {
QSerialPortErrorInfo error = getSystemError();
if (error.errorCode != QSerialPort::NoError) {
if (error.errorCode == QSerialPort::PermissionError)
@@ -649,6 +489,7 @@ bool QSerialPortPrivate::startAsyncCommunication()
return false;
}
}
+ communicationStarted = true;
return true;
}
@@ -670,27 +511,23 @@ bool QSerialPortPrivate::startAsyncRead()
Q_ASSERT(int(bytesToRead) <= readChunkBuffer.size());
- if (!readCompletionOverlapped)
- readCompletionOverlapped = new Overlapped(this);
+ ::ZeroMemory(&readCompletionOverlapped, sizeof(readCompletionOverlapped));
+ if (::ReadFile(handle, readChunkBuffer.data(), bytesToRead, nullptr, &readCompletionOverlapped)) {
+ readStarted = true;
+ return true;
+ }
- readCompletionOverlapped->clear();
- readStarted = true;
- if (!::ReadFileEx(handle,
- readChunkBuffer.data(),
- bytesToRead,
- readCompletionOverlapped,
- ioCompletionRoutine)) {
- readStarted = false;
- QSerialPortErrorInfo error = getSystemError();
- if (error.errorCode != QSerialPort::NoError) {
- if (error.errorCode == QSerialPort::PermissionError)
- error.errorCode = QSerialPort::ResourceError;
- if (error.errorCode != QSerialPort::ResourceError)
- error.errorCode = QSerialPort::ReadError;
- setError(error);
- return false;
- }
+ QSerialPortErrorInfo error = getSystemError();
+ if (error.errorCode != QSerialPort::NoError) {
+ if (error.errorCode == QSerialPort::PermissionError)
+ error.errorCode = QSerialPort::ResourceError;
+ if (error.errorCode != QSerialPort::ResourceError)
+ error.errorCode = QSerialPort::ReadError;
+ setError(error);
+ return false;
}
+
+ readStarted = true;
return true;
}
@@ -700,18 +537,10 @@ bool QSerialPortPrivate::_q_startAsyncWrite()
return true;
writeChunkBuffer = writeBuffer.read();
+ ::ZeroMemory(&writeCompletionOverlapped, sizeof(writeCompletionOverlapped));
+ if (!::WriteFile(handle, writeChunkBuffer.constData(),
+ writeChunkBuffer.size(), nullptr, &writeCompletionOverlapped)) {
- if (!writeCompletionOverlapped)
- writeCompletionOverlapped = new Overlapped(this);
-
- writeCompletionOverlapped->clear();
- writeStarted = true;
- if (!::WriteFileEx(handle,
- writeChunkBuffer.constData(),
- writeChunkBuffer.size(),
- writeCompletionOverlapped,
- ioCompletionRoutine)) {
- writeStarted = false;
QSerialPortErrorInfo error = getSystemError();
if (error.errorCode != QSerialPort::NoError) {
if (error.errorCode != QSerialPort::ResourceError)
@@ -720,29 +549,25 @@ bool QSerialPortPrivate::_q_startAsyncWrite()
return false;
}
}
+
+ writeStarted = true;
return true;
}
-void QSerialPortPrivate::handleNotification(DWORD bytesTransferred, DWORD errorCode,
- OVERLAPPED *overlapped)
+void QSerialPortPrivate::_q_notified(DWORD numberOfBytes, DWORD errorCode, OVERLAPPED *overlapped)
{
- // This occurred e.g. after calling the CloseHandle() function,
- // just skip handling at all.
- if (handle == INVALID_HANDLE_VALUE)
- return;
-
const QSerialPortErrorInfo error = getSystemError(errorCode);
if (error.errorCode != QSerialPort::NoError) {
setError(error);
return;
}
- if (overlapped == communicationCompletionOverlapped)
- completeAsyncCommunication(bytesTransferred);
- else if (overlapped == readCompletionOverlapped)
- completeAsyncRead(bytesTransferred);
- else if (overlapped == writeCompletionOverlapped)
- completeAsyncWrite(bytesTransferred);
+ if (overlapped == &communicationOverlapped)
+ completeAsyncCommunication(numberOfBytes);
+ else if (overlapped == &readCompletionOverlapped)
+ completeAsyncRead(numberOfBytes);
+ else if (overlapped == &writeCompletionOverlapped)
+ completeAsyncWrite(numberOfBytes);
else
Q_ASSERT(!"Unknown OVERLAPPED activated");
}
@@ -772,6 +597,16 @@ qint64 QSerialPortPrivate::writeData(const char *data, qint64 maxSize)
return maxSize;
}
+OVERLAPPED *QSerialPortPrivate::waitForNotified(QDeadlineTimer deadline)
+{
+ OVERLAPPED *overlapped = notifier->waitForAnyNotified(deadline);
+ if (!overlapped) {
+ setError(getSystemError(WAIT_TIMEOUT));
+ return nullptr;
+ }
+ return overlapped;
+}
+
qint64 QSerialPortPrivate::queuedBytesCount(QSerialPort::Direction direction) const
{
COMSTAT comstat;
@@ -784,6 +619,8 @@ qint64 QSerialPortPrivate::queuedBytesCount(QSerialPort::Direction direction) co
inline bool QSerialPortPrivate::initialize(QIODevice::OpenMode mode)
{
+ Q_Q(QSerialPort);
+
DCB dcb;
if (!getDcb(&dcb))
return false;
@@ -819,8 +656,17 @@ inline bool QSerialPortPrivate::initialize(QIODevice::OpenMode mode)
return false;
}
- if ((eventMask & EV_RXCHAR) && !startAsyncCommunication())
+ notifier = new QWinOverlappedIoNotifier(q);
+ QObjectPrivate::connect(notifier, &QWinOverlappedIoNotifier::notified,
+ this, &QSerialPortPrivate::_q_notified);
+ notifier->setHandle(handle);
+ notifier->setEnabled(true);
+
+ if ((eventMask & EV_RXCHAR) && !startAsyncCommunication()) {
+ delete notifier;
+ notifier = nullptr;
return false;
+ }
return true;
}
@@ -920,17 +766,4 @@ QSerialPort::Handle QSerialPort::handle() const
return d->handle;
}
-void QSerialPortPrivate::ioCompletionRoutine(
- DWORD errorCode, DWORD bytesTransfered,
- OVERLAPPED *overlappedBase)
-{
- const auto overlapped = static_cast<Overlapped *>(overlappedBase);
- if (overlapped->dptr) {
- overlapped->dptr->handleNotification(bytesTransfered, errorCode,
- overlappedBase);
- } else {
- delete overlapped;
- }
-}
-
QT_END_NAMESPACE
diff --git a/src/serialport/qserialportglobal.h b/src/serialport/qserialportglobal.h
index f6c5803..8bfd299 100644
--- a/src/serialport/qserialportglobal.h
+++ b/src/serialport/qserialportglobal.h
@@ -1,61 +1,12 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Denis Shienkov <denis.shienkov@gmail.com>
-** Copyright (C) 2012 Laszlo Papp <lpapp@kde.org>
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtSerialPort module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2012 Denis Shienkov <denis.shienkov@gmail.com>
+// Copyright (C) 2012 Laszlo Papp <lpapp@kde.org>
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#ifndef QSERIALPORTGLOBAL_H
#define QSERIALPORTGLOBAL_H
#include <QtCore/qstring.h>
#include <QtCore/qglobal.h>
-
-QT_BEGIN_NAMESPACE
-
-#ifndef QT_STATIC
-# if defined(QT_BUILD_SERIALPORT_LIB)
-# define Q_SERIALPORT_EXPORT Q_DECL_EXPORT
-# else
-# define Q_SERIALPORT_EXPORT Q_DECL_IMPORT
-# endif
-#else
-# define Q_SERIALPORT_EXPORT
-#endif
-
-QT_END_NAMESPACE
+#include <QtSerialPort/qtserialportexports.h>
#endif // QSERIALPORTGLOBAL_H
diff --git a/src/serialport/qserialportinfo.cpp b/src/serialport/qserialportinfo.cpp
index 3bfa56c..be58f69 100644
--- a/src/serialport/qserialportinfo.cpp
+++ b/src/serialport/qserialportinfo.cpp
@@ -1,43 +1,7 @@
-/****************************************************************************
-**
-** Copyright (C) 2011-2012 Denis Shienkov <denis.shienkov@gmail.com>
-** Copyright (C) 2011 Sergey Belyashov <Sergey.Belyashov@gmail.com>
-** Copyright (C) 2012 Laszlo Papp <lpapp@kde.org>
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtSerialPort module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2011-2012 Denis Shienkov <denis.shienkov@gmail.com>
+// Copyright (C) 2011 Sergey Belyashov <Sergey.Belyashov@gmail.com>
+// Copyright (C) 2012 Laszlo Papp <lpapp@kde.org>
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#include "qserialportinfo.h"
#include "qserialportinfo_p.h"
@@ -46,6 +10,12 @@
QT_BEGIN_NAMESPACE
+// We changed from QScopedPointer to std::unique_ptr, make sure it's
+// binary compatible. The QScopedPointer had a non-default deleter, but
+// the deleter just provides a static function to use for deletion so we don't
+// include it in this template definition (the deleter-class was deleted).
+static_assert(sizeof(std::unique_ptr<QSerialPortInfoPrivate>)
+ == sizeof(QScopedPointer<QSerialPortInfoPrivate>));
/*!
\class QSerialPortInfo
@@ -56,12 +26,20 @@ QT_BEGIN_NAMESPACE
\inmodule QtSerialPort
\since 5.1
- Use the static functions to generate a list of QSerialPortInfo
- objects. Each QSerialPortInfo object in the list represents a single
- serial port and can be queried for the port name, system location,
- description, and manufacturer. The QSerialPortInfo class can also be
- used as an input parameter for the setPort() method of the QSerialPort
- class.
+ Use the static \l availablePorts() function to generate a list of
+ QSerialPortInfo objects. Each QSerialPortInfo object in the list represents
+ a single serial port and can be queried for the \l {portName}{port name},
+ \l {systemLocation}{system location}, \l description, \l manufacturer, and
+ some other hardware parameters. The QSerialPortInfo class can also be
+ used as an input parameter for the \l {QSerialPort::}{setPort()} method of
+ the QSerialPort class.
+
+ \section1 Example Usage
+
+ The example code enumerates all available serial ports and prints their
+ parameters to console:
+
+ \snippet doc_src_serialport.cpp enumerate_ports
\sa QSerialPort
*/
@@ -255,33 +233,7 @@ bool QSerialPortInfo::hasProductIdentifier() const
Returns whether this QSerialPortInfo object holds a
serial port definition.
-
- \sa isBusy()
-*/
-
-#if QT_DEPRECATED_SINCE(5, 6)
-/*!
- \fn bool QSerialPortInfo::isBusy() const
- \obsolete
-
- Returns \c true if serial port is busy;
- otherwise returns \c false.
-
- \sa isNull()
-*/
-#endif // QT_DEPRECATED_SINCE(5, 6)
-
-#if QT_DEPRECATED_SINCE(5, 2)
-/*!
- \fn bool QSerialPortInfo::isValid() const
- \obsolete
-
- Returns \c true if serial port is present on system;
- otherwise returns \c false.
-
- \sa isNull(), isBusy()
*/
-#endif // QT_DEPRECATED_SINCE(5, 2)
/*!
\fn QList<qint32> QSerialPortInfo::standardBaudRates()
diff --git a/src/serialport/qserialportinfo.h b/src/serialport/qserialportinfo.h
index e4c9288..d6c1e66 100644
--- a/src/serialport/qserialportinfo.h
+++ b/src/serialport/qserialportinfo.h
@@ -1,42 +1,6 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Denis Shienkov <denis.shienkov@gmail.com>
-** Copyright (C) 2012 Laszlo Papp <lpapp@kde.org>
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtSerialPort module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2012 Denis Shienkov <denis.shienkov@gmail.com>
+// Copyright (C) 2012 Laszlo Papp <lpapp@kde.org>
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#ifndef QSERIALPORTINFO_H
#define QSERIALPORTINFO_H
@@ -50,7 +14,6 @@ QT_BEGIN_NAMESPACE
class QSerialPort;
class QSerialPortInfoPrivate;
-class QSerialPortInfoPrivateDeleter;
class Q_SERIALPORT_EXPORT QSerialPortInfo
{
@@ -78,12 +41,6 @@ public:
bool hasProductIdentifier() const;
bool isNull() const;
-#if QT_DEPRECATED_SINCE(5, 6)
- bool isBusy() const;
-#endif
-#if QT_DEPRECATED_SINCE(5, 2)
- QT_DEPRECATED bool isValid() const;
-#endif
static QList<qint32> standardBaudRates();
static QList<QSerialPortInfo> availablePorts();
@@ -93,7 +50,7 @@ private:
friend QList<QSerialPortInfo> availablePortsByUdev(bool &ok);
friend QList<QSerialPortInfo> availablePortsBySysfs(bool &ok);
friend QList<QSerialPortInfo> availablePortsByFiltersOfDevices(bool &ok);
- QScopedPointer<QSerialPortInfoPrivate, QSerialPortInfoPrivateDeleter> d_ptr;
+ std::unique_ptr<QSerialPortInfoPrivate> d_ptr;
};
inline bool QSerialPortInfo::isNull() const
diff --git a/src/serialport/qserialportinfo_freebsd.cpp b/src/serialport/qserialportinfo_freebsd.cpp
index 5514fa4..5852cd7 100644
--- a/src/serialport/qserialportinfo_freebsd.cpp
+++ b/src/serialport/qserialportinfo_freebsd.cpp
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 Denis Shienkov <denis.shienkov@gmail.com>
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtSerialPort module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 Denis Shienkov <denis.shienkov@gmail.com>
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#include "qserialportinfo.h"
#include "qserialportinfo_p.h"
@@ -320,10 +284,10 @@ QList<QSerialPortInfo> QSerialPortInfo::availablePorts()
QList<QSerialPortInfo> serialPortInfoList;
- for (const QSerialPortInfo &cuaCandidate : qAsConst(cuaCandidates)) {
+ for (const QSerialPortInfo &cuaCandidate : std::as_const(cuaCandidates)) {
const QString cuaPortName = cuaCandidate.portName();
const QString cuaToken = deviceProperty(cuaPortName, "cua");
- for (const QSerialPortInfo &ttyCandidate : qAsConst(ttyCandidates)) {
+ for (const QSerialPortInfo &ttyCandidate : std::as_const(ttyCandidates)) {
const QString ttyPortName = ttyCandidate.portName();
const QString ttyToken = deviceProperty(ttyPortName, "tty");
if (cuaToken != ttyToken)
@@ -337,37 +301,6 @@ QList<QSerialPortInfo> QSerialPortInfo::availablePorts()
return serialPortInfoList;
}
-bool QSerialPortInfo::isBusy() const
-{
- QString lockFilePath = serialPortLockFilePath(portName());
- if (lockFilePath.isEmpty())
- return false;
-
- QFile reader(lockFilePath);
- if (!reader.open(QIODevice::ReadOnly))
- return false;
-
- QByteArray pidLine = reader.readLine();
- pidLine.chop(1);
- if (pidLine.isEmpty())
- return false;
-
- qint64 pid = pidLine.toLongLong();
-
- if (pid && (::kill(pid, 0) == -1) && (errno == ESRCH))
- return false; // PID doesn't exist anymore
-
- return true;
-}
-
-#if QT_DEPRECATED_SINCE(5, 2)
-bool QSerialPortInfo::isValid() const
-{
- QFile f(systemLocation());
- return f.exists();
-}
-#endif // QT_DEPRECATED_SINCE(5, 2)
-
QString QSerialPortInfoPrivate::portNameToSystemLocation(const QString &source)
{
return (source.startsWith(QLatin1Char('/'))
diff --git a/src/serialport/qserialportinfo_osx.cpp b/src/serialport/qserialportinfo_osx.cpp
index 2e46397..203b084 100644
--- a/src/serialport/qserialportinfo_osx.cpp
+++ b/src/serialport/qserialportinfo_osx.cpp
@@ -1,43 +1,7 @@
-/****************************************************************************
-**
-** Copyright (C) 2011-2012 Denis Shienkov <denis.shienkov@gmail.com>
-** Copyright (C) 2011 Sergey Belyashov <Sergey.Belyashov@gmail.com>
-** Copyright (C) 2012 Laszlo Papp <lpapp@kde.org>
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtSerialPort module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2011-2012 Denis Shienkov <denis.shienkov@gmail.com>
+// Copyright (C) 2011 Sergey Belyashov <Sergey.Belyashov@gmail.com>
+// Copyright (C) 2012 Laszlo Papp <lpapp@kde.org>
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#include "qserialportinfo.h"
#include "qserialportinfo_p.h"
@@ -230,39 +194,6 @@ QList<QSerialPortInfo> QSerialPortInfo::availablePorts()
return serialPortInfoList;
}
-#if QT_DEPRECATED_SINCE(5, 6)
-bool QSerialPortInfo::isBusy() const
-{
- QString lockFilePath = serialPortLockFilePath(portName());
- if (lockFilePath.isEmpty())
- return false;
-
- QFile reader(lockFilePath);
- if (!reader.open(QIODevice::ReadOnly))
- return false;
-
- QByteArray pidLine = reader.readLine();
- pidLine.chop(1);
- if (pidLine.isEmpty())
- return false;
-
- qint64 pid = pidLine.toLongLong();
-
- if (pid && (::kill(pid, 0) == -1) && (errno == ESRCH))
- return false; // PID doesn't exist anymore
-
- return true;
-}
-#endif // QT_DEPRECATED_SINCE(5, 6)
-
-#if QT_DEPRECATED_SINCE(5, 2)
-bool QSerialPortInfo::isValid() const
-{
- QFile f(systemLocation());
- return f.exists();
-}
-#endif // QT_DEPRECATED_SINCE(5, 2)
-
QString QSerialPortInfoPrivate::portNameToSystemLocation(const QString &source)
{
return (source.startsWith(QLatin1Char('/'))
diff --git a/src/serialport/qserialportinfo_p.h b/src/serialport/qserialportinfo_p.h
index 405cc41..1a949f0 100644
--- a/src/serialport/qserialportinfo_p.h
+++ b/src/serialport/qserialportinfo_p.h
@@ -1,43 +1,7 @@
-/****************************************************************************
-**
-** Copyright (C) 2011-2012 Denis Shienkov <denis.shienkov@gmail.com>
-** Copyright (C) 2011 Sergey Belyashov <Sergey.Belyashov@gmail.com>
-** Copyright (C) 2012 Laszlo Papp <lpapp@kde.org>
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtSerialPort module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2011-2012 Denis Shienkov <denis.shienkov@gmail.com>
+// Copyright (C) 2017 Sergey Belyashov <Sergey.Belyashov@gmail.com>
+// Copyright (C) 2013 Laszlo Papp <lpapp@kde.org>
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#ifndef QSERIALPORTINFO_P_H
#define QSERIALPORTINFO_P_H
@@ -54,6 +18,7 @@
//
#include <QtCore/qstring.h>
+#include <QtCore/private/qglobal_p.h>
QT_BEGIN_NAMESPACE
@@ -76,14 +41,6 @@ public:
bool hasProductIdentifier = false;
};
-class QSerialPortInfoPrivateDeleter
-{
-public:
- static void cleanup(QSerialPortInfoPrivate *p) {
- delete p;
- }
-};
-
QT_END_NAMESPACE
#endif // QSERIALPORTINFO_P_H
diff --git a/src/serialport/qserialportinfo_unix.cpp b/src/serialport/qserialportinfo_unix.cpp
index 7b96757..4f9304b 100644
--- a/src/serialport/qserialportinfo_unix.cpp
+++ b/src/serialport/qserialportinfo_unix.cpp
@@ -1,43 +1,7 @@
-/****************************************************************************
-**
-** Copyright (C) 2011-2012 Denis Shienkov <denis.shienkov@gmail.com>
-** Copyright (C) 2011 Sergey Belyashov <Sergey.Belyashov@gmail.com>
-** Copyright (C) 2012 Laszlo Papp <lpapp@kde.org>
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtSerialPort module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2011-2012 Denis Shienkov <denis.shienkov@gmail.com>
+// Copyright (C) 2011 Sergey Belyashov <Sergey.Belyashov@gmail.com>
+// Copyright (C) 2012 Laszlo Papp <lpapp@kde.org>
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#include "qserialportinfo.h"
#include "qserialportinfo_p.h"
@@ -46,10 +10,11 @@
#include <QtCore/qlockfile.h>
#include <QtCore/qfile.h>
#include <QtCore/qdir.h>
-#include <QtCore/qscopedpointer.h>
#include <private/qcore_unix_p.h>
+#include <memory>
+
#include <errno.h>
#include <sys/types.h> // kill
#include <signal.h> // kill
@@ -313,29 +278,22 @@ QList<QSerialPortInfo> availablePortsBySysfs(bool &ok)
return serialPortInfoList;
}
-struct ScopedPointerUdevDeleter
-{
- static inline void cleanup(struct ::udev *pointer)
+struct udev_deleter {
+ void operator()(struct ::udev *pointer) const
{
::udev_unref(pointer);
}
-};
-
-struct ScopedPointerUdevEnumeratorDeleter
-{
- static inline void cleanup(struct ::udev_enumerate *pointer)
+ void operator()(struct ::udev_enumerate *pointer) const
{
::udev_enumerate_unref(pointer);
}
-};
-
-struct ScopedPointerUdevDeviceDeleter
-{
- static inline void cleanup(struct ::udev_device *pointer)
+ void operator()(struct ::udev_device *pointer) const
{
::udev_device_unref(pointer);
}
};
+template <typename T>
+using udev_ptr = std::unique_ptr<T, udev_deleter>;
#ifndef LINK_LIBUDEV
Q_GLOBAL_STATIC(QLibrary, udevLibrary)
@@ -396,21 +354,20 @@ QList<QSerialPortInfo> availablePortsByUdev(bool &ok)
return QList<QSerialPortInfo>();
#endif
- QScopedPointer<struct ::udev, ScopedPointerUdevDeleter> udev(::udev_new());
+ const udev_ptr<struct ::udev> udev(::udev_new());
if (!udev)
return QList<QSerialPortInfo>();
- QScopedPointer<udev_enumerate, ScopedPointerUdevEnumeratorDeleter>
- enumerate(::udev_enumerate_new(udev.data()));
+ const udev_ptr<udev_enumerate> enumerate(::udev_enumerate_new(udev.get()));
if (!enumerate)
return QList<QSerialPortInfo>();
- ::udev_enumerate_add_match_subsystem(enumerate.data(), "tty");
- ::udev_enumerate_scan_devices(enumerate.data());
+ ::udev_enumerate_add_match_subsystem(enumerate.get(), "tty");
+ ::udev_enumerate_scan_devices(enumerate.get());
- udev_list_entry *devices = ::udev_enumerate_get_list_entry(enumerate.data());
+ udev_list_entry *devices = ::udev_enumerate_get_list_entry(enumerate.get());
QList<QSerialPortInfo> serialPortInfoList;
udev_list_entry *dev_list_entry;
@@ -418,29 +375,29 @@ QList<QSerialPortInfo> availablePortsByUdev(bool &ok)
ok = true;
- QScopedPointer<udev_device, ScopedPointerUdevDeviceDeleter>
+ const udev_ptr<udev_device>
dev(::udev_device_new_from_syspath(
- udev.data(), ::udev_list_entry_get_name(dev_list_entry)));
+ udev.get(), ::udev_list_entry_get_name(dev_list_entry)));
if (!dev)
return serialPortInfoList;
QSerialPortInfoPrivate priv;
- priv.device = deviceLocation(dev.data());
- priv.portName = deviceName(dev.data());
+ priv.device = deviceLocation(dev.get());
+ priv.portName = deviceName(dev.get());
- udev_device *parentdev = ::udev_device_get_parent(dev.data());
+ udev_device *parentdev = ::udev_device_get_parent(dev.get());
if (parentdev) {
const QString driverName = deviceDriver(parentdev);
if (isSerial8250Driver(driverName) && !isValidSerial8250(priv.device))
continue;
- priv.description = deviceDescription(dev.data());
- priv.manufacturer = deviceManufacturer(dev.data());
- priv.serialNumber = deviceSerialNumber(dev.data());
- priv.vendorIdentifier = deviceVendorIdentifier(dev.data(), priv.hasVendorIdentifier);
- priv.productIdentifier = deviceProductIdentifier(dev.data(), priv.hasProductIdentifier);
+ priv.description = deviceDescription(dev.get());
+ priv.manufacturer = deviceManufacturer(dev.get());
+ priv.serialNumber = deviceSerialNumber(dev.get());
+ priv.vendorIdentifier = deviceVendorIdentifier(dev.get(), priv.hasVendorIdentifier);
+ priv.productIdentifier = deviceProductIdentifier(dev.get(), priv.hasProductIdentifier);
} else {
if (!isRfcommDevice(priv.portName)
&& !isVirtualNullModemDevice(priv.portName)
@@ -472,39 +429,6 @@ QList<QSerialPortInfo> QSerialPortInfo::availablePorts()
return serialPortInfoList;
}
-#if QT_DEPRECATED_SINCE(5, 6)
-bool QSerialPortInfo::isBusy() const
-{
- QString lockFilePath = serialPortLockFilePath(portName());
- if (lockFilePath.isEmpty())
- return false;
-
- QFile reader(lockFilePath);
- if (!reader.open(QIODevice::ReadOnly))
- return false;
-
- QByteArray pidLine = reader.readLine();
- pidLine.chop(1);
- if (pidLine.isEmpty())
- return false;
-
- qint64 pid = pidLine.toLongLong();
-
- if (pid && (::kill(pid, 0) == -1) && (errno == ESRCH))
- return false; // PID doesn't exist anymore
-
- return true;
-}
-#endif // QT_DEPRECATED_SINCE(5, 6)
-
-#if QT_DEPRECATED_SINCE(5, 2)
-bool QSerialPortInfo::isValid() const
-{
- QFile f(systemLocation());
- return f.exists();
-}
-#endif // QT_DEPRECATED_SINCE(5, 2)
-
QString QSerialPortInfoPrivate::portNameToSystemLocation(const QString &source)
{
return (source.startsWith(QLatin1Char('/'))
diff --git a/src/serialport/qserialportinfo_win.cpp b/src/serialport/qserialportinfo_win.cpp
index 1bab3e9..30159f1 100644
--- a/src/serialport/qserialportinfo_win.cpp
+++ b/src/serialport/qserialportinfo_win.cpp
@@ -1,43 +1,7 @@
-/****************************************************************************
-**
-** Copyright (C) 2011-2012 Denis Shienkov <denis.shienkov@gmail.com>
-** Copyright (C) 2011 Sergey Belyashov <Sergey.Belyashov@gmail.com>
-** Copyright (C) 2012 Laszlo Papp <lpapp@kde.org>
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtSerialPort module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2011-2012 Denis Shienkov <denis.shienkov@gmail.com>
+// Copyright (C) 2011 Sergey Belyashov <Sergey.Belyashov@gmail.com>
+// Copyright (C) 2012 Laszlo Papp <lpapp@kde.org>
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#include "qserialportinfo.h"
#include "qserialportinfo_p.h"
@@ -347,38 +311,6 @@ QList<QSerialPortInfo> QSerialPortInfo::availablePorts()
return serialPortInfoList;
}
-#if QT_DEPRECATED_SINCE(5, 6)
-bool QSerialPortInfo::isBusy() const
-{
- const HANDLE handle = ::CreateFile(reinterpret_cast<const wchar_t*>(systemLocation().utf16()),
- GENERIC_READ | GENERIC_WRITE, 0, nullptr, OPEN_EXISTING, 0, nullptr);
-
- if (handle == INVALID_HANDLE_VALUE) {
- if (::GetLastError() == ERROR_ACCESS_DENIED)
- return true;
- } else {
- ::CloseHandle(handle);
- }
- return false;
-}
-#endif // QT_DEPRECATED_SINCE(5, 6)
-
-#if QT_DEPRECATED_SINCE(5, 2)
-bool QSerialPortInfo::isValid() const
-{
- const HANDLE handle = ::CreateFile(reinterpret_cast<const wchar_t*>(systemLocation().utf16()),
- GENERIC_READ | GENERIC_WRITE, 0, nullptr, OPEN_EXISTING, 0, nullptr);
-
- if (handle == INVALID_HANDLE_VALUE) {
- if (::GetLastError() != ERROR_ACCESS_DENIED)
- return false;
- } else {
- ::CloseHandle(handle);
- }
- return true;
-}
-#endif // QT_DEPRECATED_SINCE(5, 2)
-
QString QSerialPortInfoPrivate::portNameToSystemLocation(const QString &source)
{
return source.startsWith(QLatin1String("COM"))
diff --git a/src/serialport/qt_cmdline.cmake b/src/serialport/qt_cmdline.cmake
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/src/serialport/qt_cmdline.cmake
diff --git a/src/serialport/qtntdll_p.h b/src/serialport/qtntdll_p.h
deleted file mode 100644
index 2e57201..0000000
--- a/src/serialport/qtntdll_p.h
+++ /dev/null
@@ -1,158 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2019 Denis Shienkov <denis.shienkov@gmail.com>
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtSerialPort module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QTNTDLL_P_H
-#define QTNTDLL_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include <QtCore/qlibrary.h>
-#include <QtCore/qstring.h>
-#include <QtCore/qdebug.h>
-
-#include <qt_windows.h>
-
-// Internal control codes.
-
-#ifndef CTL_CODE
-# define CTL_CODE(DeviceType, Function, Method, Access) ( \
- ((DeviceType) << 16) | ((Access) << 14) | ((Function) << 2) | (Method) \
- )
-#endif
-
-#ifndef FILE_DEVICE_SERIAL_PORT
-# define FILE_DEVICE_SERIAL_PORT 27
-#endif
-
-#ifndef METHOD_BUFFERED
-# define METHOD_BUFFERED 0
-#endif
-
-#ifndef FILE_ANY_ACCESS
-# define FILE_ANY_ACCESS 0x00000000
-#endif
-
-#ifndef IOCTL_SERIAL_GET_DTRRTS
-# define IOCTL_SERIAL_GET_DTRRTS \
- CTL_CODE(FILE_DEVICE_SERIAL_PORT, 30, METHOD_BUFFERED, FILE_ANY_ACCESS)
-#endif
-
-#ifndef SERIAL_DTR_STATE
-# define SERIAL_DTR_STATE 0x00000001
-#endif
-
-#ifndef SERIAL_RTS_STATE
-# define SERIAL_RTS_STATE 0x00000002
-#endif
-
-#ifndef IOCTL_SERIAL_WAIT_ON_MASK
-# define IOCTL_SERIAL_WAIT_ON_MASK \
- CTL_CODE(FILE_DEVICE_SERIAL_PORT, 18, METHOD_BUFFERED, FILE_ANY_ACCESS)
-#endif
-
-// Internal NT-based data types.
-
-#ifndef NT_SUCCESS
-#define NT_SUCCESS(status) (((NTSTATUS)(status)) >= 0)
-#endif
-
-typedef struct _IO_STATUS_BLOCK {
- union {
- NTSTATUS Status;
- PVOID Pointer;
- } DUMMYUNIONNAME;
-
- ULONG_PTR Information;
-} IO_STATUS_BLOCK, *PIO_STATUS_BLOCK;
-
-typedef VOID (WINAPI *PIO_APC_ROUTINE) (
- PVOID ApcContext,
- PIO_STATUS_BLOCK IoStatusBlock,
- ULONG Reserved
- );
-
-// Resolving macros.
-
-#define GENERATE_SYMBOL_VARIABLE(returnType, symbolName, ...) \
- typedef returnType (WINAPI *fp_##symbolName)(__VA_ARGS__); \
- static fp_##symbolName symbolName;
-
-#define RESOLVE_SYMBOL(symbolName) \
- symbolName = reinterpret_cast<fp_##symbolName>(resolveNtdllSymbol(ntLibrary, #symbolName)); \
- if (!symbolName) \
- return false;
-
-GENERATE_SYMBOL_VARIABLE(ULONG, RtlNtStatusToDosError, NTSTATUS)
-GENERATE_SYMBOL_VARIABLE(NTSTATUS, NtDeviceIoControlFile, HANDLE, HANDLE, PIO_APC_ROUTINE, PVOID, PIO_STATUS_BLOCK, ULONG, PVOID, ULONG, PVOID, ULONG)
-
-inline QFunctionPointer resolveNtdllSymbol(QLibrary *ntLibrary, const char *symbolName)
-{
- QFunctionPointer symbolFunctionPointer = ntLibrary->resolve(symbolName);
- if (!symbolFunctionPointer)
- qWarning("Failed to resolve the symbol: %s", symbolName);
-
- return symbolFunctionPointer;
-}
-
-inline bool resolveNtdllSymbols(QLibrary *ntLibrary)
-{
- if (!ntLibrary->isLoaded()) {
- ntLibrary->setFileName(QStringLiteral("ntdll"));
- if (!ntLibrary->load()) {
- qWarning("Failed to load the library: %s", qPrintable(ntLibrary->fileName()));
- return false;
- }
- }
-
- RESOLVE_SYMBOL(RtlNtStatusToDosError)
- RESOLVE_SYMBOL(NtDeviceIoControlFile)
-
- return true;
-}
-
-#endif // QTNTDLL_P_H
diff --git a/src/serialport/qtudev_p.h b/src/serialport/qtudev_p.h
index af2dab2..311fa75 100644
--- a/src/serialport/qtudev_p.h
+++ b/src/serialport/qtudev_p.h
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2013 Laszlo Papp <lpapp@kde.org>
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtSerialPort module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2013 Laszlo Papp <lpapp@kde.org>
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#ifndef QTUDEV_P_H
#define QTUDEV_P_H
@@ -60,6 +24,7 @@ extern "C"
#include <QtCore/qlibrary.h>
#include <QtCore/qstring.h>
#include <QtCore/qdebug.h>
+#include <QtCore/private/qglobal_p.h>
#define GENERATE_SYMBOL_VARIABLE(returnType, symbolName, ...) \
typedef returnType (*fp_##symbolName)(__VA_ARGS__); \
diff --git a/src/serialport/qwinoverlappedionotifier.cpp b/src/serialport/qwinoverlappedionotifier.cpp
index f29bae0..3e85fd8 100644
--- a/src/serialport/qwinoverlappedionotifier.cpp
+++ b/src/serialport/qwinoverlappedionotifier.cpp
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtCore module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#include "qwinoverlappedionotifier_p.h"
#include <qdebug.h>
@@ -129,6 +93,7 @@ public:
HANDLE hSemaphore = nullptr;
HANDLE hResultsMutex = nullptr;
QAtomicInt waiting;
+ QAtomicInt signalSent;
QQueue<IOResult> results;
};
@@ -200,7 +165,7 @@ public:
using QThread::isRunning;
protected:
- void run()
+ void run() override
{
DWORD dwBytesRead = 0;
ULONG_PTR pulCompletionKey = 0;
@@ -313,13 +278,13 @@ OVERLAPPED *QWinOverlappedIoNotifierPrivate::waitForAnyNotified(QDeadlineTimer d
return 0;
}
- DWORD msecs = deadline.remainingTime();
+ qint64 msecs = deadline.remainingTime();
if (msecs == 0)
iocp->drainQueue();
if (msecs == -1)
msecs = INFINITE;
- const DWORD wfso = WaitForSingleObject(hSemaphore, msecs);
+ const DWORD wfso = WaitForSingleObject(hSemaphore, DWORD(msecs));
switch (wfso) {
case WAIT_OBJECT_0:
return dispatchNextIoResult();
@@ -395,16 +360,45 @@ void QWinOverlappedIoNotifierPrivate::notify(DWORD numberOfBytes, DWORD errorCod
Q_Q(QWinOverlappedIoNotifier);
WaitForSingleObject(hResultsMutex, INFINITE);
results.enqueue(IOResult(numberOfBytes, errorCode, overlapped));
- ReleaseMutex(hResultsMutex);
ReleaseSemaphore(hSemaphore, 1, NULL);
- if (!waiting)
+ ReleaseMutex(hResultsMutex);
+ // Do not send a signal if we didn't process the previous one.
+ // This is done to prevent soft memory leaks when working in a completely
+ // synchronous way.
+ if (!waiting && !signalSent.loadAcquire()) {
+ signalSent.storeRelease(1);
emit q->_q_notify();
+ }
}
void QWinOverlappedIoNotifierPrivate::_q_notified()
{
- if (WaitForSingleObject(hSemaphore, 0) == WAIT_OBJECT_0)
- dispatchNextIoResult();
+ Q_Q(QWinOverlappedIoNotifier);
+ signalSent.storeRelease(0); // signal processed - ready for a new one
+ if (WaitForSingleObject(hSemaphore, 0) == WAIT_OBJECT_0) {
+ // As we do not queue signals anymore, we need to process the whole
+ // queue at once.
+ WaitForSingleObject(hResultsMutex, INFINITE);
+ QQueue<IOResult> values;
+ results.swap(values);
+ // Decreasing the semaphore count to keep it in sync with the number
+ // of messages in queue. As ReleaseSemaphore does not accept negative
+ // values, this is sort of a recommended way to go:
+ // https://learn.microsoft.com/en-us/windows/win32/api/synchapi/nf-synchapi-releasesemaphore#remarks
+ int numToDecrease = values.size() - 1;
+ while (numToDecrease > 0) {
+ WaitForSingleObject(hSemaphore, 0);
+ --numToDecrease;
+ }
+ ReleaseMutex(hResultsMutex);
+ // 'q' can go out of scope if the user decides to close the serial port
+ // while processing some answer. So we need to guard against that.
+ QPointer<QWinOverlappedIoNotifier> qptr(q);
+ while (!values.empty() && qptr) {
+ IOResult ioresult = values.dequeue();
+ emit qptr->notified(ioresult.numberOfBytes, ioresult.errorCode, ioresult.overlapped);
+ }
+ }
}
OVERLAPPED *QWinOverlappedIoNotifierPrivate::dispatchNextIoResult()
diff --git a/src/serialport/qwinoverlappedionotifier_p.h b/src/serialport/qwinoverlappedionotifier_p.h
new file mode 100644
index 0000000..45d252e
--- /dev/null
+++ b/src/serialport/qwinoverlappedionotifier_p.h
@@ -0,0 +1,55 @@
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
+
+#ifndef QWINOVERLAPPEDIONOTIFIER_P_H
+#define QWINOVERLAPPEDIONOTIFIER_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <QtCore/private/qglobal_p.h>
+#include <qobject.h>
+#include <qdeadlinetimer.h>
+
+typedef struct _OVERLAPPED OVERLAPPED;
+
+QT_BEGIN_NAMESPACE
+
+class QWinOverlappedIoNotifierPrivate;
+
+class QWinOverlappedIoNotifier : public QObject
+{
+ Q_OBJECT
+ Q_DISABLE_COPY(QWinOverlappedIoNotifier)
+ Q_DECLARE_PRIVATE(QWinOverlappedIoNotifier)
+ Q_PRIVATE_SLOT(d_func(), void _q_notified())
+ friend class QWinIoCompletionPort;
+public:
+ QWinOverlappedIoNotifier(QObject *parent = 0);
+ ~QWinOverlappedIoNotifier();
+
+ void setHandle(Qt::HANDLE h);
+ Qt::HANDLE handle() const;
+
+ void setEnabled(bool enabled);
+ OVERLAPPED *waitForAnyNotified(QDeadlineTimer deadline);
+ bool waitForNotified(QDeadlineTimer deadline, OVERLAPPED *overlapped);
+
+Q_SIGNALS:
+ void notified(quint32 numberOfBytes, quint32 errorCode, OVERLAPPED *overlapped);
+#if !defined(Q_QDOC)
+ void _q_notify();
+#endif
+};
+
+QT_END_NAMESPACE
+
+#endif // QWINOVERLAPPEDIONOTIFIER_P_H
diff --git a/src/serialport/serialport-lib.pri b/src/serialport/serialport-lib.pri
deleted file mode 100644
index b9b3c83..0000000
--- a/src/serialport/serialport-lib.pri
+++ /dev/null
@@ -1,51 +0,0 @@
-INCLUDEPATH += $$PWD
-
-unix:qtConfig(libudev) {
- DEFINES += LINK_LIBUDEV
- INCLUDEPATH += $$QMAKE_INCDIR_LIBUDEV
- LIBS_PRIVATE += $$QMAKE_LIBS_LIBUDEV
-}
-
-PUBLIC_HEADERS += \
- $$PWD/qserialportglobal.h \
- $$PWD/qserialport.h \
- $$PWD/qserialportinfo.h
-
-PRIVATE_HEADERS += \
- $$PWD/qserialport_p.h \
- $$PWD/qserialportinfo_p.h
-
-SOURCES += \
- $$PWD/qserialport.cpp \
- $$PWD/qserialportinfo.cpp
-
-win32 {
- SOURCES += \
- $$PWD/qserialport_win.cpp \
- $$PWD/qserialportinfo_win.cpp \
-
- PRIVATE_HEADERS += \
- $$PWD/qtntdll_p.h
-
- LIBS_PRIVATE += -lsetupapi -ladvapi32
-}
-
-unix {
- SOURCES += \
- $$PWD/qserialport_unix.cpp
-
- osx {
- SOURCES += \
- $$PWD/qserialportinfo_osx.cpp
-
- LIBS_PRIVATE += -framework IOKit -framework CoreFoundation
- } else:freebsd {
- SOURCES += \
- $$PWD/qserialportinfo_freebsd.cpp
- } else {
- SOURCES += \
- $$PWD/qserialportinfo_unix.cpp
- }
-}
-
-HEADERS += $$PUBLIC_HEADERS $$PRIVATE_HEADERS
diff --git a/src/serialport/serialport.pro b/src/serialport/serialport.pro
deleted file mode 100644
index 194958a..0000000
--- a/src/serialport/serialport.pro
+++ /dev/null
@@ -1,12 +0,0 @@
-TARGET = QtSerialPort
-QT = core-private
-
-QMAKE_DOCS = $$PWD/doc/qtserialport.qdocconf
-
-config_ntddmodm: DEFINES += QT_NO_REDEFINE_GUID_DEVINTERFACE_MODEM
-
-include($$PWD/serialport-lib.pri)
-
-load(qt_module)
-
-PRECOMPILED_HEADER =
diff --git a/src/src.pro b/src/src.pro
deleted file mode 100644
index 1426d64..0000000
--- a/src/src.pro
+++ /dev/null
@@ -1,3 +0,0 @@
-TEMPLATE = subdirs
-
-SUBDIRS = serialport
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
new file mode 100644
index 0000000..05cc44c
--- /dev/null
+++ b/tests/CMakeLists.txt
@@ -0,0 +1,8 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
+if(QT_BUILD_STANDALONE_TESTS)
+ # Add qt_find_package calls for extra dependencies that need to be found when building
+ # the standalone tests here.
+endif()
+qt_build_tests()
diff --git a/tests/auto/CMakeLists.txt b/tests/auto/CMakeLists.txt
new file mode 100644
index 0000000..910fe21
--- /dev/null
+++ b/tests/auto/CMakeLists.txt
@@ -0,0 +1,9 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
+add_subdirectory(qserialport)
+add_subdirectory(qserialportinfo)
+add_subdirectory(cmake)
+if(QT_FEATURE_private_tests)
+ add_subdirectory(qserialportinfoprivate)
+endif()
diff --git a/tests/auto/auto.pro b/tests/auto/auto.pro
deleted file mode 100644
index 6c0bcec..0000000
--- a/tests/auto/auto.pro
+++ /dev/null
@@ -1,5 +0,0 @@
-TEMPLATE = subdirs
-SUBDIRS += qserialport qserialportinfo qserialportinfoprivate cmake
-
-!qtConfig(private_tests): SUBDIRS -= \
- qserialportinfoprivate
diff --git a/tests/auto/cmake/CMakeLists.txt b/tests/auto/cmake/CMakeLists.txt
index 597f0d3..cf09459 100644
--- a/tests/auto/cmake/CMakeLists.txt
+++ b/tests/auto/cmake/CMakeLists.txt
@@ -1,14 +1,48 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
-cmake_minimum_required(VERSION 2.8)
-
-project(qmake_cmake_files)
+# This is an automatic test for the CMake configuration files.
+# To run it manually,
+# 1) mkdir build # Create a build directory
+# 2) cd build
+# 3) # Run cmake on this directory
+# `$qt_prefix/bin/qt-cmake ..` or `cmake -DCMAKE_PREFIX_PATH=/path/to/qt ..`
+# 4) ctest # Run ctest
+cmake_minimum_required(VERSION 3.16)
+project(serialport_cmake_tests)
enable_testing()
-find_package(Qt5Core REQUIRED)
+set(required_packages Core SerialPort)
+
+# Setup the test when called as a completely standalone project.
+if(TARGET Qt6::Core)
+ # Tests are built as part of the repository's build tree.
+ # Setup paths so that the Qt packages are found.
+ qt_internal_set_up_build_dir_package_paths()
+endif()
+
+find_package(Qt6 REQUIRED COMPONENTS ${required_packages})
+
+# Setup common test variables which were previously set by ctest_testcase_common.prf.
+set(CMAKE_MODULES_UNDER_TEST "${required_packages}")
-include("${_Qt5CTestMacros}")
+foreach(qt_package ${CMAKE_MODULES_UNDER_TEST})
+ set(package_name "${QT_CMAKE_EXPORT_NAMESPACE}${qt_package}")
+ if(${package_name}_FOUND)
+ set(CMAKE_${qt_package}_MODULE_MAJOR_VERSION "${${package_name}_VERSION_MAJOR}")
+ set(CMAKE_${qt_package}_MODULE_MINOR_VERSION "${${package_name}_VERSION_MINOR}")
+ set(CMAKE_${qt_package}_MODULE_PATCH_VERSION "${${package_name}_VERSION_PATCH}")
+ endif()
+endforeach()
-test_module_includes(
- SerialPort QSerialPort
+include("${_Qt6CTestMacros}")
+
+set(module_includes
+ SerialPort QSerialPort
+)
+
+_qt_internal_test_module_includes(
+ ${module_includes}
)
+
diff --git a/tests/auto/cmake/cmake.pro b/tests/auto/cmake/cmake.pro
deleted file mode 100644
index 6596497..0000000
--- a/tests/auto/cmake/cmake.pro
+++ /dev/null
@@ -1,7 +0,0 @@
-
-# Cause make to do nothing.
-TEMPLATE = subdirs
-
-CMAKE_QT_MODULES_UNDER_TEST = serialport
-
-CONFIG += ctest_testcase
diff --git a/tests/auto/qserialport/CMakeLists.txt b/tests/auto/qserialport/CMakeLists.txt
new file mode 100644
index 0000000..4339424
--- /dev/null
+++ b/tests/auto/qserialport/CMakeLists.txt
@@ -0,0 +1,14 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
+#####################################################################
+## tst_qserialport Binary:
+#####################################################################
+
+qt_internal_add_test(tst_qserialport
+ SOURCES
+ tst_qserialport.cpp
+ LIBRARIES
+ Qt::SerialPort
+ Qt::Test
+)
diff --git a/tests/auto/qserialport/qserialport.pro b/tests/auto/qserialport/qserialport.pro
deleted file mode 100644
index 5435fa3..0000000
--- a/tests/auto/qserialport/qserialport.pro
+++ /dev/null
@@ -1,7 +0,0 @@
-QT = core testlib
-TARGET = tst_qserialport
-#CONFIG += testcase
-
-QT += serialport
-
-SOURCES = tst_qserialport.cpp
diff --git a/tests/auto/qserialport/tst_qserialport.cpp b/tests/auto/qserialport/tst_qserialport.cpp
index f55dac7..a7eeb14 100644
--- a/tests/auto/qserialport/tst_qserialport.cpp
+++ b/tests/auto/qserialport/tst_qserialport.cpp
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2014 Denis Shienkov <denis.shienkov@gmail.com>
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtSerialPort module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2014 Denis Shienkov <denis.shienkov@gmail.com>
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#include <QtTest/QtTest>
#include <QtSerialPort/QSerialPort>
@@ -132,6 +107,8 @@ private slots:
void readWriteWithDifferentBaudRate_data();
void readWriteWithDifferentBaudRate();
+ void bindingsAndProperties();
+
protected slots:
void handleBytesWrittenAndExitLoopSlot(qint64 bytesWritten);
void handleBytesWrittenAndExitLoopSlot2(qint64 bytesWritten);
@@ -270,7 +247,7 @@ void tst_QSerialPort::openExisting()
QFETCH(bool, openResult);
QFETCH(QSerialPort::SerialPortError, errorCode);
- for (const QString &serialPortName : qAsConst(m_availablePortNames)) {
+ for (const QString &serialPortName : std::as_const(m_availablePortNames)) {
QSerialPort serialPort(serialPortName);
QSignalSpy errorSpy(&serialPort, &QSerialPort::errorOccurred);
QVERIFY(errorSpy.isValid());
@@ -280,7 +257,7 @@ void tst_QSerialPort::openExisting()
QCOMPARE(serialPort.isOpen(), openResult);
QCOMPARE(serialPort.error(), errorCode);
- QCOMPARE(errorSpy.count(), 1);
+ QCOMPARE(errorSpy.size(), 1);
QCOMPARE(qvariant_cast<QSerialPort::SerialPortError>(errorSpy.at(0).at(0)), errorCode);
}
}
@@ -503,11 +480,11 @@ void tst_QSerialPort::rts()
QCOMPARE(serialPort.isRequestToSend(), !toggle3); // same as before
QCOMPARE(serialPort.error(), QSerialPort::UnsupportedOperationError);
- QCOMPARE(errorSpy.count(), 2);
+ QCOMPARE(errorSpy.size(), 2);
QCOMPARE(qvariant_cast<QSerialPort::SerialPortError>(errorSpy.at(0).at(0)), QSerialPort::NoError);
QCOMPARE(qvariant_cast<QSerialPort::SerialPortError>(errorSpy.at(1).at(0)), QSerialPort::UnsupportedOperationError);
- QCOMPARE(rtsSpy.count(), 2);
+ QCOMPARE(rtsSpy.size(), 2);
QCOMPARE(qvariant_cast<bool>(rtsSpy.at(0).at(0)), toggle1);
QCOMPARE(qvariant_cast<bool>(rtsSpy.at(1).at(0)), toggle2);
}
@@ -541,10 +518,10 @@ void tst_QSerialPort::dtr()
QVERIFY(serialPort.setDataTerminalReady(toggle3));
QCOMPARE(serialPort.isDataTerminalReady(), toggle3);
- QCOMPARE(errorSpy.count(), 1);
+ QCOMPARE(errorSpy.size(), 1);
QCOMPARE(qvariant_cast<QSerialPort::SerialPortError>(errorSpy.at(0).at(0)), QSerialPort::NoError);
- QCOMPARE(dtrSpy.count(), 3);
+ QCOMPARE(dtrSpy.size(), 3);
QCOMPARE(qvariant_cast<bool>(dtrSpy.at(0).at(0)), toggle1);
QCOMPARE(qvariant_cast<bool>(dtrSpy.at(1).at(0)), toggle2);
QCOMPARE(qvariant_cast<bool>(dtrSpy.at(2).at(0)), toggle3);
@@ -629,7 +606,7 @@ void tst_QSerialPort::flush()
QCOMPARE(serialPort.bytesToWrite(), qint64(0));
enterLoop(1);
QVERIFY2(!timeout(), "Timed out when waiting for the bytesWritten(qint64) signal.");
- QCOMPARE(bytesWrittenSpy.count(), 1);
+ QCOMPARE(bytesWrittenSpy.size(), 1);
}
void tst_QSerialPort::handleBytesWrittenAndExitLoopSlot2(qint64 bytesWritten)
@@ -669,7 +646,7 @@ void tst_QSerialPort::doubleFlush()
enterLoop(1);
QVERIFY2(!timeout(), "Timed out when waiting for the bytesWritten(qint64) signal.");
- QCOMPARE(bytesWrittenSpy.count(), 2);
+ QCOMPARE(bytesWrittenSpy.size(), 2);
}
void tst_QSerialPort::waitForBytesWritten()
@@ -715,7 +692,7 @@ void tst_QSerialPort::waitForReadyReadWithOneByte()
QVERIFY(receiverSerialPort.waitForReadyRead(waitMsecs));
QCOMPARE(receiverSerialPort.bytesAvailable(), oneByte);
QCOMPARE(receiverSerialPort.error(), QSerialPort::NoError);
- QCOMPARE(readyReadSpy.count(), 1);
+ QCOMPARE(readyReadSpy.size(), 1);
}
void tst_QSerialPort::waitForReadyReadWithAlphabet()
@@ -736,7 +713,7 @@ void tst_QSerialPort::waitForReadyReadWithAlphabet()
} while (receiverSerialPort.bytesAvailable() < qint64(alphabetArray.size()));
QCOMPARE(receiverSerialPort.error(), QSerialPort::NoError);
- QVERIFY(readyReadSpy.count() > 0);
+ QVERIFY(readyReadSpy.size() > 0);
}
void tst_QSerialPort::twoStageSynchronousLoopback()
@@ -1048,11 +1025,11 @@ void tst_QSerialPort::readAfterInputClear()
QVERIFY(receiverPort.bytesAvailable() == 0);
}
-class MasterTransactor : public QObject
+class SenderTransactor : public QObject
{
Q_OBJECT
public:
- explicit MasterTransactor(const QString &name)
+ explicit SenderTransactor(const QString &name)
: serialPort(name)
{
}
@@ -1085,7 +1062,7 @@ private slots:
private:
void createAsynchronousConnection()
{
- connect(&serialPort, &QSerialPort::readyRead, this, &MasterTransactor::transaction);
+ connect(&serialPort, &QSerialPort::readyRead, this, &SenderTransactor::transaction);
}
void deleteAsyncronousConnection()
@@ -1096,14 +1073,14 @@ private:
QSerialPort serialPort;
};
-class SlaveTransactor : public QObject
+class ReceiverTransactor : public QObject
{
Q_OBJECT
public:
- explicit SlaveTransactor(const QString &name)
+ explicit ReceiverTransactor(const QString &name)
: serialPort(new QSerialPort(name, this))
{
- connect(serialPort, &QSerialPort::readyRead, this, &SlaveTransactor::transaction);
+ connect(serialPort, &QSerialPort::readyRead, this, &ReceiverTransactor::transaction);
}
public slots:
@@ -1128,17 +1105,17 @@ private:
void tst_QSerialPort::synchronousReadWriteAfterAsynchronousReadWrite()
{
- MasterTransactor master(m_senderPortName);
- auto slave = new SlaveTransactor(m_receiverPortName);
+ SenderTransactor sender(m_senderPortName);
+ auto receiver = new ReceiverTransactor(m_receiverPortName);
QThread thread;
- slave->moveToThread(&thread);
+ receiver->moveToThread(&thread);
thread.start();
- QObject::connect(&thread, &QThread::finished, slave, &SlaveTransactor::deleteLater);
- QObject::connect(slave, &SlaveTransactor::ready, &master, &MasterTransactor::open);
+ QObject::connect(&thread, &QThread::finished, receiver, &ReceiverTransactor::deleteLater);
+ QObject::connect(receiver, &ReceiverTransactor::ready, &sender, &SenderTransactor::open);
- QMetaObject::invokeMethod(slave, "open", Qt::QueuedConnection);
+ QMetaObject::invokeMethod(receiver, "open", Qt::QueuedConnection);
tst_QSerialPort::enterLoopMsecs(2000);
@@ -1196,7 +1173,7 @@ void tst_QSerialPort::controlBreak()
QVERIFY(senderPort.setBreakEnabled(false));
QCOMPARE(senderPort.isBreakEnabled(), false);
- QCOMPARE(breakSpy.count(), 2);
+ QCOMPARE(breakSpy.size(), 2);
QCOMPARE(qvariant_cast<bool>(breakSpy.at(0).at(0)), true);
QCOMPARE(qvariant_cast<bool>(breakSpy.at(1).at(0)), false);
}
@@ -1284,5 +1261,157 @@ void tst_QSerialPort::readWriteWithDifferentBaudRate()
}
}
+void tst_QSerialPort::bindingsAndProperties()
+{
+ QSerialPort sp;
+
+ // -- data bits
+
+ QProperty<QSerialPort::DataBits> dbProp(QSerialPort::DataBits::Data6);
+ QCOMPARE(dbProp.value(), QSerialPort::DataBits::Data6);
+
+ sp.bindableDataBits().setBinding(Qt::makePropertyBinding(dbProp));
+ QCOMPARE(sp.dataBits(), QSerialPort::DataBits::Data6);
+
+ const QSignalSpy dataBitsChangedSpy(&sp, &QSerialPort::dataBitsChanged);
+
+ dbProp = QSerialPort::DataBits::Data5;
+ QCOMPARE(sp.dataBits(), QSerialPort::DataBits::Data5);
+ QCOMPARE(dataBitsChangedSpy.size(), 1);
+ QCOMPARE(dataBitsChangedSpy.at(0).value(0).toInt(), QSerialPort::DataBits::Data5);
+
+ dbProp.setBinding(sp.bindableDataBits().makeBinding());
+ sp.setDataBits(QSerialPort::DataBits::Data8);
+ QCOMPARE(dbProp.value(), QSerialPort::DataBits::Data8);
+
+ dbProp.setBinding([&] { return sp.dataBits(); });
+ sp.setDataBits(QSerialPort::DataBits::Data7);
+ QCOMPARE(dbProp.value(), QSerialPort::DataBits::Data7);
+
+ // -- parity
+
+ QProperty<QSerialPort::Parity> parityProp(QSerialPort::Parity::SpaceParity);
+ QCOMPARE(parityProp.value(), QSerialPort::Parity::SpaceParity);
+
+ sp.bindableParity().setBinding(Qt::makePropertyBinding(parityProp));
+ QCOMPARE(sp.parity(), QSerialPort::Parity::SpaceParity);
+
+ const QSignalSpy parityChangedSpy(&sp, &QSerialPort::parityChanged);
+
+ parityProp = QSerialPort::Parity::EvenParity;
+ QCOMPARE(sp.parity(), QSerialPort::Parity::EvenParity);
+ QCOMPARE(parityChangedSpy.size(), 1);
+ QCOMPARE(parityChangedSpy.at(0).value(0).toInt(), QSerialPort::Parity::EvenParity);
+
+ parityProp.setBinding(sp.bindableParity().makeBinding());
+ sp.setParity(QSerialPort::Parity::NoParity);
+ QCOMPARE(parityProp.value(), QSerialPort::Parity::NoParity);
+
+ parityProp.setBinding([&] { return sp.parity(); });
+ sp.setParity(QSerialPort::Parity::OddParity);
+ QCOMPARE(parityProp.value(), QSerialPort::Parity::OddParity);
+
+ // -- stop bits
+
+ QProperty<QSerialPort::StopBits> sbProp(QSerialPort::StopBits::OneAndHalfStop);
+ QCOMPARE(sbProp.value(), QSerialPort::StopBits::OneAndHalfStop);
+
+ sp.bindableStopBits().setBinding(Qt::makePropertyBinding(sbProp));
+ QCOMPARE(sp.stopBits(), QSerialPort::StopBits::OneAndHalfStop);
+
+ const QSignalSpy stopBitsChangedSpy(&sp, &QSerialPort::stopBitsChanged);
+
+ sbProp = QSerialPort::StopBits::OneStop;
+ QCOMPARE(sp.stopBits(), QSerialPort::StopBits::OneStop);
+ QCOMPARE(stopBitsChangedSpy.size(), 1);
+ QCOMPARE(stopBitsChangedSpy.at(0).value(0).toInt(), QSerialPort::StopBits::OneStop);
+
+ sbProp.setBinding(sp.bindableStopBits().makeBinding());
+ sp.setStopBits(QSerialPort::StopBits::TwoStop);
+ QCOMPARE(sbProp.value(), QSerialPort::StopBits::TwoStop);
+
+ sbProp.setBinding([&] { return sp.stopBits(); });
+ sp.setStopBits(QSerialPort::StopBits::OneAndHalfStop);
+ QCOMPARE(sbProp.value(), QSerialPort::StopBits::OneAndHalfStop);
+
+ // -- flow control
+
+ QProperty<QSerialPort::FlowControl> fcProp(QSerialPort::FlowControl::HardwareControl);
+ QCOMPARE(fcProp.value(), QSerialPort::FlowControl::HardwareControl);
+
+ sp.bindableFlowControl().setBinding(Qt::makePropertyBinding(fcProp));
+ QCOMPARE(sp.flowControl(), QSerialPort::FlowControl::HardwareControl);
+
+ const QSignalSpy flowControlChangedSpy(&sp, &QSerialPort::flowControlChanged);
+
+ fcProp = QSerialPort::FlowControl::NoFlowControl;
+ QCOMPARE(sp.flowControl(), QSerialPort::FlowControl::NoFlowControl);
+ QCOMPARE(flowControlChangedSpy.size(), 1);
+ QCOMPARE(flowControlChangedSpy.at(0).value(0).toInt(), QSerialPort::FlowControl::NoFlowControl);
+
+ fcProp.setBinding(sp.bindableFlowControl().makeBinding());
+ sp.setFlowControl(QSerialPort::FlowControl::SoftwareControl);
+ QCOMPARE(fcProp.value(), QSerialPort::FlowControl::SoftwareControl);
+
+ fcProp.setBinding([&] { return sp.flowControl(); });
+ sp.setFlowControl(QSerialPort::FlowControl::NoFlowControl);
+ QCOMPARE(fcProp.value(), QSerialPort::FlowControl::NoFlowControl);
+
+ // -- error
+
+ QProperty<QSerialPort::SerialPortError> errorProp(QSerialPort::SerialPortError::PermissionError);
+ QCOMPARE(errorProp.value(), QSerialPort::SerialPortError::PermissionError);
+
+ sp.bindableError().setBinding(Qt::makePropertyBinding(errorProp));
+ QCOMPARE(sp.error(), QSerialPort::SerialPortError::NoError);
+
+ const QSignalSpy errorChangedSpy(&sp, &QSerialPort::errorOccurred);
+
+ // this shall not change the error, we do not have a public setter
+ errorProp = QSerialPort::SerialPortError::DeviceNotFoundError;
+ QCOMPARE(sp.error(), QSerialPort::SerialPortError::NoError);
+ QCOMPARE(errorChangedSpy.size(), 0);
+
+ errorProp.setBinding(sp.bindableError().makeBinding());
+ sp.clearError();
+ QCOMPARE(errorProp.value(), QSerialPort::SerialPortError::NoError);
+ QCOMPARE(errorChangedSpy.size(), 1);
+ QCOMPARE(errorChangedSpy.at(0).value(0).toInt(), QSerialPort::SerialPortError::NoError);
+
+ sp.setPortName(m_receiverPortName);
+ const bool portOpened = sp.open(QIODevice::ReadOnly);
+
+ // -- break enabled
+
+ if (portOpened) {
+ QProperty<bool> beProp(false);
+ QCOMPARE(beProp.value(), false);
+
+ sp.bindableIsBreakEnabled().setBinding(Qt::makePropertyBinding(beProp));
+ QCOMPARE(sp.isBreakEnabled(), false);
+
+ const QSignalSpy breakEnabledChangedSpy(&sp, &QSerialPort::breakEnabledChanged);
+
+ beProp = true;
+ QCOMPARE(sp.isBreakEnabled(), true);
+ QCOMPARE(breakEnabledChangedSpy.size(), 1);
+ QCOMPARE(breakEnabledChangedSpy.at(0).value(0).toBool(), true);
+
+ beProp.setBinding(sp.bindableIsBreakEnabled().makeBinding());
+ sp.setBreakEnabled(false);
+ QCOMPARE(beProp.value(), false);
+
+ beProp.setBinding([&] { return sp.isBreakEnabled(); });
+ sp.setBreakEnabled(true);
+ QCOMPARE(beProp.value(), true);
+ } else {
+ // setting isBreakEnabled() will return false and raise an error
+ const auto currErrorCount = errorChangedSpy.size();
+ sp.setBreakEnabled(true);
+ QCOMPARE(errorProp.value(), QSerialPort::SerialPortError::NotOpenError);
+ QCOMPARE(errorChangedSpy.size(), currErrorCount + 1);
+ }
+}
+
QTEST_MAIN(tst_QSerialPort)
#include "tst_qserialport.moc"
diff --git a/tests/auto/qserialportinfo/CMakeLists.txt b/tests/auto/qserialportinfo/CMakeLists.txt
new file mode 100644
index 0000000..6d3fd7a
--- /dev/null
+++ b/tests/auto/qserialportinfo/CMakeLists.txt
@@ -0,0 +1,14 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
+#####################################################################
+## tst_qserialportinfo Binary:
+#####################################################################
+
+qt_internal_add_test(tst_qserialportinfo
+ SOURCES
+ tst_qserialportinfo.cpp
+ LIBRARIES
+ Qt::SerialPort
+ Qt::Test
+)
diff --git a/tests/auto/qserialportinfo/qserialportinfo.pro b/tests/auto/qserialportinfo/qserialportinfo.pro
deleted file mode 100644
index b3e49bd..0000000
--- a/tests/auto/qserialportinfo/qserialportinfo.pro
+++ /dev/null
@@ -1,11 +0,0 @@
-QT = core testlib
-TARGET = tst_qserialportinfo
-#CONFIG += testcase
-
-greaterThan(QT_MAJOR_VERSION, 4) {
- QT += serialport
-} else {
- include($$QTSERIALPORT_PROJECT_ROOT/src/serialport/qt4support/serialport.prf)
-}
-
-SOURCES = tst_qserialportinfo.cpp
diff --git a/tests/auto/qserialportinfo/tst_qserialportinfo.cpp b/tests/auto/qserialportinfo/tst_qserialportinfo.cpp
index 5824f08..b88531d 100644
--- a/tests/auto/qserialportinfo/tst_qserialportinfo.cpp
+++ b/tests/auto/qserialportinfo/tst_qserialportinfo.cpp
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2014 Denis Shienkov <denis.shienkov@gmail.com>
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtSerialPort module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2014 Denis Shienkov <denis.shienkov@gmail.com>
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#include <QtTest/QtTest>
#include <QtSerialPort/QSerialPort>
diff --git a/tests/auto/qserialportinfoprivate/CMakeLists.txt b/tests/auto/qserialportinfoprivate/CMakeLists.txt
new file mode 100644
index 0000000..17185a0
--- /dev/null
+++ b/tests/auto/qserialportinfoprivate/CMakeLists.txt
@@ -0,0 +1,14 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
+#####################################################################
+## tst_qserialportinfoprivate Binary:
+#####################################################################
+
+qt_internal_add_test(tst_qserialportinfoprivate
+ SOURCES
+ tst_qserialportinfoprivate.cpp
+ LIBRARIES
+ Qt::SerialPortPrivate
+ Qt::Test
+)
diff --git a/tests/auto/qserialportinfoprivate/qserialportinfoprivate.pro b/tests/auto/qserialportinfoprivate/qserialportinfoprivate.pro
deleted file mode 100644
index f479a29..0000000
--- a/tests/auto/qserialportinfoprivate/qserialportinfoprivate.pro
+++ /dev/null
@@ -1,4 +0,0 @@
-QT = core testlib serialport-private
-TARGET = tst_qserialportinfoprivate
-#CONFIG += testcase
-SOURCES = tst_qserialportinfoprivate.cpp
diff --git a/tests/auto/qserialportinfoprivate/tst_qserialportinfoprivate.cpp b/tests/auto/qserialportinfoprivate/tst_qserialportinfoprivate.cpp
index e2e66d8..5af3f9f 100644
--- a/tests/auto/qserialportinfoprivate/tst_qserialportinfoprivate.cpp
+++ b/tests/auto/qserialportinfoprivate/tst_qserialportinfoprivate.cpp
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2014 Denis Shienkov <denis.shienkov@gmail.com>
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtSerialPort module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2014 Denis Shienkov <denis.shienkov@gmail.com>
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#include <QtTest/QtTest>
diff --git a/tests/manual/CMakeLists.txt b/tests/manual/CMakeLists.txt
new file mode 100644
index 0000000..3057e84
--- /dev/null
+++ b/tests/manual/CMakeLists.txt
@@ -0,0 +1,7 @@
+# Copyright (C) 2023 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
+if(TARGET Qt::Widgets)
+ add_subdirectory(examples/sender)
+ add_subdirectory(examples/receiver)
+endif()
diff --git a/tests/manual/examples/receiver/CMakeLists.txt b/tests/manual/examples/receiver/CMakeLists.txt
new file mode 100644
index 0000000..0063c20
--- /dev/null
+++ b/tests/manual/examples/receiver/CMakeLists.txt
@@ -0,0 +1,26 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
+cmake_minimum_required(VERSION 3.16)
+project(receiver LANGUAGES CXX)
+
+find_package(Qt6 REQUIRED COMPONENTS Core Gui SerialPort Widgets)
+
+qt_standard_project_setup()
+
+qt_add_executable(receiver
+ dialog.cpp dialog.h
+ main.cpp
+)
+
+set_target_properties(receiver PROPERTIES
+ WIN32_EXECUTABLE TRUE
+ MACOSX_BUNDLE TRUE
+)
+
+target_link_libraries(receiver PRIVATE
+ Qt::Core
+ Qt::Gui
+ Qt::SerialPort
+ Qt::Widgets
+)
diff --git a/examples/serialport/slave/dialog.cpp b/tests/manual/examples/receiver/dialog.cpp
index 31ab795..51e18ea 100644
--- a/examples/serialport/slave/dialog.cpp
+++ b/tests/manual/examples/receiver/dialog.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Denis Shienkov <denis.shienkov@gmail.com>
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtSerialPort module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2012 Denis Shienkov <denis.shienkov@gmail.com>
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "dialog.h"
@@ -65,7 +18,7 @@ Dialog::Dialog(QWidget *parent) :
m_waitRequestLabel(new QLabel(tr("Wait request, msec:"))),
m_waitRequestSpinBox(new QSpinBox),
m_responseLabel(new QLabel(tr("Response:"))),
- m_responseLineEdit(new QLineEdit(tr("Hello, I'm Slave."))),
+ m_responseLineEdit(new QLineEdit(tr("Hello, I'm the receiver."))),
m_trafficLabel(new QLabel(tr("No traffic."))),
m_statusLabel(new QLabel(tr("Status: Not running."))),
m_runButton(new QPushButton(tr("Start")))
@@ -89,12 +42,12 @@ Dialog::Dialog(QWidget *parent) :
mainLayout->addWidget(m_statusLabel, 4, 0, 1, 5);
setLayout(mainLayout);
- setWindowTitle(tr("Slave"));
+ setWindowTitle(tr("Receiver"));
m_serialPortComboBox->setFocus();
m_timer.setSingleShot(true);
- connect(m_runButton, &QPushButton::clicked, this, &Dialog::startSlave);
+ connect(m_runButton, &QPushButton::clicked, this, &Dialog::startReceiver);
connect(&m_serial, &QSerialPort::readyRead, this, &Dialog::readRequest);
connect(&m_timer, &QTimer::timeout, this, &Dialog::processTimeout);
@@ -103,7 +56,7 @@ Dialog::Dialog(QWidget *parent) :
connect(m_responseLineEdit, &QLineEdit::textChanged, this, &Dialog::activateRunButton);
}
-void Dialog::startSlave()
+void Dialog::startReceiver()
{
if (m_serial.portName() != m_serialPortComboBox->currentText()) {
m_serial.close();
diff --git a/tests/manual/examples/receiver/dialog.h b/tests/manual/examples/receiver/dialog.h
new file mode 100644
index 0000000..a32e148
--- /dev/null
+++ b/tests/manual/examples/receiver/dialog.h
@@ -0,0 +1,54 @@
+// Copyright (C) 2012 Denis Shienkov <denis.shienkov@gmail.com>
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#ifndef DIALOG_H
+#define DIALOG_H
+
+#include <QDialog>
+#include <QSerialPort>
+#include <QTimer>
+
+QT_BEGIN_NAMESPACE
+
+class QLabel;
+class QLineEdit;
+class QComboBox;
+class QSpinBox;
+class QPushButton;
+
+QT_END_NAMESPACE
+
+class Dialog : public QDialog
+{
+ Q_OBJECT
+
+public:
+ explicit Dialog(QWidget *parent = nullptr);
+
+private slots:
+ void startReceiver();
+ void readRequest();
+ void processTimeout();
+ void activateRunButton();
+
+private:
+ void processError(const QString &s);
+
+private:
+ int m_transactionCount = 0;
+ QLabel *m_serialPortLabel = nullptr;
+ QComboBox *m_serialPortComboBox = nullptr;
+ QLabel *m_waitRequestLabel = nullptr;
+ QSpinBox *m_waitRequestSpinBox = nullptr;
+ QLabel *m_responseLabel = nullptr;
+ QLineEdit *m_responseLineEdit = nullptr;
+ QLabel *m_trafficLabel = nullptr;
+ QLabel *m_statusLabel = nullptr;
+ QPushButton *m_runButton = nullptr;
+
+ QSerialPort m_serial;
+ QByteArray m_request;
+ QTimer m_timer;
+};
+
+#endif // DIALOG_H
diff --git a/tests/manual/examples/receiver/main.cpp b/tests/manual/examples/receiver/main.cpp
new file mode 100644
index 0000000..f08a0ee
--- /dev/null
+++ b/tests/manual/examples/receiver/main.cpp
@@ -0,0 +1,14 @@
+// Copyright (C) 2012 Denis Shienkov <denis.shienkov@gmail.com>
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#include "dialog.h"
+
+#include <QApplication>
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ Dialog dialog;
+ dialog.show();
+ return app.exec();
+}
diff --git a/tests/manual/examples/receiver/receiver.pro b/tests/manual/examples/receiver/receiver.pro
new file mode 100644
index 0000000..d318006
--- /dev/null
+++ b/tests/manual/examples/receiver/receiver.pro
@@ -0,0 +1,12 @@
+QT += widgets serialport
+requires(qtConfig(combobox))
+
+TARGET = receiver
+TEMPLATE = app
+
+HEADERS += \
+ dialog.h
+
+SOURCES += \
+ main.cpp \
+ dialog.cpp
diff --git a/tests/manual/examples/sender/CMakeLists.txt b/tests/manual/examples/sender/CMakeLists.txt
new file mode 100644
index 0000000..efbd555
--- /dev/null
+++ b/tests/manual/examples/sender/CMakeLists.txt
@@ -0,0 +1,28 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
+cmake_minimum_required(VERSION 3.16)
+project(sender LANGUAGES CXX)
+
+set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/serialport/sender")
+
+find_package(Qt6 REQUIRED COMPONENTS Core Gui SerialPort Widgets)
+
+qt_standard_project_setup()
+
+qt_add_executable(sender
+ dialog.cpp dialog.h
+ main.cpp
+)
+
+set_target_properties(sender PROPERTIES
+ WIN32_EXECUTABLE TRUE
+ MACOSX_BUNDLE TRUE
+)
+
+target_link_libraries(sender PRIVATE
+ Qt::Core
+ Qt::Gui
+ Qt::SerialPort
+ Qt::Widgets
+)
diff --git a/examples/serialport/master/dialog.cpp b/tests/manual/examples/sender/dialog.cpp
index e12d837..d19ec88 100644
--- a/examples/serialport/master/dialog.cpp
+++ b/tests/manual/examples/sender/dialog.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Denis Shienkov <denis.shienkov@gmail.com>
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtSerialPort module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2012 Denis Shienkov <denis.shienkov@gmail.com>
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "dialog.h"
@@ -90,7 +43,7 @@ Dialog::Dialog(QWidget *parent) :
mainLayout->addWidget(m_statusLabel, 4, 0, 1, 5);
setLayout(mainLayout);
- setWindowTitle(tr("Master"));
+ setWindowTitle(tr("Sender"));
m_serialPortComboBox->setFocus();
m_timer.setSingleShot(true);
diff --git a/tests/manual/examples/sender/dialog.h b/tests/manual/examples/sender/dialog.h
new file mode 100644
index 0000000..0f04995
--- /dev/null
+++ b/tests/manual/examples/sender/dialog.h
@@ -0,0 +1,54 @@
+// Copyright (C) 2012 Denis Shienkov <denis.shienkov@gmail.com>
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#ifndef DIALOG_H
+#define DIALOG_H
+
+#include <QDialog>
+#include <QSerialPort>
+#include <QTimer>
+
+QT_BEGIN_NAMESPACE
+
+class QLabel;
+class QLineEdit;
+class QSpinBox;
+class QPushButton;
+class QComboBox;
+
+QT_END_NAMESPACE
+
+class Dialog : public QDialog
+{
+ Q_OBJECT
+
+public:
+ explicit Dialog(QWidget *parent = nullptr);
+
+private slots:
+ void sendRequest();
+ void readResponse();
+ void processTimeout();
+
+private:
+ void setControlsEnabled(bool enable);
+ void processError(const QString &error);
+
+private:
+ int m_transactionCount = 0;
+ QLabel *m_serialPortLabel = nullptr;
+ QComboBox *m_serialPortComboBox = nullptr;
+ QLabel *m_waitResponseLabel = nullptr;
+ QSpinBox *m_waitResponseSpinBox = nullptr;
+ QLabel *m_requestLabel = nullptr;
+ QLineEdit *m_requestLineEdit = nullptr;
+ QLabel *m_trafficLabel = nullptr;
+ QLabel *m_statusLabel = nullptr;
+ QPushButton *m_runButton = nullptr;
+
+ QSerialPort m_serial;
+ QByteArray m_response;
+ QTimer m_timer;
+};
+
+#endif // DIALOG_H
diff --git a/tests/manual/examples/sender/main.cpp b/tests/manual/examples/sender/main.cpp
new file mode 100644
index 0000000..f08a0ee
--- /dev/null
+++ b/tests/manual/examples/sender/main.cpp
@@ -0,0 +1,14 @@
+// Copyright (C) 2012 Denis Shienkov <denis.shienkov@gmail.com>
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#include "dialog.h"
+
+#include <QApplication>
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ Dialog dialog;
+ dialog.show();
+ return app.exec();
+}
diff --git a/tests/manual/examples/sender/sender.pro b/tests/manual/examples/sender/sender.pro
new file mode 100644
index 0000000..f5fc421
--- /dev/null
+++ b/tests/manual/examples/sender/sender.pro
@@ -0,0 +1,12 @@
+QT += widgets serialport
+requires(qtConfig(combobox))
+
+TARGET = sender
+TEMPLATE = app
+
+HEADERS += \
+ dialog.h
+
+SOURCES += \
+ main.cpp \
+ dialog.cpp
diff --git a/tests/tests.pro b/tests/tests.pro
deleted file mode 100644
index 157ef34..0000000
--- a/tests/tests.pro
+++ /dev/null
@@ -1,2 +0,0 @@
-TEMPLATE = subdirs
-SUBDIRS += auto