From 7a2562aabcc8e1c4659386340956ed44bfbfa6ca Mon Sep 17 00:00:00 2001 From: Andreas Buhr Date: Fri, 8 May 2020 17:36:27 +0200 Subject: Add support for QSerialPort QSerialPort is part of Qt since Qt 5.1. PySide2 so far had no support for QSerialPort. At the same time, QSerialPort was not listed as unsupported. Task-number: PYSIDE-487 Change-Id: I88d4282a206dadf6f398c3f0e5740f02641724b6 Reviewed-by: Friedemann Kleint Reviewed-by: Cristian Maureira-Fredes --- sources/cmake_helpers/helpers.cmake | 2 +- .../pyside2/PySide2/QtSerialPort/CMakeLists.txt | 31 ++++++++++++ .../PySide2/QtSerialPort/typesystem_serialport.xml | 56 +++++++++++++++++++++ sources/pyside2/tests/QtSerialPort/CMakeLists.txt | 1 + sources/pyside2/tests/QtSerialPort/serial.py | 58 ++++++++++++++++++++++ tools/missing_bindings.py | 1 + 6 files changed, 148 insertions(+), 1 deletion(-) create mode 100644 sources/pyside2/PySide2/QtSerialPort/CMakeLists.txt create mode 100644 sources/pyside2/PySide2/QtSerialPort/typesystem_serialport.xml create mode 100644 sources/pyside2/tests/QtSerialPort/CMakeLists.txt create mode 100644 sources/pyside2/tests/QtSerialPort/serial.py diff --git a/sources/cmake_helpers/helpers.cmake b/sources/cmake_helpers/helpers.cmake index 81b52920c..49141de66 100644 --- a/sources/cmake_helpers/helpers.cmake +++ b/sources/cmake_helpers/helpers.cmake @@ -17,7 +17,7 @@ endmacro() macro(collect_optional_modules) # Collect all optional modules. set(ALL_OPTIONAL_MODULES Xml XmlPatterns Help Multimedia -MultimediaWidgets OpenGL OpenGLFunctions Positioning Location Qml Quick QuickWidgets RemoteObjects Scxml Script ScriptTools Sensors TextToSpeech Charts Svg DataVisualization) +MultimediaWidgets OpenGL OpenGLFunctions Positioning Location Qml Quick QuickWidgets RemoteObjects Scxml Script ScriptTools Sensors SerialPort TextToSpeech Charts Svg DataVisualization) find_package(Qt5UiTools) if(Qt5UiTools_FOUND) list(APPEND ALL_OPTIONAL_MODULES UiTools) diff --git a/sources/pyside2/PySide2/QtSerialPort/CMakeLists.txt b/sources/pyside2/PySide2/QtSerialPort/CMakeLists.txt new file mode 100644 index 000000000..d79b3b1e2 --- /dev/null +++ b/sources/pyside2/PySide2/QtSerialPort/CMakeLists.txt @@ -0,0 +1,31 @@ +project(QtSerialPort) + +set(QtSerialPort_OPTIONAL_SRC ) +set(QtSerialPort_DROPPED_ENTRIES ) + +set(QtSerialPort_SRC + ${QtSerialPort_GEN_DIR}/qserialport_wrapper.cpp + ${QtSerialPort_GEN_DIR}/qserialportinfo_wrapper.cpp +# module is always needed + ${QtSerialPort_GEN_DIR}/qtserialport_module_wrapper.cpp +) + +set(QtSerialPort_include_dirs ${QtSerialPort_SOURCE_DIR} + ${QtSerialPort_BINARY_DIR} + ${Qt5Core_INCLUDE_DIRS} + ${Qt5SerialPort_INCLUDE_DIRS} + ${libpyside_SOURCE_DIR} + ${QtCore_GEN_DIR}) + +set(QtSerialPort_libraries pyside2 + ${Qt5SerialPort_LIBRARIES}) + +set(QtSerialPort_deps QtCore) + +create_pyside_module(NAME QtSerialPort + INCLUDE_DIRS QtSerialPort_include_dirs + LIBRARIES QtSerialPort_libraries + DEPS QtSerialPort_deps + TYPESYSTEM_PATH QtSerialPort_SOURCE_DIR + SOURCES QtSerialPort_SRC + DROPPED_ENTRIES QtSerialPort_DROPPED_ENTRIES) diff --git a/sources/pyside2/PySide2/QtSerialPort/typesystem_serialport.xml b/sources/pyside2/PySide2/QtSerialPort/typesystem_serialport.xml new file mode 100644 index 000000000..8548c543e --- /dev/null +++ b/sources/pyside2/PySide2/QtSerialPort/typesystem_serialport.xml @@ -0,0 +1,56 @@ + + + + + + + + + + + + + + + + + diff --git a/sources/pyside2/tests/QtSerialPort/CMakeLists.txt b/sources/pyside2/tests/QtSerialPort/CMakeLists.txt new file mode 100644 index 000000000..554373445 --- /dev/null +++ b/sources/pyside2/tests/QtSerialPort/CMakeLists.txt @@ -0,0 +1 @@ +PYSIDE_TEST(serial.py) diff --git a/sources/pyside2/tests/QtSerialPort/serial.py b/sources/pyside2/tests/QtSerialPort/serial.py new file mode 100644 index 000000000..c30d9eb03 --- /dev/null +++ b/sources/pyside2/tests/QtSerialPort/serial.py @@ -0,0 +1,58 @@ +#!/usr/bin/python + +############################################################################# +## +## Copyright (C) 2020 The Qt Company Ltd. +## Contact: https://www.qt.io/licensing/ +## +## This file is part of the test suite of Qt for Python. +## +## $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$ +## +############################################################################# + +'''Test cases for QSerialPort''' + +import os +import sys +import unittest + +sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) +from init_paths import init_test_paths +init_test_paths(False) + +from PySide2.QtSerialPort import QSerialPort, QSerialPortInfo + + +def callPortInfoMemberFunctions(portinfo): + portinfo.description() + portinfo.hasProductIdentifier() + portinfo.hasVendorIdentifier() + portinfo.isNull() + + +class QSerialPortInfoTest(unittest.TestCase): + def test_available_ports(self): + allportinfos = QSerialPortInfo.availablePorts() + for portinfo in allportinfos: + callPortInfoMemberFunctions(portinfo) + +if __name__ == '__main__': + unittest.main() diff --git a/tools/missing_bindings.py b/tools/missing_bindings.py index a4a418a6e..cfc885c6c 100644 --- a/tools/missing_bindings.py +++ b/tools/missing_bindings.py @@ -115,6 +115,7 @@ modules_to_test['QtPositioning'] = 'qtpositioning-module.html' modules_to_test['QtRemoteObjects'] = 'qtremoteobjects-module.html' modules_to_test['QtScriptTools'] = 'qtscripttools-module.html' modules_to_test['QtSensors'] = 'qtsensors-module.html' +modules_to_test['QtSerialPort'] = 'qtserialport-module.html' types_to_ignore = set() # QtCore types_to_ignore.add('QFlag') -- cgit v1.2.3