diff options
author | Ivan Solovev <ivan.solovev@qt.io> | 2023-02-08 11:13:18 +0100 |
---|---|---|
committer | Ivan Solovev <ivan.solovev@qt.io> | 2023-02-20 12:05:42 +0100 |
commit | 49aaee74c6f05984356311e9978fe04080bcc327 (patch) | |
tree | 69e75c30824fb7cd241b0fe813d0fce66c9eca52 /examples/serialport/cwriterasync/main.cpp | |
parent | 66be82f475119c85b11c4070088418c006ceb3a2 (diff) | |
download | qtserialport-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>
Diffstat (limited to 'examples/serialport/cwriterasync/main.cpp')
-rw-r--r-- | examples/serialport/cwriterasync/main.cpp | 57 |
1 files changed, 0 insertions, 57 deletions
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(); -} |