summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIvan Solovev <ivan.solovev@qt.io>2023-02-08 11:13:18 +0100
committerIvan Solovev <ivan.solovev@qt.io>2023-02-20 12:05:42 +0100
commit49aaee74c6f05984356311e9978fe04080bcc327 (patch)
tree69e75c30824fb7cd241b0fe813d0fce66c9eca52
parent66be82f475119c85b11c4070088418c006ceb3a2 (diff)
downloadqtserialport-49aaee74c6f05984356311e9978fe04080bcc327.tar.gz
Remove creaderasync and cwriterasync examples
The examples didn't have a good documentation, and the features that they show can also be illustrated using the Terminal example. Remove the examples in scope of global example revamp. Task-number: QTBUG-110645 Pick-to: 6.5 Change-Id: Ib4c91f75bd99de3670d9648b6407fbdefc4e5f18 Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
-rw-r--r--examples/serialport/CMakeLists.txt2
-rw-r--r--examples/serialport/creaderasync/CMakeLists.txt36
-rw-r--r--examples/serialport/creaderasync/creaderasync.pro18
-rw-r--r--examples/serialport/creaderasync/main.cpp45
-rw-r--r--examples/serialport/creaderasync/serialportreader.cpp55
-rw-r--r--examples/serialport/creaderasync/serialportreader.h35
-rw-r--r--examples/serialport/cwriterasync/CMakeLists.txt36
-rw-r--r--examples/serialport/cwriterasync/cwriterasync.pro18
-rw-r--r--examples/serialport/cwriterasync/main.cpp57
-rw-r--r--examples/serialport/cwriterasync/serialportwriter.cpp74
-rw-r--r--examples/serialport/cwriterasync/serialportwriter.h38
-rw-r--r--examples/serialport/doc/creaderasync.qdoc25
-rw-r--r--examples/serialport/doc/cwriterasync.qdoc25
-rw-r--r--examples/serialport/serialport.pro1
-rw-r--r--src/serialport/doc/images/creaderasync-example.pngbin12788 -> 0 bytes
-rw-r--r--src/serialport/doc/images/cwriterasync-example.pngbin11519 -> 0 bytes
16 files changed, 0 insertions, 465 deletions
diff --git a/examples/serialport/CMakeLists.txt b/examples/serialport/CMakeLists.txt
index dd3d50d..f1b6877 100644
--- a/examples/serialport/CMakeLists.txt
+++ b/examples/serialport/CMakeLists.txt
@@ -1,8 +1,6 @@
# Copyright (C) 2023 The Qt Company Ltd.
# SPDX-License-Identifier: BSD-3-Clause
-qt_internal_add_example(creaderasync)
-qt_internal_add_example(cwriterasync)
if(TARGET Qt::Widgets)
qt_internal_add_example(terminal)
qt_internal_add_example(blockingsender)
diff --git a/examples/serialport/creaderasync/CMakeLists.txt b/examples/serialport/creaderasync/CMakeLists.txt
deleted file mode 100644
index b60dbab..0000000
--- a/examples/serialport/creaderasync/CMakeLists.txt
+++ /dev/null
@@ -1,36 +0,0 @@
-# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
-
-cmake_minimum_required(VERSION 3.16)
-project(creaderasync LANGUAGES CXX)
-
-set(CMAKE_AUTOMOC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/serialport/creaderasync")
-
-find_package(Qt6 REQUIRED COMPONENTS Core SerialPort)
-
-qt_add_executable(creaderasync
- main.cpp
- serialportreader.cpp serialportreader.h
-)
-
-set_target_properties(creaderasync PROPERTIES
- WIN32_EXECUTABLE FALSE
- MACOSX_BUNDLE FALSE
-)
-
-target_link_libraries(creaderasync PRIVATE
- Qt::Core
- Qt::SerialPort
-)
-
-install(TARGETS creaderasync
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
-)
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 f371266..0000000
--- a/examples/serialport/creaderasync/main.cpp
+++ /dev/null
@@ -1,45 +0,0 @@
-// Copyright (C) 2013 Laszlo Papp <lpapp@kde.org>
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#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 d7f399b..0000000
--- a/examples/serialport/creaderasync/serialportreader.cpp
+++ /dev/null
@@ -1,55 +0,0 @@
-// Copyright (C) 2013 Laszlo Papp <lpapp@kde.org>
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#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 361db1d..0000000
--- a/examples/serialport/creaderasync/serialportreader.h
+++ /dev/null
@@ -1,35 +0,0 @@
-// Copyright (C) 2013 Laszlo Papp <lpapp@kde.org>
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#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/cwriterasync/CMakeLists.txt b/examples/serialport/cwriterasync/CMakeLists.txt
deleted file mode 100644
index 7f64ccb..0000000
--- a/examples/serialport/cwriterasync/CMakeLists.txt
+++ /dev/null
@@ -1,36 +0,0 @@
-# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
-
-cmake_minimum_required(VERSION 3.16)
-project(cwriterasync LANGUAGES CXX)
-
-set(CMAKE_AUTOMOC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/serialport/cwriterasync")
-
-find_package(Qt6 REQUIRED COMPONENTS Core SerialPort)
-
-qt_add_executable(cwriterasync
- main.cpp
- serialportwriter.cpp serialportwriter.h
-)
-
-set_target_properties(cwriterasync PROPERTIES
- WIN32_EXECUTABLE FALSE
- MACOSX_BUNDLE FALSE
-)
-
-target_link_libraries(cwriterasync PRIVATE
- Qt::Core
- Qt::SerialPort
-)
-
-install(TARGETS cwriterasync
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
-)
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 9424a26..0000000
--- a/examples/serialport/cwriterasync/main.cpp
+++ /dev/null
@@ -1,57 +0,0 @@
-// Copyright (C) 2013 Laszlo Papp <lpapp@kde.org>
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#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 0331b26..0000000
--- a/examples/serialport/cwriterasync/serialportwriter.cpp
+++ /dev/null
@@ -1,74 +0,0 @@
-// Copyright (C) 2013 Laszlo Papp <lpapp@kde.org>
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#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 371fe2a..0000000
--- a/examples/serialport/cwriterasync/serialportwriter.h
+++ /dev/null
@@ -1,38 +0,0 @@
-// Copyright (C) 2013 Laszlo Papp <lpapp@kde.org>
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#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/doc/creaderasync.qdoc b/examples/serialport/doc/creaderasync.qdoc
deleted file mode 100644
index 7843754..0000000
--- a/examples/serialport/doc/creaderasync.qdoc
+++ /dev/null
@@ -1,25 +0,0 @@
-// Copyright (C) 2013 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
-
-/*!
- \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/cwriterasync.qdoc b/examples/serialport/doc/cwriterasync.qdoc
deleted file mode 100644
index bce1de0..0000000
--- a/examples/serialport/doc/cwriterasync.qdoc
+++ /dev/null
@@ -1,25 +0,0 @@
-// Copyright (C) 2013 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
-
-/*!
- \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/serialport.pro b/examples/serialport/serialport.pro
index ed6656b..7a70fbb 100644
--- a/examples/serialport/serialport.pro
+++ b/examples/serialport/serialport.pro
@@ -1,3 +1,2 @@
TEMPLATE = subdirs
-SUBDIRS = creaderasync cwriterasync
!isEmpty(QT.widgets.name):SUBDIRS += terminal blockingsender blockingreceiver
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/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