summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorLaszlo Papp <lpapp@kde.org>2012-05-30 02:18:41 +0300
committerDenis Shienkov <scapig@yandex.ru>2012-05-30 13:23:06 +0200
commit397168d049d4a99f0582e714382f9ff493b43ac8 (patch)
tree3601ff3e01e8abad3e7a73de2ac16e8aa5eab8e6 /examples
parentbd5a7077fafbb73424366d6eadb205a9c4ae2ea4 (diff)
Establish a command line enumerator example mostly for limited environments
This is useful in environment where it is not possible or just not handy to run UI examples to present the operation of the core SerialPort and SerialPortInfo classes in the QtSerialPort add-on module. Typical use cases are embedded BSP boards, like PandaBoard, BeagleBoard, Raspberry Pi and so forth. Usually there is a "direct" connection over ssh or the native serial port to those boards how the developer actually builds projects on the board. It would be nice to build the QtSerialPort project in those cases, and then just fire a command line example up. In fact, while testing the QtSerialPort project on Mac, this is also very useful at least to me since I have only limited access to a Mac box. Perhaps, it can be the same with other people as well having access only to a Linux box remotely and so forth. Task-number: QTPLAYGROUND-1 Change-Id: If4681b05904845108ba2c6243b8955927211137c Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com> Reviewed-by: Denis Shienkov <scapig@yandex.ru>
Diffstat (limited to 'examples')
-rw-r--r--examples/cenumerator/cenumerator.pro11
-rw-r--r--examples/cenumerator/main.cpp68
-rw-r--r--examples/examples.pro2
3 files changed, 80 insertions, 1 deletions
diff --git a/examples/cenumerator/cenumerator.pro b/examples/cenumerator/cenumerator.pro
new file mode 100644
index 00000000..3a77a70d
--- /dev/null
+++ b/examples/cenumerator/cenumerator.pro
@@ -0,0 +1,11 @@
+greaterThan(QT_MAJOR_VERSION, 4) {
+ QT += core serialport
+} else {
+ include($$SERIALPORT_PROJECT_ROOT/src/qt4support/serialport.prf)
+}
+
+TARGET = cenumerator
+TEMPLATE = app
+
+SOURCES += \
+ main.cpp
diff --git a/examples/cenumerator/main.cpp b/examples/cenumerator/main.cpp
new file mode 100644
index 00000000..a544e775
--- /dev/null
+++ b/examples/cenumerator/main.cpp
@@ -0,0 +1,68 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Laszlo Papp <lpapp@kde.org>
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtSerialPort module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QTextStream>
+#include <QCoreApplication>
+#include <QtAddOnSerialPort/serialportinfo.h>
+
+QT_USE_NAMESPACE_SERIALPORT
+
+int main(int argc, char *argv[])
+{
+ QCoreApplication a(argc, argv);
+ QTextStream out(stdout);
+ QList<SerialPortInfo> serialPortInfoList = SerialPortInfo::availablePorts();
+
+ out << QObject::tr("Total number of ports available: ") << serialPortInfoList.count() << endl;
+
+ foreach (const SerialPortInfo &serialPortInfo, serialPortInfoList) {
+ out << endl
+ << QObject::tr("Port: ") << serialPortInfo.portName() << endl
+ << QObject::tr("Location: ") << serialPortInfo.systemLocation() << endl
+ << QObject::tr("Description: ") << serialPortInfo.description() << endl
+ << QObject::tr("Manufacturer: ") << serialPortInfo.manufacturer() << endl
+ << QObject::tr("Vendor Idenifier: ") << serialPortInfo.vendorIdentifier() << endl
+ << QObject::tr("Product Idenifier: ") << serialPortInfo.productIdentifier() << endl
+ << QObject::tr("Busy: ") << (serialPortInfo.isBusy() ? QObject::tr("Yes") : QObject::tr("No")) << endl;
+ }
+
+ return 0;
+}
diff --git a/examples/examples.pro b/examples/examples.pro
index 33716ef4..76029a54 100644
--- a/examples/examples.pro
+++ b/examples/examples.pro
@@ -1,3 +1,3 @@
TEMPLATE = subdirs
CONFIG += ordered
-SUBDIRS = terminal enumerator
+SUBDIRS = terminal enumerator cenumerator