summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.gitignore21
-rw-r--r--LICENSE (renamed from CHANGES)0
-rw-r--r--doc/EMPTYFILE (renamed from INSTALL)0
-rw-r--r--doc/qserialdevice.qdocconf72
-rw-r--r--doc/src/serialportengine.qdoc1
-rw-r--r--examples/consoleportinfo/consoleportinfo.pro27
-rw-r--r--examples/consoleportinfo/main.cpp22
-rw-r--r--examples/examples.pro2
-rw-r--r--examples/guiportinfo/guiportinfo.pro28
-rw-r--r--examples/guiportinfo/main.cpp11
-rw-r--r--examples/guiportinfo/portinfodialog.cpp93
-rw-r--r--examples/guiportinfo/portinfodialog.h29
-rw-r--r--examples/guiportinfo/portinfodialog.ui158
-rw-r--r--modules/qt_serialport.pri16
-rw-r--r--serialport.pro7
-rw-r--r--src/ringbuffer_p.h6
-rw-r--r--src/serialport-global.h34
-rw-r--r--src/serialport.cpp6
-rw-r--r--src/serialport.h (renamed from include/serialport.h)18
-rw-r--r--src/serialport_p.h5
-rw-r--r--src/serialportengine_p.h4
-rw-r--r--src/serialportengine_symbian.cpp (renamed from src/serialportengine_p_symbian.cpp)6
-rw-r--r--src/serialportengine_symbian_p.h (renamed from src/serialportengine_p_symbian.h)10
-rw-r--r--src/serialportengine_unix.cpp (renamed from src/serialportengine_p_unix.cpp)16
-rw-r--r--src/serialportengine_unix_p.h (renamed from src/serialportengine_p_unix.h)12
-rw-r--r--src/serialportengine_win.cpp (renamed from src/serialportengine_p_win.cpp)12
-rw-r--r--src/serialportengine_win_p.h (renamed from src/serialportengine_p_win.h)12
-rw-r--r--src/serialportinfo.cpp4
-rw-r--r--src/serialportinfo.h (renamed from include/serialportinfo.h)18
-rw-r--r--src/serialportinfo_mac.cpp4
-rw-r--r--src/serialportinfo_p.h4
-rw-r--r--src/serialportinfo_symbian.cpp4
-rw-r--r--src/serialportinfo_unix.cpp82
-rw-r--r--src/serialportinfo_win.cpp10
-rw-r--r--src/src-lib.pri (renamed from src/src.pri)46
-rw-r--r--src/src.pro91
-rw-r--r--src/ttylocker_unix.cpp (renamed from src/ttylocker_p_unix.cpp)208
-rw-r--r--src/ttylocker_unix_p.h (renamed from src/ttylocker_p_unix.h)14
-rw-r--r--sync.profile22
-rw-r--r--tests/consolewaitreader/consolewaitreader.pro25
-rw-r--r--tests/consolewaitreader/main.cpp89
-rw-r--r--tests/consolewriter/consolewriter.pro25
-rw-r--r--tests/consolewriter/main.cpp81
-rw-r--r--tests/guiapp/guiapp.pro33
-rw-r--r--tests/guiapp/main.cpp11
-rw-r--r--tests/guiapp/maindialog.cpp173
-rw-r--r--tests/guiapp/maindialog.h48
-rw-r--r--tests/guiapp/maindialog.ui275
-rw-r--r--tests/guiapp/optionsdialog.cpp249
-rw-r--r--tests/guiapp/optionsdialog.h39
-rw-r--r--tests/guiapp/optionsdialog.ui91
-rw-r--r--tests/guiapp/tracedialog.cpp81
-rw-r--r--tests/guiapp/tracedialog.h34
-rw-r--r--tests/guiapp/tracedialog.ui70
-rw-r--r--tests/guidevtest/guidevtest.pro45
-rw-r--r--tests/guidevtest/main.cpp17
-rw-r--r--tests/guidevtest/maindialog.cpp381
-rw-r--r--tests/guidevtest/maindialog.h82
-rw-r--r--tests/guidevtest/maindialog.ui152
-rw-r--r--tests/guidevtest/unittestinfo.cpp64
-rw-r--r--tests/guidevtest/unittestio.cpp308
-rw-r--r--tests/guidevtest/unittests.h168
-rw-r--r--tests/guidevtest/unittestsignals.cpp218
-rw-r--r--tests/guidevtest/unittestwaitforx.cpp33
64 files changed, 355 insertions, 3572 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 00000000..c88ebd4f
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,21 @@
+*~
+doc/html
+Makefile
+*.dylib
+*.o
+*.a
+moc_*.cpp
+*.pro.user
+*.moc
+lib*.so
+lib*.so.*
+.qmake.cache
+include/QtAddOnSerialPort/*
+lib/cmake/*
+lib*.la
+lib*.prl
+module-paths/*
+src/qtaddonserialportversion.h
+lib/pkgconfig/*
+Makefile.Debug
+Makefile.Release
diff --git a/CHANGES b/LICENSE
index e69de29b..e69de29b 100644
--- a/CHANGES
+++ b/LICENSE
diff --git a/INSTALL b/doc/EMPTYFILE
index e69de29b..e69de29b 100644
--- a/INSTALL
+++ b/doc/EMPTYFILE
diff --git a/doc/qserialdevice.qdocconf b/doc/qserialdevice.qdocconf
deleted file mode 100644
index ca2928e9..00000000
--- a/doc/qserialdevice.qdocconf
+++ /dev/null
@@ -1,72 +0,0 @@
-#include(compat.qdocconf)
-#include(macros.qdocconf)
-#include(qt-cpp-ignore.qdocconf)
-#include(qt-html-templates.qdocconf)
-#include(qt-defines.qdocconf)
-
-project = QSerialDevice
-versionsym =
-version = 2.0
-description = QSerialDevice Reference Documentation
-url = https://gitorious.org/qserialdevice
-
-######
-
-#qhp.projects = QSerialDevice
-
-#qhp.QSerialDevice.file = qserialdevice.qhp
-#qhp.QSerialDevice.namespace = com.gitorious.org.qserialdevice.20
-#qhp.QSerialDevice.virtualFolder = qdoc
-#qhp.QSerialDevice.indexTitle = QSerialDevice Reference Documentation
-#qhp.QSerialDevice.indexRoot =
-
-# Files not referenced in any qdoc file (last four are needed by qtdemo)
-# See also extraimages.HTML
-#qhp.QSerialDevice.extraFiles = classic.css
-
-#qhp.QSerialDevice.filterAttributes = qt 4.7.4 qtrefdoc
-#qhp.QSerialDevice.customFilters.Qt.name = Qt 4.7.4
-#qhp.QSerialDevice.customFilters.Qt.filterAttributes = qt 4.7.4
-#qhp.QSerialDevice.subprojects = classes overviews examples
-#qhp.QSerialDevice.subprojects.classes.title = Classes
-#qhp.QSerialDevice.subprojects.classes.indexTitle = Qt's Classes
-#qhp.QSerialDevice.subprojects.classes.selectors = class fake:headerfile
-#qhp.QSerialDevice.subprojects.classes.sortPages = true
-#qhp.QSerialDevice.subprojects.overviews.title = Overviews
-#qhp.QSerialDevice.subprojects.overviews.indexTitle = All Overviews and HOWTOs
-#qhp.QSerialDevice.subprojects.overviews.selectors = fake:page,group,module
-#qhp.QSerialDevice.subprojects.examples.title = Tutorials and Examples
-#qhp.QSerialDevice.subprojects.examples.indexTitle = Qt Examples
-#qhp.QSerialDevice.subprojects.examples.selectors = fake:example
-
-language = Cpp
-
-Cpp.ignoretokens = SERIALPORT_EXPORT
-
-headers.fileextensions = "*.h"
-sources.fileextensions = "*.cpp *.qdoc *.mm"
-examples.fileextensions = "*.cpp *.h *.js *.xq *.svg *.xml *.ui *.qhp *.qhcp"
-
-headerdirs = $SERIALDEVICE_DIR/include \
- $SERIALDEVICE_DIR/src
-
-sourcedirs = $SERIALDEVICE_DIR/src \
- $SERIALDEVICE_DIR/doc/src
-
-exampledirs = $SERIALDEVICE_DIR/doc/src \
- $SERIALDEVICE_DIR/examples
-
-imagedirs = $SERIALDEVICE_DIR/doc/src/images \
- $SERIALDEVICE_DIR/examples
-
-outputdir = $SERIALDEVICE_DIR/doc/html
-
-tagfile = $SERIALDEVICE_DIR/doc/html/qt.tags
-
-base = file:$SERIALDEVICE_DIR/doc/html
-
-
-
-
-
-
diff --git a/doc/src/serialportengine.qdoc b/doc/src/serialportengine.qdoc
deleted file mode 100644
index e5a49f32..00000000
--- a/doc/src/serialportengine.qdoc
+++ /dev/null
@@ -1 +0,0 @@
-qqq \ No newline at end of file
diff --git a/examples/consoleportinfo/consoleportinfo.pro b/examples/consoleportinfo/consoleportinfo.pro
deleted file mode 100644
index 9bdd996e..00000000
--- a/examples/consoleportinfo/consoleportinfo.pro
+++ /dev/null
@@ -1,27 +0,0 @@
-TEMPLATE = app
-CONFIG += console
-QT -= gui
-OBJECTS_DIR = obj
-MOC_DIR = moc
-
-linux*:DEFINES += HAVE_LIBUDEV
-
-INCLUDEPATH += \
- ../../include
-
-HEADERS += \
- ../../include/serialport.h \
- ../../include/serialportinfo.h
-
-include(../../src/src.pri)
-
-SOURCES += main.cpp
-
-CONFIG(debug, debug|release) {
- DESTDIR = debug
- TARGET = consoleinfod
-} else {
- DESTDIR = release
- TARGET = consoleinfo
-}
-
diff --git a/examples/consoleportinfo/main.cpp b/examples/consoleportinfo/main.cpp
deleted file mode 100644
index c1a3d564..00000000
--- a/examples/consoleportinfo/main.cpp
+++ /dev/null
@@ -1,22 +0,0 @@
-#include <QtCore/QCoreApplication>
-#include <QtCore/QStringList>
-#include <QtCore/QDebug>
-
-#include "serialportinfo.h"
-
-int main(int argc, char *argv[])
-{
- QCoreApplication a(argc, argv);
-
- QList<SerialPortInfo> list = SerialPortInfo::availablePorts();
- int item = 0;
- foreach(SerialPortInfo info, list) {
- qDebug() << "--> Item: " << item++;
- qDebug() << "Port name : " << info.portName();
- qDebug() << "Port location : " << info.systemLocation();
- qDebug() << "Port description : " << info.description();
- qDebug() << "Port manufacturer: " << info.manufacturer();
- }
-
- return a.exec();
-}
diff --git a/examples/examples.pro b/examples/examples.pro
deleted file mode 100644
index 43c38e28..00000000
--- a/examples/examples.pro
+++ /dev/null
@@ -1,2 +0,0 @@
-TEMPLATE = subdirs
-SUBDIRS += consoleportinfo
diff --git a/examples/guiportinfo/guiportinfo.pro b/examples/guiportinfo/guiportinfo.pro
deleted file mode 100644
index df2671e7..00000000
--- a/examples/guiportinfo/guiportinfo.pro
+++ /dev/null
@@ -1,28 +0,0 @@
-#-------------------------------------------------
-#
-# Project created by QtCreator 2011-09-21T13:44:17
-#
-#-------------------------------------------------
-
-QT += core gui
-
-TARGET = guiportinfo
-TEMPLATE = app
-
-linux*:DEFINES += HAVE_LIBUDEV
-
-INCLUDEPATH += \
- ../../include
-
-HEADERS += \
- ../../include/serialport.h \
- ../../include/serialportinfo.h
-
-include(../../src/src.pri)
-
-SOURCES += main.cpp\
- portinfodialog.cpp
-
-HEADERS += portinfodialog.h
-
-FORMS += portinfodialog.ui
diff --git a/examples/guiportinfo/main.cpp b/examples/guiportinfo/main.cpp
deleted file mode 100644
index 2bdf2faf..00000000
--- a/examples/guiportinfo/main.cpp
+++ /dev/null
@@ -1,11 +0,0 @@
-#include <QtGui/QApplication>
-#include "portinfodialog.h"
-
-int main(int argc, char *argv[])
-{
- QApplication a(argc, argv);
- Dialog w;
- w.show();
-
- return a.exec();
-}
diff --git a/examples/guiportinfo/portinfodialog.cpp b/examples/guiportinfo/portinfodialog.cpp
deleted file mode 100644
index 7954e437..00000000
--- a/examples/guiportinfo/portinfodialog.cpp
+++ /dev/null
@@ -1,93 +0,0 @@
-#include "portinfodialog.h"
-#include "ui_portinfodialog.h"
-
-#include "serialportinfo.h"
-
-#include <QtCore/QVariant>
-
-Q_DECLARE_METATYPE(SerialPortInfo)
-
-Dialog::Dialog(QWidget *parent)
- : QDialog(parent)
- , ui(new Ui::Dialog)
-{
- ui->setupUi(this);
- procUpdateAvailablePorts();
- procItemPortChanged(0);
-
- connect(ui->updateButton, SIGNAL(clicked()), this, SLOT(procUpdateAvailablePorts()));
- connect(ui->portsComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(procItemPortChanged(int)));
- connect(ui->busyButton, SIGNAL(clicked()), this, SLOT(procBusyButtonClick()));
- connect(ui->validButton, SIGNAL(clicked()), this, SLOT(procValidButtonClick()));
- connect(ui->ratesButton, SIGNAL(clicked()), this, SLOT(procRatesButtonClick()));
-}
-
-Dialog::~Dialog()
-{
- delete ui;
-}
-
-void Dialog::procUpdateAvailablePorts()
-{
- ui->portsComboBox->clear();
- foreach (SerialPortInfo info, SerialPortInfo::availablePorts()) {
- QVariant v;
- v.setValue(info);
- ui->portsComboBox->addItem(info.portName(), v);
- }
-}
-
-void Dialog::procItemPortChanged(int idx)
-{
- QVariant v = ui->portsComboBox->itemData(idx);
- if (v.isValid()) {
- SerialPortInfo info = v.value<SerialPortInfo>();
-
- ui->locationValueLabel->setText(info.systemLocation());
- ui->descriptionValueLabel->setText(info.description());
- ui->manufacturerValueLabel->setText(info.manufacturer());
-
- ui->busyLabel->setText("***");
- ui->validLabel->setText("***");
- ui->ratesComboBox->clear();
- }
-}
-
-void Dialog::procBusyButtonClick()
-{
- int idx = ui->portsComboBox->currentIndex();
- if (idx >= 0) {
- QVariant v = ui->portsComboBox->itemData(idx);
- if (v.isValid()) {
- SerialPortInfo info = v.value<SerialPortInfo>();
- ui->busyLabel->setText(info.isBusy() ? tr("Busy") : tr("Free"));
- }
- }
-}
-
-void Dialog::procValidButtonClick()
-{
- int idx = ui->portsComboBox->currentIndex();
- if (idx >= 0) {
- QVariant v = ui->portsComboBox->itemData(idx);
- if (v.isValid()) {
- SerialPortInfo info = v.value<SerialPortInfo>();
- ui->validLabel->setText(info.isValid() ? tr("Valid") : tr("Invalid"));
- }
- }
-}
-
-void Dialog::procRatesButtonClick()
-{
- ui->ratesComboBox->clear();
- int idx = ui->portsComboBox->currentIndex();
- if (idx >= 0) {
- QVariant v = ui->portsComboBox->itemData(idx);
- if (v.isValid()) {
- SerialPortInfo info = v.value<SerialPortInfo>();
-
- foreach (qint32 rate, info.standardRates())
- ui->ratesComboBox->addItem(QString::number(rate));
- }
- }
-}
diff --git a/examples/guiportinfo/portinfodialog.h b/examples/guiportinfo/portinfodialog.h
deleted file mode 100644
index 9032be7e..00000000
--- a/examples/guiportinfo/portinfodialog.h
+++ /dev/null
@@ -1,29 +0,0 @@
-#ifndef PORTINFODIALOG_H
-#define PORTINFODIALOG_H
-
-#include <QDialog>
-
-namespace Ui {
- class Dialog;
-}
-
-class Dialog : public QDialog
-{
- Q_OBJECT
-
-public:
- explicit Dialog(QWidget *parent = 0);
- ~Dialog();
-
-private slots:
- void procUpdateAvailablePorts();
- void procItemPortChanged(int idx);
- void procBusyButtonClick();
- void procValidButtonClick();
- void procRatesButtonClick();
-
-private:
- Ui::Dialog *ui;
-};
-
-#endif // PORTINFODIALOG_H
diff --git a/examples/guiportinfo/portinfodialog.ui b/examples/guiportinfo/portinfodialog.ui
deleted file mode 100644
index abe58ecf..00000000
--- a/examples/guiportinfo/portinfodialog.ui
+++ /dev/null
@@ -1,158 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<ui version="4.0">
- <class>Dialog</class>
- <widget class="QDialog" name="Dialog">
- <property name="geometry">
- <rect>
- <x>0</x>
- <y>0</y>
- <width>293</width>
- <height>255</height>
- </rect>
- </property>
- <property name="windowTitle">
- <string>Simple port info application</string>
- </property>
- <layout class="QGridLayout" name="gridLayout_4">
- <item row="0" column="0">
- <widget class="QGroupBox" name="portsGroupBox">
- <property name="title">
- <string>Available ports:</string>
- </property>
- <layout class="QHBoxLayout" name="horizontalLayout">
- <item>
- <widget class="QLabel" name="portNameLabel">
- <property name="text">
- <string>Current port name:</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QComboBox" name="portsComboBox"/>
- </item>
- <item>
- <widget class="QPushButton" name="updateButton">
- <property name="text">
- <string>Update</string>
- </property>
- </widget>
- </item>
- <item>
- <spacer name="horizontalSpacer">
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>0</width>
- <height>20</height>
- </size>
- </property>
- </spacer>
- </item>
- </layout>
- </widget>
- </item>
- <item row="1" column="0">
- <widget class="QGroupBox" name="infoGroupBox">
- <property name="title">
- <string>Current port info:</string>
- </property>
- <layout class="QGridLayout" name="gridLayout_3">
- <item row="0" column="0">
- <layout class="QGridLayout" name="gridLayout">
- <item row="0" column="0">
- <widget class="QLabel" name="locationNameLabel">
- <property name="text">
- <string>Location:</string>
- </property>
- </widget>
- </item>
- <item row="0" column="1">
- <widget class="QLabel" name="locationValueLabel">
- <property name="text">
- <string>***</string>
- </property>
- </widget>
- </item>
- <item row="1" column="0">
- <widget class="QLabel" name="descriptionNameLabel">
- <property name="text">
- <string>Description:</string>
- </property>
- </widget>
- </item>
- <item row="1" column="1">
- <widget class="QLabel" name="descriptionValueLabel">
- <property name="text">
- <string>***</string>
- </property>
- </widget>
- </item>
- <item row="2" column="0">
- <widget class="QLabel" name="manufacturerNameLabel">
- <property name="text">
- <string>Manufacturer:</string>
- </property>
- </widget>
- </item>
- <item row="2" column="1">
- <widget class="QLabel" name="manufacturerValueLabel">
- <property name="text">
- <string>***</string>
- </property>
- </widget>
- </item>
- </layout>
- </item>
- <item row="1" column="0">
- <layout class="QGridLayout" name="gridLayout_2">
- <item row="0" column="0">
- <widget class="QPushButton" name="validButton">
- <property name="text">
- <string>Check valid</string>
- </property>
- </widget>
- </item>
- <item row="0" column="1">
- <widget class="QLabel" name="validLabel">
- <property name="text">
- <string>***</string>
- </property>
- </widget>
- </item>
- <item row="1" column="0">
- <widget class="QPushButton" name="busyButton">
- <property name="text">
- <string>Check busy</string>
- </property>
- </widget>
- </item>
- <item row="1" column="1">
- <widget class="QLabel" name="busyLabel">
- <property name="text">
- <string>***</string>
- </property>
- </widget>
- </item>
- <item row="2" column="0">
- <widget class="QPushButton" name="ratesButton">
- <property name="text">
- <string>Get rates</string>
- </property>
- </widget>
- </item>
- <item row="2" column="1">
- <widget class="QComboBox" name="ratesComboBox"/>
- </item>
- </layout>
- </item>
- </layout>
- </widget>
- </item>
- </layout>
- </widget>
- <layoutdefault spacing="6" margin="11"/>
- <resources/>
- <connections/>
-</ui>
diff --git a/modules/qt_serialport.pri b/modules/qt_serialport.pri
new file mode 100644
index 00000000..0bd4768b
--- /dev/null
+++ b/modules/qt_serialport.pri
@@ -0,0 +1,16 @@
+QT.serialport.VERSION = 1.0.0
+QT.serialport.MAJOR_VERSION = 1
+QT.serialport.MINOR_VERSION = 0
+QT.serialport.PATCH_VERSION = 0
+
+QT.serialport.name = QtAddOnSerialPort
+QT.serialport.bins = $$QT_MODULE_BIN_BASE
+QT.serialport.includes = $$QT_MODULE_INCLUDE_BASE $$QT_MODULE_INCLUDE_BASE/QtAddOnSerialPort
+QT.serialport.private_includes = $$QT_MODULE_INCLUDE_BASE/QtAddOnSerialPort/$$QT.serialport.VERSION
+QT.serialport.sources = $$QT_MODULE_BASE/src
+QT.serialport.libs = $$QT_MODULE_LIB_BASE
+QT.serialport.plugins = $$QT_MODULE_PLUGIN_BASE
+QT.serialport.imports = $$QT_MODULE_IMPORT_BASE
+QT.serialport.depends = core
+
+QT_CONFIG += serialport
diff --git a/serialport.pro b/serialport.pro
index f5e0a590..27d0ba4a 100644
--- a/serialport.pro
+++ b/serialport.pro
@@ -1,5 +1,4 @@
TEMPLATE = subdirs
-SUBDIRS = src
-#examples
-
-
+SUBDIRS = src #tests
+CONFIG += ordered
+#include(doc/doc.pri)
diff --git a/src/ringbuffer_p.h b/src/ringbuffer_p.h
index e99443f8..8a2c3ed2 100644
--- a/src/ringbuffer_p.h
+++ b/src/ringbuffer_p.h
@@ -4,7 +4,9 @@
#include <QtCore/qbytearray.h>
#include <QtCore/qlist.h>
-QT_BEGIN_NAMESPACE
+#include "serialport-global.h"
+
+QT_BEGIN_NAMESPACE_SERIALPORT
class RingBuffer
{
@@ -370,6 +372,6 @@ private:
int bufferSize;
};
-QT_END_NAMESPACE
+QT_END_NAMESPACE_SERIALPORT
#endif // RINGBUFFER_P_H
diff --git a/src/serialport-global.h b/src/serialport-global.h
new file mode 100644
index 00000000..85331aa1
--- /dev/null
+++ b/src/serialport-global.h
@@ -0,0 +1,34 @@
+/*
+ License...
+*/
+
+#ifndef SERIALPORT_GLOBAL_H
+#define SERIALPORT_GLOBAL_H
+
+#include "qglobal.h"
+
+#if defined(QT_ADDON_SERIALPORT_LIB)
+# define Q_ADDON_SERIALPORT_EXPORT Q_DECL_EXPORT
+#else
+# define Q_ADDON_SERIALPORT_EXPORT Q_DECL_IMPORT
+#endif
+
+#if defined(QT_NAMESPACE)
+# define QT_BEGIN_NAMESPACE_SERIALPORT namespace QT_NAMESPACE { namespace QtAddOn { namespace SerialPort {
+# define QT_END_NAMESPACE_SERIALPORT } } }
+# define QT_USE_NAMESPACE_SERIALPORT using namespace QT_NAMESPACE::QtAddOn::SerialPort;
+# define QT_PREPEND_NAMESPACE_SERIALPORT(name) ::QT_NAMESPACE::QtAddOn::SerialPort::name
+#else
+# define QT_BEGIN_NAMESPACE_SERIALPORT namespace QtAddOn { namespace SerialPort {
+# define QT_END_NAMESPACE_SERIALPORT } }
+# define QT_USE_NAMESPACE_SERIALPORT using namespace QtAddOn::SerialPort;
+# define QT_PREPEND_NAMESPACE_SERIALPORT(name) ::QtAddOn::SerialPort::name
+#endif
+
+// a workaround for moc - if there is a header file that doesn't use serialport
+// namespace, we still force moc to do "using namespace" but the namespace have to
+// be defined, so let's define an empty namespace here
+QT_BEGIN_NAMESPACE_SERIALPORT
+QT_END_NAMESPACE_SERIALPORT
+
+#endif // SERIALPORT_GLOBAL_H
diff --git a/src/serialport.cpp b/src/serialport.cpp
index 308a4619..3fe766b5 100644
--- a/src/serialport.cpp
+++ b/src/serialport.cpp
@@ -17,7 +17,7 @@
# define SERIALPORT_BUFFERSIZE 16384
#endif
-QT_USE_NAMESPACE
+QT_BEGIN_NAMESPACE_SERIALPORT
//----------------------------------------------------------------
@@ -1779,3 +1779,7 @@ qint64 SerialPort::writeData(const char *data, qint64 maxSize)
\sa setBreak(), sendBreak()
*/
+
+#include "moc_serialport.cpp"
+
+QT_END_NAMESPACE_SERIALPORT
diff --git a/include/serialport.h b/src/serialport.h
index 2089b325..1282468a 100644
--- a/include/serialport.h
+++ b/src/serialport.h
@@ -7,22 +7,14 @@
#include <QtCore/qiodevice.h>
-#ifdef SERIALPORT_SHARED
-# ifdef SERIALPORT_BUILD
-# define SERIALPORT_EXPORT Q_DECL_EXPORT
-# else
-# define SERIALPORT_EXPORT Q_DECL_IMPORT
-# endif
-#else
-# define SERIALPORT_EXPORT
-#endif
-
-QT_BEGIN_NAMESPACE
+#include "serialport-global.h"
+
+QT_BEGIN_NAMESPACE_SERIALPORT
class SerialPortInfo;
class SerialPortPrivate;
-class SERIALPORT_EXPORT SerialPort : public QIODevice
+class Q_ADDON_SERIALPORT_EXPORT SerialPort : public QIODevice
{
Q_OBJECT
@@ -208,6 +200,6 @@ inline bool SerialPort::clearBreak(bool clear)
Q_DECLARE_OPERATORS_FOR_FLAGS(SerialPort::Directions)
Q_DECLARE_OPERATORS_FOR_FLAGS(SerialPort::Lines)
-QT_END_NAMESPACE
+QT_END_NAMESPACE_SERIALPORT
#endif // SERIALPORT_H
diff --git a/src/serialport_p.h b/src/serialport_p.h
index 4c376caa..3576d518 100644
--- a/src/serialport_p.h
+++ b/src/serialport_p.h
@@ -8,7 +8,7 @@
#include "serialport.h"
#include "ringbuffer_p.h"
-QT_BEGIN_NAMESPACE
+QT_BEGIN_NAMESPACE_SERIALPORT
class SerialPortEngine;
@@ -70,7 +70,6 @@ public:
bool checkRead, bool checkWrite,
bool *selectForRead, bool *selectForWrite);
-
void clearBuffers();
bool readFromPort();
@@ -104,6 +103,6 @@ public:
bool m_restoreSettingsOnClose;
};
-QT_END_NAMESPACE
+QT_END_NAMESPACE_SERIALPORT
#endif // SERIALPORT_P_H
diff --git a/src/serialportengine_p.h b/src/serialportengine_p.h
index 4f122a8a..e163342a 100644
--- a/src/serialportengine_p.h
+++ b/src/serialportengine_p.h
@@ -8,7 +8,7 @@
#include "serialport.h"
#include "serialport_p.h"
-QT_BEGIN_NAMESPACE
+QT_BEGIN_NAMESPACE_SERIALPORT
class SerialPortEngine
{
@@ -79,6 +79,6 @@ protected:
virtual void detectDefaultSettings() = 0;
};
-QT_END_NAMESPACE
+QT_END_NAMESPACE_SERIALPORT
#endif // SERIALPORTENGINE_P_H
diff --git a/src/serialportengine_p_symbian.cpp b/src/serialportengine_symbian.cpp
index 6e7d916e..733c9a3a 100644
--- a/src/serialportengine_p_symbian.cpp
+++ b/src/serialportengine_symbian.cpp
@@ -34,7 +34,7 @@
completely covers all the necessary tasks.
*/
-#include "serialportengine_p_symbian.h"
+#include "serialportengine_symbian_p.h"
#include <e32base.h>
//#include <e32test.h>
@@ -90,7 +90,7 @@ static bool loadDevices()
return true;
}
-QT_USE_NAMESPACE
+QT_BEGIN_NAMESPACE_SERIALPORT
/* Public methods */
@@ -976,6 +976,8 @@ SerialPortEngine *SerialPortEngine::create(SerialPortPrivate *parent)
return new SymbianSerialPortEngine(parent);
}
+#include "moc_serialportengine_symbian_p.cpp"
+QT_END_NAMESPACE_SERIALPORT
diff --git a/src/serialportengine_p_symbian.h b/src/serialportengine_symbian_p.h
index 69f5ec47..ce3851f9 100644
--- a/src/serialportengine_p_symbian.h
+++ b/src/serialportengine_symbian_p.h
@@ -2,15 +2,15 @@
License...
*/
-#ifndef SERIALPORTENGINE_P_SYMBIAN_H
-#define SERIALPORTENGINE_P_SYMBIAN_H
+#ifndef SERIALPORTENGINE_SYMBIAN_P_H
+#define SERIALPORTENGINE_SYMBIAN_P_H
#include "serialport.h"
#include "serialportengine_p.h"
#include <c32comm.h>
-QT_BEGIN_NAMESPACE
+QT_BEGIN_NAMESPACE_SERIALPORT
class SymbianSerialPortEngine : public QObject, public SerialPortEngine
{
@@ -73,6 +73,6 @@ private:
bool updateCommConfig();
};
-QT_END_NAMESPACE
+QT_END_NAMESPACE_SERIALPORT
-#endif // SERIALPORTENGINE_P_SYMBIAN_H
+#endif // SERIALPORTENGINE_SYMBIAN_P_H
diff --git a/src/serialportengine_p_unix.cpp b/src/serialportengine_unix.cpp
index bc379006..8535e2ee 100644
--- a/src/serialportengine_p_unix.cpp
+++ b/src/serialportengine_unix.cpp
@@ -35,8 +35,8 @@
completely covers all the necessary tasks.
*/
-#include "serialportengine_p_unix.h"
-#include "ttylocker_p_unix.h"
+#include "serialportengine_unix_p.h"
+#include "ttylocker_unix_p.h"
#include <errno.h>
#include <sys/time.h>
@@ -55,7 +55,7 @@
#include <QtCore/qsocketnotifier.h>
#include <QtCore/qcoreevent.h>
-QT_USE_NAMESPACE
+QT_BEGIN_NAMESPACE_SERIALPORT
/* Public methods */
@@ -579,10 +579,10 @@ bool UnixSerialPortEngine::select(int timeout,
}
#if defined (Q_OS_MAC)
-static const QString defaultPathPrefix = "/dev/cu.";
-static const QString notUsedPathPrefix = "/dev/tty.";
+static const QString defaultPathPrefix = QLatin1String("/dev/cu.");
+static const QString notUsedPathPrefix = QLatin1String("/dev/tty.");
#else
-static const QString defaultPathPrefix = "/dev/";
+static const QString defaultPathPrefix = QLatin1String("/dev/");
#endif
/*!
@@ -1472,3 +1472,7 @@ SerialPortEngine *SerialPortEngine::create(SerialPortPrivate *parent)
{
return new UnixSerialPortEngine(parent);
}
+
+#include "moc_serialportengine_unix_p.cpp"
+
+QT_END_NAMESPACE_SERIALPORT
diff --git a/src/serialportengine_p_unix.h b/src/serialportengine_unix_p.h
index e83e84fd..78af7b76 100644
--- a/src/serialportengine_p_unix.h
+++ b/src/serialportengine_unix_p.h
@@ -2,8 +2,8 @@
License...
*/
-#ifndef SERIALPORTENGINE_P_UNIX_H
-#define SERIALPORTENGINE_P_UNIX_H
+#ifndef SERIALPORTENGINE_UNIX_P_H
+#define SERIALPORTENGINE_UNIX_P_H
#include "serialport.h"
#include "serialportengine_p.h"
@@ -11,10 +11,10 @@
#include <termios.h>
//# undef CMSPAR
-QT_BEGIN_NAMESPACE
-
class QSocketNotifier;
+QT_BEGIN_NAMESPACE_SERIALPORT
+
class UnixSerialPortEngine : public QObject, public SerialPortEngine
{
Q_OBJECT
@@ -86,6 +86,6 @@ private:
qint64 readPerChar(char *data, qint64 maxSize);
};
-QT_END_NAMESPACE
+QT_END_NAMESPACE_SERIALPORT
-#endif // SERIALPORTENGINE_P_UNIX_H
+#endif // SERIALPORTENGINE_UNIX_P_H
diff --git a/src/serialportengine_p_win.cpp b/src/serialportengine_win.cpp
index 97903127..b2b87d66 100644
--- a/src/serialportengine_p_win.cpp
+++ b/src/serialportengine_win.cpp
@@ -42,7 +42,7 @@
completely covers all the necessary tasks.
*/
-#include "serialportengine_p_win.h"
+#include "serialportengine_win_p.h"
#include <QtCore/qregexp.h>
#if !defined (Q_OS_WINCE)
@@ -87,7 +87,7 @@
#endif
-QT_USE_NAMESPACE
+QT_BEGIN_NAMESPACE_SERIALPORT
/* Public methods */
@@ -694,9 +694,9 @@ bool WinSerialPortEngine::select(int timeout,
}
#if !defined (Q_OS_WINCE)
-static const QString defaultPathPrefix = "\\\\.\\";
+static const QString defaultPathPrefix = QLatin1String("\\\\.\\");
#else
-static const QString defaultPathPostfix = ":";
+static const QString defaultPathPostfix = QLatin1String(":");
#endif
/*!
@@ -1299,3 +1299,7 @@ SerialPortEngine *SerialPortEngine::create(SerialPortPrivate *parent)
return new WinSerialPortEngine(parent);
}
+#include "moc_serialportengine_win_p.cpp"
+
+QT_END_NAMESPACE_SERIALPORT
+
diff --git a/src/serialportengine_p_win.h b/src/serialportengine_win_p.h
index ba1aa956..e30335f9 100644
--- a/src/serialportengine_p_win.h
+++ b/src/serialportengine_win_p.h
@@ -2,8 +2,8 @@
License...
*/
-#ifndef SERIALPORTENGINE_P_WIN_H
-#define SERIALPORTENGINE_P_WIN_H
+#ifndef SERIALPORTENGINE_WIN_P_H
+#define SERIALPORTENGINE_WIN_P_H
#include "serialport.h"
#include "serialportengine_p.h"
@@ -14,10 +14,10 @@
# include <QtCore/qthread.h>
# include <QtCore/qtimer.h>
#else
-# include <QtCore/private/qwineventnotifier_p.h>
+# include <QtCore/qwineventnotifier.h>
#endif
-QT_BEGIN_NAMESPACE
+QT_BEGIN_NAMESPACE_SERIALPORT
#if defined (Q_OS_WINCE)
@@ -157,6 +157,6 @@ private:
bool updateCommTimeouts();
};
-QT_END_NAMESPACE
+QT_END_NAMESPACE_SERIALPORT
-#endif // SERIALPORTENGINE_P_WIN_H
+#endif // SERIALPORTENGINE_WIN_P_H
diff --git a/src/serialportinfo.cpp b/src/serialportinfo.cpp
index 7bf80ce4..4b903acd 100644
--- a/src/serialportinfo.cpp
+++ b/src/serialportinfo.cpp
@@ -6,7 +6,7 @@
#include "serialportinfo_p.h"
#include "serialport.h"
-QT_USE_NAMESPACE
+QT_BEGIN_NAMESPACE_SERIALPORT
/*!
@@ -188,3 +188,5 @@ QString SerialPortInfo::manufacturer() const
Returns a list of available serial ports on the system.
*/
+
+QT_END_NAMESPACE_SERIALPORT
diff --git a/include/serialportinfo.h b/src/serialportinfo.h
index b197d52f..02b93595 100644
--- a/include/serialportinfo.h
+++ b/src/serialportinfo.h
@@ -8,23 +8,15 @@
#include <QtCore/qlist.h>
#include <QtCore/qscopedpointer.h>
-#ifdef SERIALPORT_SHARED
-# ifdef SERIALPORT_BUILD
-# define SERIALPORT_EXPORT Q_DECL_EXPORT
-# else
-# define SERIALPORT_EXPORT Q_DECL_IMPORT
-# endif
-#else
-# define SERIALPORT_EXPORT
-#endif
-
-QT_BEGIN_NAMESPACE
+#include "serialport-global.h"
+
+QT_BEGIN_NAMESPACE_SERIALPORT
class SerialPort;
class SerialPortInfoPrivate;
class SerialInfoPrivateDeleter;
-class SERIALPORT_EXPORT SerialPortInfo
+class Q_ADDON_SERIALPORT_EXPORT SerialPortInfo
{
Q_DECLARE_PRIVATE(SerialPortInfo)
public:
@@ -56,6 +48,6 @@ private:
inline bool SerialPortInfo::isNull() const
{ return !d_ptr; }
-QT_END_NAMESPACE
+QT_END_NAMESPACE_SERIALPORT
#endif // SERIALPORTINFO_H
diff --git a/src/serialportinfo_mac.cpp b/src/serialportinfo_mac.cpp
index 98bc71ed..c0c2a04d 100644
--- a/src/serialportinfo_mac.cpp
+++ b/src/serialportinfo_mac.cpp
@@ -23,7 +23,7 @@
#include <QtCore/qstringlist.h>
#include <QtCore/qfile.h>
-QT_USE_NAMESPACE
+QT_BEGIN_NAMESPACE_SERIALPORT
/* Public methods */
@@ -217,3 +217,5 @@ bool SerialPortInfo::isValid() const
QFile f(systemLocation());
return f.exists();
}
+
+QT_END_NAMESPACE_SERIALPORT
diff --git a/src/serialportinfo_p.h b/src/serialportinfo_p.h
index eaf158b1..b96b626a 100644
--- a/src/serialportinfo_p.h
+++ b/src/serialportinfo_p.h
@@ -9,7 +9,7 @@
#include <QtCore/qstring.h>
-QT_BEGIN_NAMESPACE
+QT_BEGIN_NAMESPACE_SERIALPORT
class SerialPortInfoPrivate
{
@@ -31,6 +31,6 @@ public:
}
};
-QT_END_NAMESPACE
+QT_END_NAMESPACE_SERIALPORT
#endif // SERIALPORTINFO_P_H
diff --git a/src/serialportinfo_symbian.cpp b/src/serialportinfo_symbian.cpp
index bae90b2b..c9055c59 100644
--- a/src/serialportinfo_symbian.cpp
+++ b/src/serialportinfo_symbian.cpp
@@ -58,7 +58,7 @@ static bool loadDevices()
return true;
}
-QT_USE_NAMESPACE
+QT_BEGIN_NAMESPACE_SERIALPORT
/* Public methods */
@@ -226,3 +226,5 @@ bool SerialPortInfo::isValid() const
port.Close();
return (r == KErrNone ) || (r == KErrLocked);
}
+
+QT_END_NAMESPACE_SERIALPORT
diff --git a/src/serialportinfo_unix.cpp b/src/serialportinfo_unix.cpp
index 2081e5c9..5a1161ea 100644
--- a/src/serialportinfo_unix.cpp
+++ b/src/serialportinfo_unix.cpp
@@ -31,24 +31,48 @@ extern "C"
#include <QtCore/qregexp.h>
#include <QtCore/qfile.h>
-QT_USE_NAMESPACE
+
+#if defined (Q_OS_LINUX) && defined (HAVE_LIBUDEV)
+//
+#else
+// This name filters used only for a simple enumeration of all available
+// devices on the mask in /dev, ie if there is no other way to enumerate
+// the devices, used in the following cases:
+// - for Gnu/Linux with no libudev
+// - for any other *nix, bsd (exception mac OSX)
static QStringList nameFilters()
{
static QStringList list;
-#if defined (Q_OS_LINUX)
- list << "ttyS*" /* Standart UART 8250 and etc. */
- << "ttyUSB*" /* Usb/serial converters PL2303 and etc. */
- << "ttyACM*" /* CDC_ACM converters (i.e. Mobile Phones). */
- << "ttyMI*" /* MOXA pci/serial converters. */
- << "rfcomm*"; /* Bluetooth serial device. */
-#elif defined (Q_OS_FREEBSD)
- list << "cu*";
-#else
+# if defined (Q_OS_LINUX)
+ list << QLatin1String("ttyS*") /* Standart UART 8250 and etc. */
+ << QLatin1String("ttyUSB*") /* Usb/serial converters PL2303 and etc. */
+ << QLatin1String("ttyACM*") /* CDC_ACM converters (i.e. Mobile Phones). */
+ << QLatin1String("ttyMI*") /* MOXA pci/serial converters. */
+ << QLatin1String("rfcomm*"); /* Bluetooth serial device. */
+# elif defined (Q_OS_FREEBSD)
+ list << QLatin1String("cu*");
+# else
// Here for other *nix OS.
-#endif
+# endif
return list;
}
+#endif
+
+static
+const qint32 standardRates_begin[] =
+{
+ 50, 75, 110, 134, 150,
+ 200, 300, 600, 1200, 1800,
+ 2400, 4800, 9600, 19200, 38400,
+ 57600, 115200, 230400, 460800,
+ 500000, 576000, 921600, 1000000,
+ 1152000, 1500000, 2000000, 2500000,
+ 3000000, 3500000, 4000000
+}, *standardRates_end = standardRates_begin + sizeof(::standardRates_begin)/sizeof(*::standardRates_begin);
+
+
+QT_BEGIN_NAMESPACE_SERIALPORT
/* Public methods */
@@ -87,30 +111,30 @@ QList<SerialPortInfo> SerialPortInfo::availablePorts()
SerialPortInfo info;
info.d_ptr->device =
- QString(udev_device_get_devnode(dev));
+ QLatin1String(udev_device_get_devnode(dev));
info.d_ptr->portName =
- QString(udev_device_get_sysname(dev));
+ QLatin1String(udev_device_get_sysname(dev));
struct udev_device *parentdev = udev_device_get_parent(dev);
if (parentdev) {
- QString subsys(udev_device_get_subsystem(parentdev));
+ QString subsys(QLatin1String(udev_device_get_subsystem(parentdev)));
bool do_append = true;
- if (subsys.contains("usb")) {
+ if (subsys.contains(QLatin1String("usb"))) {
info.d_ptr->description =
- QString(udev_device_get_property_value(dev,
+ QLatin1String(udev_device_get_property_value(dev,
"ID_MODEL_FROM_DATABASE"));
info.d_ptr->manufacturer =
- QString(udev_device_get_property_value(dev,
+ QLatin1String(udev_device_get_property_value(dev,
"ID_VENDOR_FROM_DATABASE"));
- } else if (subsys == QString("pnp")) {
+ } else if (subsys.contains(QLatin1String("pnp"))) {
info.d_ptr->description =
- QString("Standard serial port.");
+ QLatin1String("Standard serial port.");
info.d_ptr->manufacturer =
- QString("Standard serial ports.");
+ QLatin1String("Standard serial ports.");
} else {
do_append = false;
}
@@ -135,7 +159,7 @@ QList<SerialPortInfo> SerialPortInfo::availablePorts()
#else
// Simple enumerate with device directory /dev scan.
- QDir devDir("/dev");
+ QDir devDir(QLatin1String("/dev"));
if (devDir.exists()) {
devDir.setNameFilters(nameFilters());
@@ -153,7 +177,7 @@ QList<SerialPortInfo> SerialPortInfo::availablePorts()
SerialPortInfo info;
info.d_ptr->device = s;
- info.d_ptr->portName = s.remove(QRegExp("/[\\w|\\d|\\s]+/"));
+ info.d_ptr->portName = s.remove(QRegExp(QLatin1String("/[\\w|\\d|\\s]+/")));
info.d_ptr->description = QString(QObject::tr("Unknown."));
info.d_ptr->manufacturer = QString(QObject::tr("Unknown."));
@@ -169,18 +193,6 @@ QList<SerialPortInfo> SerialPortInfo::availablePorts()
return ports;
}
-static
-const qint32 standardRates_begin[] =
-{
- 50, 75, 110, 134, 150,
- 200, 300, 600, 1200, 1800,
- 2400, 4800, 9600, 19200, 38400,
- 57600, 115200, 230400, 460800,
- 500000, 576000, 921600, 1000000,
- 1152000, 1500000, 2000000, 2500000,
- 3000000, 3500000, 4000000
-}, *standardRates_end = standardRates_begin + sizeof(::standardRates_begin)/sizeof(*::standardRates_begin);
-
QList<qint32> SerialPortInfo::standardRates() const
{
QList<qint32> rates;
@@ -229,3 +241,5 @@ bool SerialPortInfo::isValid() const
QFile f(systemLocation());
return f.exists();
}
+
+QT_END_NAMESPACE_SERIALPORT
diff --git a/src/serialportinfo_win.cpp b/src/serialportinfo_win.cpp
index e14e3de0..31886cc3 100644
--- a/src/serialportinfo_win.cpp
+++ b/src/serialportinfo_win.cpp
@@ -15,7 +15,7 @@
#include <QtCore/qvariant.h>
#include <QtCore/qstringlist.h>
-QT_USE_NAMESPACE
+QT_BEGIN_NAMESPACE_SERIALPORT
static const GUID guidArray[] =
{
@@ -142,7 +142,7 @@ static QString getNativeName(HDEVINFO deviceInfoSet,
QString itemName = QString::fromUtf16(reinterpret_cast<ushort *>(bufKeyName.data()), lenKeyName);
QString itemValue = QString::fromUtf16(((const ushort *)bufKeyVal.constData()));
- if (itemName.contains("PortName")) {
+ if (itemName.contains(QLatin1String("PortName"))) {
result = itemValue;
break;
}
@@ -240,10 +240,10 @@ QList<SerialPortInfo> SerialPortInfo::availablePorts()
QVariant v = getNativeName(deviceInfoSet, &deviceInfoData);
QString s = v.toString();
- if (!(s.isEmpty() || s.contains("LPT"))) {
+ if (!(s.isEmpty() || s.contains(QLatin1String("LPT")))) {
info.d_ptr->portName = s;
- info.d_ptr->device = "\\\\.\\" + s;
+ info.d_ptr->device = QLatin1String("\\\\.\\") + s;
v = getDeviceRegistryProperty(deviceInfoSet, &deviceInfoData, SPDRP_DEVICEDESC);
info.d_ptr->description = v.toString();
@@ -374,3 +374,5 @@ bool SerialPortInfo::isValid() const
::CloseHandle(descriptor);
return true;
}
+
+QT_END_NAMESPACE_SERIALPORT
diff --git a/src/src.pri b/src/src-lib.pri
index e24b24b0..fbe5160c 100644
--- a/src/src.pri
+++ b/src/src-lib.pri
@@ -1,9 +1,13 @@
-INCLUDEPATH += ../include
-HEADERS += \
- ../include/serialport.h \
- ../include/serialportinfo.h
+INCLUDEPATH += $$PWD
-HEADERS += \
+HEADERS += qtaddonserialportversion.h
+
+PUBLIC_HEADERS += \
+ $$PWD/serialport-global.h \
+ $$PWD/serialport.h \
+ $$PWD/serialportinfo.h
+
+PRIVATE_HEADERS += \
$$PWD/serialport_p.h \
$$PWD/ringbuffer_p.h \
$$PWD/serialportengine_p.h \
@@ -13,17 +17,17 @@ SOURCES += \
$$PWD/serialport.cpp \
$$PWD/serialportinfo.cpp
+
win32 {
- HEADERS += \
- $$PWD/serialportengine_p_win.h
+ PRIVATE_HEADERS += \
+ $$PWD/serialportengine_win_p.h
SOURCES += \
- $$PWD/serialportengine_p_win.cpp \
+ $$PWD/serialportengine_win.cpp \
$$PWD/serialportinfo_win.cpp
!wince*: LIBS += -lsetupapi -luuid -ladvapi32
}
-
symbian {
MMP_RULES += EXPORTUNFROZEN
#MMP_RULES += DEBUGGABLE_UDEBONLY
@@ -33,15 +37,15 @@ symbian {
addFiles.sources = SerialPort.dll
addFiles.path = !:/sys/bin
DEPLOYMENT += addFiles
-
+
# FIXME !!!
#INCLUDEPATH += c:/Nokia/devices/Nokia_Symbian3_SDK_v1.0/epoc32/include/platform
INCLUDEPATH += c:/QtSDK/Symbian/SDKs/Symbian3Qt473/epoc32/include/platform
- HEADERS += \
- $$PWD/serialportengine_p_symbian.h
+ PRIVATE_HEADERS += \
+ $$PWD/serialportengine_symbian_p.h
SOURCES += \
- $$PWD/serialportengine_p_symbian.cpp \
+ $$PWD/serialportengine_symbian.cpp \
$$PWD/serialportinfo_symbian.cpp
LIBS += -leuser -lefsrv -lc32
}
@@ -53,21 +57,23 @@ unix:!symbian {
target.path = /usr/lib
}
INSTALLS += target
-
- HEADERS += \
- $$PWD/ttylocker_p_unix.h \
- $$PWD/serialportengine_p_unix.h
+
+ PRIVATE_HEADERS += \
+ $$PWD/ttylocker_unix_p.h \
+ $$PWD/serialportengine_unix_p.h
SOURCES += \
- $$PWD/ttylocker_p_unix.cpp \
- $$PWD/serialportengine_p_unix.cpp
+ $$PWD/ttylocker_unix.cpp \
+ $$PWD/serialportengine_unix.cpp
macx {
SOURCES += $$PWD/serialportinfo_mac.cpp
LIBS += -framework IOKit -framework CoreFoundation
} else {
SOURCES += $$PWD/serialportinfo_unix.cpp
- contains( DEFINES, HAVE_LIBUDEV ) {
+ linux*:contains( DEFINES, HAVE_LIBUDEV ) {
LIBS += -ludev
}
}
}
+
+HEADERS += $$PUBLIC_HEADERS $$PRIVATE_HEADERS
diff --git a/src/src.pro b/src/src.pro
index 3d12d558..fdd53783 100644
--- a/src/src.pro
+++ b/src/src.pro
@@ -1,87 +1,18 @@
TEMPLATE = lib
-CONFIG += dll
-#CONFIG += staticlib
-QT -= gui
-TARGET = SerialPort
+TARGET = $$QT.serialport.name
+MODULE = serialport
-win32 {
- DEFINES += SERIALPORT_BUILD SERIALPORT_SHARED
-}
+load(qt_module)
+load(qt_module_config)
-INCLUDEPATH += ../include
-HEADERS += \
- ../include/serialport.h \
- ../include/serialportinfo.h
-
-HEADERS += \
- serialport_p.h \
- ringbuffer_p.h \
- serialportengine_p.h \
- serialportinfo_p.h
-
-SOURCES += \
- serialport.cpp \
- serialportinfo.cpp
-
-win32 {
- HEADERS += \
- serialportengine_p_win.h
- SOURCES += \
- serialportengine_p_win.cpp \
- serialportinfo_win.cpp
-
- !wince*: LIBS += -lsetupapi -luuid -ladvapi32
-}
-
-
-symbian {
- MMP_RULES += EXPORTUNFROZEN
- #MMP_RULES += DEBUGGABLE_UDEBONLY
- TARGET.UID3 = 0xE7E62DFD
- TARGET.CAPABILITY =
- TARGET.EPOCALLOWDLLDATA = 1
- addFiles.sources = SerialPort.dll
- addFiles.path = !:/sys/bin
- DEPLOYMENT += addFiles
-
- # FIXME !!!
- #INCLUDEPATH += c:/Nokia/devices/Nokia_Symbian3_SDK_v1.0/epoc32/include/platform
- INCLUDEPATH += c:/QtSDK/Symbian/SDKs/Symbian3Qt473/epoc32/include/platform
-
- HEADERS += \
- serialportengine_p_symbian.h
- SOURCES += \
- serialportengine_p_symbian.cpp \
- serialportinfo_symbian.cpp
- LIBS += -leuser -lefsrv -lc32
-}
-
-unix:!symbian {
- maemo5 {
- target.path = /opt/usr/lib
- } else {
- target.path = /usr/lib
- }
- INSTALLS += target
-
- HEADERS += \
- ttylocker_p_unix.h \
- serialportengine_p_unix.h
- SOURCES += \
- ttylocker_p_unix.cpp \
- serialportengine_p_unix.cpp
-
- macx {
- SOURCES += serialportinfo_mac.cpp
- LIBS += -framework IOKit -framework CoreFoundation
- } else {
- SOURCES += serialportinfo_unix.cpp
- linux*:contains( DEFINES, HAVE_LIBUDEV ) {
- LIBS += -ludev
- }
- }
-}
+DESTDIR = $$QT.serialport.libs
+VERSION = $$QT.serialport.VERSION
+DEFINES += QT_ADDON_SERIALPORT_LIB
+CONFIG += module create_prl
+MODULE_PRI = ../modules/qt_serialport.pri
+include($$PWD/src-lib.pri)
+mac:QMAKE_FRAMEWORK_BUNDLE_NAME = $$QT.serialport.name
diff --git a/src/ttylocker_p_unix.cpp b/src/ttylocker_unix.cpp
index 6613a768..2d93e87d 100644
--- a/src/ttylocker_p_unix.cpp
+++ b/src/ttylocker_unix.cpp
@@ -4,42 +4,26 @@
#include "ttylocker_p_unix.h"
-/* this directive by default will not work because when creating Makefile no checks on the existence of:
-1. header: <baudboy.h>
-ie using qmake to do this is impossible (difficult).
-it is possible to solve the transition to CMake*/
#if defined (HAVE_BAUDBOY_H)
# include <baudboy.h>
# include <cstdlib>
-
-/* this directive by default will not work because when creating Makefile no checks on the existence of:
-1. header: <lockdev.h>
-2. library:-llockdev
-ie using qmake to do this is impossible (difficult).
-it is possible to solve the transition to CMake*/
#elif defined (HAVE_LOCKDEV_H)
# include <lockdev.h>
# include <unistd.h>
-
#else
# include <signal.h>
# include <errno.h>
# include <fcntl.h>
# include <sys/stat.h>
-
# include <QtCore/qfile.h>
# include <QtCore/qdir.h>
# include <QtCore/qstringlist.h>
-
-#endif
-
-#include <QtCore/qstring.h>
-
-QT_USE_NAMESPACE
+#endif // defined (HAVE_BAUDBOY_H)
// Truncate the full name of the device to short.
// For example the long name "/dev/ttyS0" will cut up to "ttyS0".
-static QString short_name_from_location(const QString &location)
+static
+QString shortNameFromLocation(const QString &location)
{
return QDir::cleanPath(location).section(QDir::separator() , -1);
}
@@ -47,28 +31,26 @@ static QString short_name_from_location(const QString &location)
#if !(defined (HAVE_BAUDBOY_H) || defined (HAVE_LOCKDEV_H))
-enum {
- LOCK_DIRS_COUNT = 5,
- LOCK_FILE_FORMS_COUNT = 2 //< while unused
-};
-
-static const char *lock_dir_list[LOCK_DIRS_COUNT] = {
+static
+const char *entryLockDirectoryList[] = {
"/var/lock",
"/etc/locks",
"/var/spool/locks",
"/var/spool/uucp",
- "/tmp"
+ "/tmp",
+ 0
};
// Returns the full path first found in the directory where you can create a lock file
// (ie a directory with access to the read/write).
// Verification of directories is of the order in accordance with the order
// of records in the variable lockDirList.
-static QString get_first_shared_lock_dir()
+static
+QString getFirstSharedLockDir()
{
- for (int i = 0; i < LOCK_DIRS_COUNT; ++i) {
- if (::access(lock_dir_list[i], (R_OK | W_OK)) == 0)
- return QString(lock_dir_list[i]);
+ for (int i = 0; entryLockDirectoryList[i] != 0; ++i) {
+ if (::access(entryLockDirectoryList[i], (R_OK | W_OK)) == 0)
+ return QLatin1String(entryLockDirectoryList[i]);
}
return QString();
}
@@ -78,7 +60,7 @@ static QString get_first_shared_lock_dir()
// major and minor device number, eg "LCK.30.50" etc.
static QString get_lock_file_in_numeric_form(const QString &location)
{
- QString result = get_first_shared_lock_dir();
+ QString result = getFirstSharedLockDir();
if (!result.isEmpty()) {
struct stat buf;
if (::stat(location.toLocal8Bit().constData(), &buf))
@@ -94,12 +76,13 @@ static QString get_lock_file_in_numeric_form(const QString &location)
// Returns the name of the lock file which is tied to the
// device name, eg "LCK..ttyS0", etc.
-static QString get_lock_file_in_named_form(const QString &location)
+static
+QString getLockFileInNamedForm(const QString &location)
{
- QString result(get_first_shared_lock_dir());
+ QString result(getFirstSharedLockDir());
if (!result.isEmpty()) {
- result.append("/LCK..%1");
- result = result.arg(short_name_from_location(location));
+ result.append(QLatin1String("/LCK..%1"));
+ result = result.arg(shortNameFromLocation(location));
}
return result;
}
@@ -109,7 +92,7 @@ static QString get_lock_file_in_named_form(const QString &location)
// the process which uses a device, such as "LCK...999", etc.
static QString get_lock_file_in_pid_form(const QString &location)
{
- QString result = get_first_shared_lock_dir();
+ QString result = getFirstSharedLockDir();
if (!result.isEmpty()) {
result.append("/LCK...%1");
result = result.arg(::getpid());
@@ -118,94 +101,31 @@ static QString get_lock_file_in_pid_form(const QString &location)
}
*/
-enum CheckPidResult {
- CHK_PID_PROCESS_NOT_EXISTS, /* process does not exist */
- CHK_PID_PROCESS_EXISTS_FOREIGN, /* process exists and it is "foreign" (ie not current) */
- CHK_PID_PROCESS_EXISTS_CURRENT, /* process exists and it is "their" (ie, current) */
- CHK_PID_UNKNOWN_ERROR /* another error */
-};
-// Checks the validity of the process number that was obtained from the Lock file.
-static enum CheckPidResult check_pid(int pid)
-{
- if (::kill(pid_t(pid), 0) == -1) {
- return (errno == ESRCH) ?
- (CHK_PID_PROCESS_NOT_EXISTS) : (CHK_PID_UNKNOWN_ERROR);
- }
- return (::getpid() == pid) ?
- (CHK_PID_PROCESS_EXISTS_CURRENT) : (CHK_PID_PROCESS_EXISTS_FOREIGN);
-}
+#endif //!(defined (HAVE_BAUDBOY_H) || defined (HAVE_LOCKDEV_H))
-static bool m_islocked(const QString &location, bool *current_pid)
-{
- bool result = false;
- *current_pid = false;
- QFile f(get_lock_file_in_named_form(location));
+QT_BEGIN_NAMESPACE_SERIALPORT
- if (f.exists()) {
- if (!f.open(QIODevice::ReadOnly)) {
- result = true;
- } else {
- QString content(f.readAll());
- f.close();
- bool ok = false;
- int pid = content.section(' ', 0, 0, QString::SectionSkipEmpty).toInt(&ok);
- if (ok) {
- switch (check_pid(pid)) {
- case CHK_PID_PROCESS_NOT_EXISTS:
- break;
- case CHK_PID_PROCESS_EXISTS_FOREIGN:
- result = true;
- break;
- case CHK_PID_PROCESS_EXISTS_CURRENT:
- result = true;
- *current_pid = true;
- break;
- default:
- result = true;
- }
- }
- }
- }
- return result;
-}
-
-static bool m_unlock(const QString &location) {
- QFile f(get_lock_file_in_named_form(location));
- f.remove();
- return true;
-}
-
-bool m_lock(const QString &location)
+// Try lock serial device. However, other processes can not access it.
+bool TTYLocker::lock(const QString &location)
{
bool result = false;
- QFile f(get_lock_file_in_named_form(location));
+#if defined (HAVE_BAUDBOY_H)
+ if (::ttylock(shortNameFromLocation(location).toLocal8Bit().constData()))
+ ::ttywait(shortNameFromLocation(location).toLocal8Bit().constData());
+ result = (::ttylock(shortNameFromLocation(location).toLocal8Bit().constData()) != -1);
+#elif defined (HAVE_LOCKDEV_H)
+ result = (::dev_lock(shortNameFromLocation(location).toLocal8Bit().constData()) != -1);
+#else
+ QFile f(getLockFileInNamedForm(location));
if (f.open(QIODevice::WriteOnly | QIODevice::Truncate)) {
- QString content(" %1 %2\x0A");
+ QString content(QLatin1String(" %1 %2\x0A"));
content = content.arg(::getpid()).arg(::getuid());
if (f.write(content.toLocal8Bit()) > 0)
result = true;
f.close();
}
- return result;
-}
-
-#endif//HAVE_BAUDBOY_H, HAVE_LOCKDEV_H
-
-
-// Try lock serial device. However, other processes can not access it.
-bool TTYLocker::lock(const QString &location)
-{
- bool result = false;
-#if defined (HAVE_BAUDBOY_H)
- if (::ttylock(short_name_from_location(location).toLocal8Bit().constData()))
- ::ttywait(short_name_from_location(location).toLocal8Bit().constData());
- result = (::ttylock(short_name_from_location(location).toLocal8Bit().constData()) != -1);
-#elif defined (HAVE_LOCKDEV_H)
- result = (::dev_lock(short_name_from_location(location).toLocal8Bit().constData()) != -1);
-#else
- result = m_lock(location);
#endif
return result;
}
@@ -213,13 +133,14 @@ bool TTYLocker::lock(const QString &location)
// Try unlock serial device. However, other processes can access it.
bool TTYLocker::unlock(const QString &location)
{
- bool result = false;
+ bool result = true;
#if defined (HAVE_BAUDBOY_H)
- result = (::ttyunlock(short_name_from_location(location).toLocal8Bit().constData()) != -1);
+ result = (::ttyunlock(shortNameFromLocation(location).toLocal8Bit().constData()) != -1);
#elif defined (HAVE_LOCKDEV_H)
- result = (::dev_unlock(short_name_from_location(location).toLocal8Bit().constData(), ::getpid()) != -1);
+ result = (::dev_unlock(shortNameFromLocation(location).toLocal8Bit().constData(), ::getpid()) != -1);
#else
- result = m_unlock(location);
+ QFile f(getLockFileInNamedForm(location));
+ f.remove();
#endif
return result;
}
@@ -230,13 +151,62 @@ bool TTYLocker::isLocked(const QString &location, bool *currentPid)
{
bool result = false;
#if defined (HAVE_BAUDBOY_H)
- result = (::ttylocked(short_name_from_location(location).toLocal8Bit().constData()) != -1);
+ result = (::ttylocked(shortNameFromLocation(location).toLocal8Bit().constData()) != -1);
*currentPid = false;
#elif defined (HAVE_LOCKDEV_H)
- result = (::dev_testlock(short_name_from_location(location).toLocal8Bit().constData()) != -1);
+ result = (::dev_testlock(shortNameFromLocation(location).toLocal8Bit().constData()) != -1);
*currentPid = false;
#else
- result = m_islocked(location, currentPid);
+
+ enum CheckPidResult {
+ CHK_PID_PROCESS_NOT_EXISTS, /* process does not exist */
+ CHK_PID_PROCESS_EXISTS_FOREIGN, /* process exists and it is "foreign" (ie not current) */
+ CHK_PID_PROCESS_EXISTS_CURRENT, /* process exists and it is "their" (ie, current) */
+ CHK_PID_UNKNOWN_ERROR /* another error */
+ };
+
+ *currentPid = false;
+
+ QFile f(getLockFileInNamedForm(location));
+ if (f.exists()) {
+ if (!f.open(QIODevice::ReadOnly)) {
+ result = true;
+ } else {
+ QString content(QLatin1String(f.readAll()));
+ f.close();
+ bool ok = false;
+ int pid = content.section(' ', 0, 0, QString::SectionSkipEmpty).toInt(&ok);
+ if (ok) {
+
+ // Checks the validity of the process number that was obtained from the Lock file.
+ enum CheckPidResult pidResult = CHK_PID_UNKNOWN_ERROR;
+
+ if (::kill(pid_t(pid), 0) == -1) {
+ pidResult = (errno == ESRCH) ?
+ (CHK_PID_PROCESS_NOT_EXISTS) : (CHK_PID_UNKNOWN_ERROR);
+ } else {
+ pidResult = (::getpid() == pid) ?
+ (CHK_PID_PROCESS_EXISTS_CURRENT) : (CHK_PID_PROCESS_EXISTS_FOREIGN);
+ }
+
+ switch (pidResult) {
+ case CHK_PID_PROCESS_NOT_EXISTS:
+ break;
+ case CHK_PID_PROCESS_EXISTS_FOREIGN:
+ result = true;
+ break;
+ case CHK_PID_PROCESS_EXISTS_CURRENT:
+ result = true;
+ *currentPid = true;
+ break;
+ default:
+ result = true;
+ }
+ }
+ }
+ }
#endif
return result;
}
+
+QT_END_NAMESPACE_SERIALPORT
diff --git a/src/ttylocker_p_unix.h b/src/ttylocker_unix_p.h
index 84a5adce..1c2a0cc0 100644
--- a/src/ttylocker_p_unix.h
+++ b/src/ttylocker_unix_p.h
@@ -2,14 +2,12 @@
License...
*/
-#ifndef TTYLOCKER_P_UNIX_H
-#define TTYLOCKER_P_UNIX_H
+#ifndef TTYLOCKER_UNIX_P_H
+#define TTYLOCKER_UNIX_P_H
-#include <QtCore/qstring.h>
+#include "serialport-global.h"
-QT_BEGIN_NAMESPACE
-
-class QString;
+QT_BEGIN_NAMESPACE_SERIALPORT
class TTYLocker
{
@@ -19,6 +17,6 @@ public:
static bool isLocked(const QString &location, bool *currentPid);
};
-QT_END_NAMESPACE
+QT_END_NAMESPACE_SERIALPORT
-#endif // TTYLOCKER_P_UNIX_H
+#endif // TTYLOCKER_UNIX_P_H
diff --git a/sync.profile b/sync.profile
new file mode 100644
index 00000000..23b9ac5a
--- /dev/null
+++ b/sync.profile
@@ -0,0 +1,22 @@
+%modules = ( # path to module name map
+ "QtAddOnSerialPort" => "$basedir/src",
+);
+%moduleheaders = ( # restrict the module headers to those found in relative path
+);
+%classnames = (
+ "qtaddonserialportversion.h" => "QtAddOnSerialPortVersion",
+);
+%mastercontent = (
+);
+%modulepris = (
+ "QtAddOnSerialPort" => "$basedir/modules/qt_serialport.pri",
+);
+# Module dependencies.
+# Every module that is required to build this module should have one entry.
+# Each of the module version specifiers can take one of the following values:
+# - A specific Git revision.
+# - any git symbolic ref resolvable from the module's repository (e.g. "refs/heads/master" to track master branch)
+#
+%dependencies = (
+ "qtbase" => "refs/heads/master",
+);
diff --git a/tests/consolewaitreader/consolewaitreader.pro b/tests/consolewaitreader/consolewaitreader.pro
deleted file mode 100644
index 44182165..00000000
--- a/tests/consolewaitreader/consolewaitreader.pro
+++ /dev/null
@@ -1,25 +0,0 @@
-TEMPLATE = app
-CONFIG += console
-QT -= gui
-OBJECTS_DIR = obj
-MOC_DIR = moc
-
-INCLUDEPATH += \
- ../../include \
- ../../src
-
-HEADERS += \
- ../../include/serialport.h \
- ../../include/serialportinfo.h
-
-include(../../src/src.pri)
-
-SOURCES += main.cpp
-
-CONFIG(debug, debug|release) {
- DESTDIR = debug
- TARGET = consolewaitreaderd
-} else {
- DESTDIR = release
- TARGET = consolewaitreader
-}
diff --git a/tests/consolewaitreader/main.cpp b/tests/consolewaitreader/main.cpp
deleted file mode 100644
index a06fa3e9..00000000
--- a/tests/consolewaitreader/main.cpp
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
-* ConsoleWaitReader
-*
-* This application is part of the examples on the use of the library QSerialDevice.
-*
-* ConsoleWaitReader - a test console application to read data from the port using the method
-* of expectations waitForReadyRead().
-*
-* Copyright (C) 2011 Denis Shienkov
-*
-* Contact Denis Shienkov:
-* e-mail: <scapig2@yandex.ru>
-* ICQ: 321789831
-*/
-
-#include <iostream>
-#include <QtCore/QCoreApplication>
-
-#include "serialport.h"
-
-int main(int argc, char *argv[])
-{
- QCoreApplication app(argc, argv);
-
- // 1. First - create an instance of an object.
- SerialPort port;
-
- char inbuf[30];
-
- std::cout << "Please enter serial device name,\n"
- "specific by OS, example\n"
- "- in Windows: COMn\n"
- "- in GNU/Linux: ttyXYZn\n"
- ":";
- std::cin >> inbuf;
-
- // 2. Second - set the device name.
- port.setPort(QString(inbuf));
-
- std::cout << "The port will be opened in read-only mode (QIODevice::ReadOnly).\n"
- "But you can choose to buffered or not (QIODevice::Unbuffered).\n"
- "To understand what is the difference - try to change these modes!\n"
- "Disable buffering [y/N] ?:";
- std::cin >> inbuf;
-
- QIODevice::OpenMode mode = QIODevice::ReadOnly;
- if (inbuf[0] == 'y')
- mode |= QIODevice::Unbuffered;
-
- // 3. Third - open the device.
- if (port.open(mode)) {
-
- // 4. Fourth - now you can configure it (only after successfully opened!).
- if (port.setRate(115200) && port.setDataBits(SerialPort::Data8)
- && port.setParity(SerialPort::NoParity) && port.setStopBits(SerialPort::OneStop)
- && port.setFlowControl(SerialPort::NoFlowControl)) {
-
- int msecs = 0;
- std::cout << "Please enter wait timeout for ready read, msec: ";
- std::cin >> msecs;
-
- int len = 0;
- std::cout << "Please enter len data for read, bytes: ";
- std::cin >> len;
-
- // 5. Fifth - you can now read/write device, or further modify its settings, etc.
- while (1) {
-
- std::cout << "Now starting wait data ..." << std::endl;
-
- if ((port.bytesAvailable() > 0) || port.waitForReadyRead(msecs)) {
-
- QByteArray data = port.read(len);
-
- std::cout << "Readed " << data.size() << " bytes" << std::endl;
- } else {
- std::cout << "Wait timeout expired." << std::endl;
- }
- }
- } else {
- std::cout << "Configure " << port.portName().toLocal8Bit().constData() << " fail.";
- port.close();
- }
- } else {
- std::cout << "Open " << port.portName().toLocal8Bit().constData() << " fail.";
- }
-
- return app.exec();
-}
diff --git a/tests/consolewriter/consolewriter.pro b/tests/consolewriter/consolewriter.pro
deleted file mode 100644
index 335d92c7..00000000
--- a/tests/consolewriter/consolewriter.pro
+++ /dev/null
@@ -1,25 +0,0 @@
-TEMPLATE = app
-CONFIG += console
-QT -= gui
-OBJECTS_DIR = obj
-MOC_DIR = moc
-
-INCLUDEPATH += \
- ../../include \
- ../../src
-
-HEADERS += \
- ../../include/serialport.h \
- ../../include/serialportinfo.h
-
-include(../../src/src.pri)
-
-SOURCES += main.cpp
-
-CONFIG(debug, debug|release) {
- DESTDIR = debug
- TARGET = consolewriterd
-} else {
- DESTDIR = release
- TARGET = consolewriter
-}
diff --git a/tests/consolewriter/main.cpp b/tests/consolewriter/main.cpp
deleted file mode 100644
index e2e47d15..00000000
--- a/tests/consolewriter/main.cpp
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
-* ConsoleWriter
-*
-* This application is part of the examples on the use of the library QSerialDevice.
-*
-* ConsoleWriter - a test console application to write data to the port.
-*
-* Copyright (C) 2011 Denis Shienkov
-*
-* Contact Denis Shienkov:
-* e-mail: <scapig2@yandex.ru>
-* ICQ: 321789831
-*/
-
-#include <iostream>
-#include <QtCore/QCoreApplication>
-
-#include "serialport.h"
-
-int main(int argc, char *argv[])
-{
- QCoreApplication app(argc, argv);
-
- // 1. First - create an instance of an object.
- SerialPort port;
-
- char inbuf[30];
-
- std::cout << "Please enter serial device name,\n"
- "specific by OS, example\n"
- "- in Windows: COMn\n"
- "- in GNU/Linux: ttyXYZn\n"
- ":";
- std::cin >> inbuf;
-
- // 2. Second - set the device name.
- port.setPort(QString(inbuf));
-
- std::cout << "The port will be opened in write-only mode (QIODevice::WriteOnly).\n"
- "But you can choose to buffered or not (QIODevice::Unbuffered).\n"
- "To understand what is the difference - try to change these modes!\n"
- "Disable buffering [y/N] ?:";
- std::cin >> inbuf;
-
- QIODevice::OpenMode mode = QIODevice::WriteOnly;
- if (inbuf[0] == 'y')
- mode |= QIODevice::Unbuffered;
-
- // 3. Third - open the device.
- if (port.open(mode)) {
-
- // 4. Fourth - now you can configure it (only after successfully opened!).
- if (port.setRate(115200) && port.setDataBits(SerialPort::Data8)
- && port.setParity(SerialPort::NoParity) && port.setStopBits(SerialPort::OneStop)
- && port.setFlowControl(SerialPort::NoFlowControl)) {
-
- // 5. Fifth - you can now read/write device, or further modify its settings, etc.
- while (1) {
-
- int len = 0;
- std::cout << "Please enter len data for write, bytes: ";
- std::cin >> len;
-
- QByteArray data(len, 0);
-
- if (port.write(data)) {
- std::cout << "Writed " << data.size() << " bytes" << std::endl;
- } else {
- std::cout << "Write fail." << std::endl;
- }
- }
- } else {
- std::cout << "Configure " << port.portName().toLocal8Bit().constData() << " fail.";
- port.close();
- }
- } else {
- std::cout << "Open " << port.portName().toLocal8Bit().constData() << " fail.";
- }
-
- return app.exec();
-}
diff --git a/tests/guiapp/guiapp.pro b/tests/guiapp/guiapp.pro
deleted file mode 100644
index fd750b79..00000000
--- a/tests/guiapp/guiapp.pro
+++ /dev/null
@@ -1,33 +0,0 @@
-QT += core gui
-TEMPLATE = app
-
-linux*:DEFINES += HAVE_LIBUDEV
-
-INCLUDEPATH += \
- ../../include \
- ../../src
-
-HEADERS += \
- ../../include/serialport.h \
- ../../include/serialportinfo.h
-
-include(../../src/src.pri)
-
-SOURCES += main.cpp\
- maindialog.cpp \
- optionsdialog.cpp \
- tracedialog.cpp
-HEADERS += maindialog.h \
- optionsdialog.h \
- tracedialog.h
-FORMS += maindialog.ui \
- optionsdialog.ui \
- tracedialog.ui
-
-CONFIG(debug, debug|release) {
- DESTDIR = debug
- TARGET = guiappd
-} else {
- DESTDIR = release
- TARGET = guiapp
-}
diff --git a/tests/guiapp/main.cpp b/tests/guiapp/main.cpp
deleted file mode 100644
index 494c4105..00000000
--- a/tests/guiapp/main.cpp
+++ /dev/null
@@ -1,11 +0,0 @@
-#include <QtGui/QApplication>
-#include "maindialog.h"
-
-int main(int argc, char *argv[])
-{
- QApplication a(argc, argv);
- MainDialog dlg;
- dlg.show();
-
- return a.exec();
-}
diff --git a/tests/guiapp/maindialog.cpp b/tests/guiapp/maindialog.cpp
deleted file mode 100644
index aafcc466..00000000
--- a/tests/guiapp/maindialog.cpp
+++ /dev/null
@@ -1,173 +0,0 @@
-#include <QtCore/QStringList>
-#include <QtCore/QTimer>
-//#include <QtCore/QDebug>
-
-#include "maindialog.h"
-#include "ui_maindialog.h"
-#include "optionsdialog.h"
-#include "tracedialog.h"
-
-#include "serialportinfo.h"
-#include "serialport.h"
-
-
-/* Public methods */
-
-
-MainDialog::MainDialog(QWidget *parent)
- : QDialog(parent)
- , ui(new Ui::MainDialog)
- , m_port(0)
- , m_timer(0)
- , m_rts(false)
- , m_dtr(false)
-{
- ui->setupUi(this);
- fillOpenModeComboBox();
-
- m_port = new SerialPort(this);
- m_timer = new QTimer(this);
- m_timer->setInterval(500);
-
- connect(m_timer, SIGNAL(timeout()), this, SLOT(procUpdateLines()));
-
- procShowPorts();
- int idx = ui->boxName->currentIndex();
- if (idx >= 0)
- procItemPortChanged(idx);
-
- connect(ui->boxName, SIGNAL(currentIndexChanged(int)), this, SLOT(procItemPortChanged(int)));
- connect(ui->controlButton, SIGNAL(clicked()), this, SLOT(procControlButtonClick()));
- connect(ui->optionsButton, SIGNAL(clicked()), this, SLOT(procOptionsButtonClick()));
- connect(ui->ioButton, SIGNAL(clicked()), this, SLOT(procIOButtonClick()));
- connect(ui->rtsButton, SIGNAL(clicked()), this, SLOT(procRtsButtonClick()));
- connect(ui->dtrButton, SIGNAL(clicked()), this, SLOT(procDtrButtonClick()));
-}
-
-MainDialog::~MainDialog()
-{
- if (m_port->isOpen())
- m_port->close();
- delete ui;
-}
-
-
-/* Protected methods */
-
-
-void MainDialog::changeEvent(QEvent *e)
-{
- QDialog::changeEvent(e);
- switch (e->type()) {
- case QEvent::LanguageChange:
- ui->retranslateUi(this);
- break;
- default:
- break;
- }
-}
-
-
-/* Private slots */
-
-
-void MainDialog::procShowPorts()
-{
- ui->boxName->clear();
- foreach(SerialPortInfo inf, SerialPortInfo::availablePorts()) {
- QStringList sl;
- sl << inf.systemLocation() << inf.description() << inf.manufacturer();
- ui->boxName->addItem(inf.portName(), QVariant(sl));
- }
-}
-
-void MainDialog::procItemPortChanged(int idx)
-{
- QStringList sl = ui->boxName->itemData(idx).toStringList();
- ui->lbLocation->setText(sl.at(0));
- ui->lbDescr->setText(sl.at(1));
- ui->lbMfg->setText(sl.at(2));
-}
-
-void MainDialog::procControlButtonClick()
-{
- if (m_port->isOpen()) {
- m_timer->stop();
- m_port->close();
- ui->controlButton->setText(tr("Open"));
- ui->optionsButton->setEnabled(false);
- ui->ioButton->setEnabled(false);
- ui->rtsButton->setEnabled(false);
- ui->dtrButton->setEnabled(false);
- ui->boxName->setEnabled(true);
- ui->modeGroupBox->setEnabled(true);
- } else {
- m_port->setPort(ui->boxName->currentText());
- int idx = ui->modeComboBox->currentIndex();
- bool ok = false;
- idx = ui->modeComboBox->itemData(idx).toInt(&ok);
- if (ok && m_port->open((QIODevice::OpenMode)idx)) {
- ui->controlButton->setText(tr("Close"));
- ui->optionsButton->setEnabled(true);
- ui->ioButton->setEnabled(true);
- ui->rtsButton->setEnabled(true);
- ui->dtrButton->setEnabled(true);
- ui->boxName->setEnabled(false);
- ui->modeGroupBox->setEnabled(false);
- m_timer->start();
- }
- }
-}
-
-void MainDialog::procOptionsButtonClick()
-{
- OptionsDialog dlg(m_port);
- dlg.exec();
-}
-
-void MainDialog::procIOButtonClick()
-{
- TraceDialog dlg(m_port);
- dlg.exec();
-}
-
-void MainDialog::procRtsButtonClick()
-{
- m_port->setRts(!m_rts);
-}
-
-void MainDialog::procDtrButtonClick()
-{
- m_port->setDtr(!m_dtr);
-}
-
-void MainDialog::procUpdateLines()
-{
- SerialPort::Lines lines = m_port->lines();
- m_rts = SerialPort::Rts & lines;
- m_dtr = SerialPort::Dtr & lines;
-
- ui->leLabel->setEnabled(SerialPort::Le & lines);
- ui->dtrLabel->setEnabled(m_dtr);
- ui->rtsLabel->setEnabled(m_rts);
- //ui->stLabel->setEnabled(SerialPort::St & lines);
- //ui->srLabel->setEnabled(SerialPort::Sr & lines);
- ui->ctsLabel->setEnabled(SerialPort::Cts & lines);
- ui->dcdLabel->setEnabled(SerialPort::Dcd & lines);
- ui->ringLabel->setEnabled(SerialPort::Ri & lines);
- ui->dsrLabel->setEnabled(SerialPort::Dsr & lines);
-
- ui->rtsButton->setText((m_rts) ? tr("Clear RTS") : tr("Set RTS"));
- ui->dtrButton->setText((m_dtr) ? tr("Clear DTR") : tr("Set DTR"));
-}
-
-
-/* Private methods */
-
-
-void MainDialog::fillOpenModeComboBox()
-{
- ui->modeComboBox->addItem(QString(tr("Read and write")), QVariant(QIODevice::ReadWrite));
- ui->modeComboBox->addItem(QString(tr("Read only")), QVariant(QIODevice::ReadOnly));
- ui->modeComboBox->addItem(QString(tr("Write only")), QVariant(QIODevice::WriteOnly));
-}
diff --git a/tests/guiapp/maindialog.h b/tests/guiapp/maindialog.h
deleted file mode 100644
index 889c8ce3..00000000
--- a/tests/guiapp/maindialog.h
+++ /dev/null
@@ -1,48 +0,0 @@
-#ifndef MAINDIALOG_H
-#define MAINDIALOG_H
-
-#include <QtGui/QDialog>
-
-namespace Ui {
-class MainDialog;
-}
-
-class SerialPort;
-class QTimer;
-
-class MainDialog : public QDialog
-{
- Q_OBJECT
-public:
- explicit MainDialog(QWidget *parent = 0);
- ~MainDialog();
-
-protected:
- void changeEvent(QEvent *e);
-
-private slots:
- void procShowPorts();
- void procItemPortChanged(int idx);
-
- void procControlButtonClick();
- void procOptionsButtonClick();
- void procIOButtonClick();
- void procRtsButtonClick();
- void procDtrButtonClick();
-
- void procUpdateLines();
-
-private:
- Ui::MainDialog *ui;
-
- SerialPort *m_port;
- QTimer *m_timer;
-
- bool m_rts;
- bool m_dtr;
-
- void fillOpenModeComboBox();
-
-};
-
-#endif // MAINDIALOG_H
diff --git a/tests/guiapp/maindialog.ui b/tests/guiapp/maindialog.ui
deleted file mode 100644
index ed54e132..00000000
--- a/tests/guiapp/maindialog.ui
+++ /dev/null
@@ -1,275 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<ui version="4.0">
- <class>MainDialog</class>
- <widget class="QDialog" name="MainDialog">
- <property name="geometry">
- <rect>
- <x>0</x>
- <y>0</y>
- <width>411</width>
- <height>240</height>
- </rect>
- </property>
- <property name="windowTitle">
- <string>Simple GUI application for demonstrating the use of QSerialDevice.</string>
- </property>
- <layout class="QGridLayout" name="gridLayout_2">
- <item row="0" column="0">
- <widget class="QGroupBox" name="modeGroupBox">
- <property name="title">
- <string>Open mode:</string>
- </property>
- <layout class="QVBoxLayout" name="verticalLayout">
- <item>
- <widget class="QComboBox" name="modeComboBox"/>
- </item>
- </layout>
- </widget>
- </item>
- <item row="0" column="1" rowspan="5">
- <widget class="QGroupBox" name="infoGroupBox">
- <property name="title">
- <string>Available ports:</string>
- </property>
- <layout class="QGridLayout" name="gridLayout">
- <item row="0" column="0">
- <widget class="QLabel" name="label_1">
- <property name="text">
- <string>Name:</string>
- </property>
- </widget>
- </item>
- <item row="0" column="1">
- <widget class="QComboBox" name="boxName"/>
- </item>
- <item row="1" column="0">
- <widget class="QLabel" name="label_2">
- <property name="text">
- <string>Location:</string>
- </property>
- </widget>
- </item>
- <item row="1" column="1">
- <widget class="QLabel" name="lbLocation">
- <property name="text">
- <string>***</string>
- </property>
- </widget>
- </item>
- <item row="2" column="0">
- <widget class="QLabel" name="label_3">
- <property name="text">
- <string>Description:</string>
- </property>
- </widget>
- </item>
- <item row="2" column="1">
- <widget class="QLabel" name="lbDescr">
- <property name="text">
- <string>***</string>
- </property>
- </widget>
- </item>
- <item row="3" column="0">
- <widget class="QLabel" name="label_4">
- <property name="text">
- <string>Manufacturer:</string>
- </property>
- </widget>
- </item>
- <item row="3" column="1">
- <widget class="QLabel" name="lbMfg">
- <property name="text">
- <string>***</string>
- </property>
- </widget>
- </item>
- <item row="4" column="0">
- <widget class="QLabel" name="label_5">
- <property name="text">
- <string>Busy:</string>
- </property>
- </widget>
- </item>
- <item row="4" column="1">
- <widget class="QLabel" name="lbBusy">
- <property name="text">
- <string>***</string>
- </property>
- </widget>
- </item>
- </layout>
- </widget>
- </item>
- <item row="1" column="0">
- <widget class="QPushButton" name="controlButton">
- <property name="text">
- <string>Open</string>
- </property>
- </widget>
- </item>
- <item row="2" column="0">
- <widget class="QPushButton" name="optionsButton">
- <property name="enabled">
- <bool>false</bool>
- </property>
- <property name="text">
- <string>Options</string>
- </property>
- </widget>
- </item>
- <item row="3" column="0">
- <widget class="QPushButton" name="ioButton">
- <property name="enabled">
- <bool>false</bool>
- </property>
- <property name="text">
- <string>Input/Output</string>
- </property>
- </widget>
- </item>
- <item row="4" column="0" rowspan="2">
- <widget class="QPushButton" name="rtsButton">
- <property name="enabled">
- <bool>false</bool>
- </property>
- <property name="text">
- <string>Set RTS</string>
- </property>
- </widget>
- </item>
- <item row="5" column="1">
- <widget class="QLabel" name="lineLabel">
- <property name="text">
- <string>Serial lines states</string>
- </property>
- <property name="alignment">
- <set>Qt::AlignCenter</set>
- </property>
- </widget>
- </item>
- <item row="6" column="0">
- <widget class="QPushButton" name="dtrButton">
- <property name="enabled">
- <bool>false</bool>
- </property>
- <property name="text">
- <string>Set DTR</string>
- </property>
- </widget>
- </item>
- <item row="6" column="1">
- <layout class="QHBoxLayout" name="horizontalLayout">
- <item>
- <widget class="Line" name="line1">
- <property name="orientation">
- <enum>Qt::Vertical</enum>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QLabel" name="dsrLabel">
- <property name="text">
- <string>DSR</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="Line" name="line2">
- <property name="orientation">
- <enum>Qt::Vertical</enum>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QLabel" name="dtrLabel">
- <property name="text">
- <string>DTR</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="Line" name="line">
- <property name="orientation">
- <enum>Qt::Vertical</enum>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QLabel" name="ctsLabel">
- <property name="text">
- <string>CTS</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="Line" name="line_2">
- <property name="orientation">
- <enum>Qt::Vertical</enum>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QLabel" name="rtsLabel">
- <property name="text">
- <string>RTS</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="Line" name="line_3">
- <property name="orientation">
- <enum>Qt::Vertical</enum>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QLabel" name="dcdLabel">
- <property name="text">
- <string>DCD</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="Line" name="line3">
- <property name="orientation">
- <enum>Qt::Vertical</enum>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QLabel" name="ringLabel">
- <property name="text">
- <string>RING</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="Line" name="line_4">
- <property name="orientation">
- <enum>Qt::Vertical</enum>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QLabel" name="leLabel">
- <property name="text">
- <string>LE</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="Line" name="line_5">
- <property name="orientation">
- <enum>Qt::Vertical</enum>
- </property>
- </widget>
- </item>
- </layout>
- </item>
- </layout>
- </widget>
- <layoutdefault spacing="6" margin="11"/>
- <resources/>
- <connections/>
-</ui>
diff --git a/tests/guiapp/optionsdialog.cpp b/tests/guiapp/optionsdialog.cpp
deleted file mode 100644
index 0af227e7..00000000
--- a/tests/guiapp/optionsdialog.cpp
+++ /dev/null
@@ -1,249 +0,0 @@
-#include <QtGui/QMessageBox>
-
-#include "optionsdialog.h"
-#include "ui_optionsdialog.h"
-
-#include "serialport.h"
-
-
-/* Public methods */
-
-
-OptionsDialog::OptionsDialog(SerialPort *port, QWidget *parent)
- : QDialog(parent)
- , ui(new Ui::OptionsDialog)
- , m_port(port)
- , m_rate(0), m_data(0), m_parity(0), m_stop(0), m_flow(0), m_policy(0)
-{
- ui->setupUi(this);
- procFillingOptions();
-
- connect(ui->applyButton, SIGNAL(clicked()), this, SLOT(procApplyButtonClick()));
-}
-
-OptionsDialog::~OptionsDialog()
-{
- delete ui;
-}
-
-
-/* Protected methods. */
-
-
-void OptionsDialog::showEvent(QShowEvent *e)
-{
- Q_UNUSED(e)
- detectOptions();
-}
-
-
-/* Private slots */
-
-
-void OptionsDialog::procFillingOptions()
-{
- ui->baudBox->addItem(tr("9600"), SerialPort::Rate9600);
- ui->baudBox->addItem(tr("19200"), SerialPort::Rate19200);
- ui->baudBox->addItem(tr("38400"), SerialPort::Rate38400);
- ui->baudBox->addItem(tr("57600"), SerialPort::Rate57600);
- ui->baudBox->addItem(tr("115200"), SerialPort::Rate115200);
- ui->baudBox->addItem(tr("Unknown"), SerialPort::UnknownRate);
-
- ui->dataBox->addItem(tr("5"), SerialPort::Data5);
- ui->dataBox->addItem(tr("6"), SerialPort::Data6);
- ui->dataBox->addItem(tr("7"), SerialPort::Data7);
- ui->dataBox->addItem(tr("8"), SerialPort::Data8);
- ui->dataBox->addItem(tr("Unknown"), SerialPort::UnknownDataBits);
-
- ui->parityBox->addItem(tr("None"), SerialPort::NoParity);
- ui->parityBox->addItem(tr("Even"), SerialPort::EvenParity);
- ui->parityBox->addItem(tr("Odd"), SerialPort::OddParity);
- ui->parityBox->addItem(tr("Mark"), SerialPort::MarkParity);
- ui->parityBox->addItem(tr("Space"), SerialPort::SpaceParity);
- ui->parityBox->addItem(tr("Unknown"), SerialPort::UnknownParity);
-
- ui->stopBox->addItem(tr("1"), SerialPort::OneStop);
- ui->stopBox->addItem(tr("1.5"), SerialPort::OneAndHalfStop);
- ui->stopBox->addItem(tr("2"), SerialPort::TwoStop);
- ui->stopBox->addItem(tr("Unknown"), SerialPort::UnknownStopBits);
-
- ui->flowBox->addItem(tr("Off"), SerialPort::NoFlowControl);
- ui->flowBox->addItem(tr("Hardware"), SerialPort::HardwareControl);
- ui->flowBox->addItem(tr("Software"), SerialPort::SoftwareControl);
- ui->flowBox->addItem(tr("Unknown"), SerialPort::UnknownFlowControl);
-
- ui->policyBox->addItem(tr("Skip"), SerialPort::SkipPolicy);
- ui->policyBox->addItem(tr("PassZero"), SerialPort::PassZeroPolicy);
- ui->policyBox->addItem(tr("Ignore"), SerialPort::IgnorePolicy);
- ui->policyBox->addItem(tr("StopReceiving"), SerialPort::StopReceivingPolicy);
- ui->policyBox->addItem(tr("Unknown"), SerialPort::UnknownPolicy);
-}
-
-void OptionsDialog::procApplyButtonClick()
-{
- bool ok;
- bool hasChanged = false;
-
- int val = ui->baudBox->itemData(ui->baudBox->currentIndex()).toInt(&ok);
- if (val != m_rate) {
- m_port->setRate(SerialPort::Rate(val));
- hasChanged = true;
- }
-
- val = ui->dataBox->itemData(ui->dataBox->currentIndex()).toInt(&ok);
- if (val != m_data) {
- m_port->setDataBits(SerialPort::DataBits(val));
- hasChanged = true;
- }
-
- val = ui->parityBox->itemData(ui->parityBox->currentIndex()).toInt(&ok);
- if (val != m_parity) {
- m_port->setParity(SerialPort::Parity(val));
- hasChanged = true;
- }
-
- val = ui->stopBox->itemData(ui->stopBox->currentIndex()).toInt(&ok);
- if (val != m_stop) {
- m_port->setStopBits(SerialPort::StopBits(val));
- hasChanged = true;
- }
-
- val = ui->flowBox->itemData(ui->flowBox->currentIndex()).toInt(&ok);
- if (val != m_flow) {
- m_port->setFlowControl(SerialPort::FlowControl(val));
- hasChanged = true;
- }
-
- val = ui->policyBox->itemData(ui->policyBox->currentIndex()).toInt(&ok);
- if (val != m_policy) {
- m_port->setDataErrorPolicy(SerialPort::DataErrorPolicy(val));
- hasChanged = true;
- }
-
- if (hasChanged)
- detectOptions();
-}
-
-
-/* Private methods */
-
-
-void OptionsDialog::detectOptions()
-{
- m_rate = m_port->rate();
- switch (m_rate) {
- case SerialPort::Rate9600:
- case SerialPort::Rate19200:
- case SerialPort::Rate38400:
- case SerialPort::Rate57600:
- case SerialPort::Rate115200:
- break;
- default: m_rate = SerialPort::UnknownRate;
- }
- int count = ui->baudBox->count();
- for (int i = 0; i < count; ++i) {
- bool ok;
- if (ui->baudBox->itemData(i).toInt(&ok) == m_rate) {
- ui->baudBox->setCurrentIndex(i);
- break;
- }
- }
-
- m_data = m_port->dataBits();
- switch (m_data) {
- case SerialPort::Data5:
- case SerialPort::Data6:
- case SerialPort::Data7:
- case SerialPort::Data8:
- break;
- default: m_data = SerialPort::UnknownDataBits;
- }
- count = ui->dataBox->count();
- for (int i = 0; i < count; ++i) {
- bool ok;
- if (ui->dataBox->itemData(i).toInt(&ok) == m_data) {
- ui->dataBox->setCurrentIndex(i);
- break;
- }
- }
-
- m_parity = m_port->parity();
- switch (m_parity) {
- case SerialPort::NoParity:
- case SerialPort::EvenParity:
- case SerialPort::OddParity:
- case SerialPort::MarkParity:
- case SerialPort::SpaceParity:
- break;
- default: m_parity = SerialPort::UnknownParity;
- }
- count = ui->parityBox->count();
- for (int i = 0; i < count; ++i) {
- bool ok;
- if (ui->parityBox->itemData(i).toInt(&ok) == m_parity) {
- ui->parityBox->setCurrentIndex(i);
- break;
- }
- }
-
- m_stop = m_port->stopBits();
- switch (m_stop) {
- case SerialPort::OneStop:
- case SerialPort::OneAndHalfStop:
- case SerialPort::TwoStop:
- break;
- default: m_stop = SerialPort::UnknownStopBits;
- }
- count = ui->stopBox->count();
- for (int i = 0; i < count; ++i) {
- bool ok;
- if (ui->stopBox->itemData(i).toInt(&ok) == m_stop) {
- ui->stopBox->setCurrentIndex(i);
- break;
- }
- }
-
- m_flow = m_port->flowControl();
- switch (m_flow) {
- case SerialPort::NoFlowControl:
- case SerialPort::HardwareControl:
- case SerialPort::SoftwareControl:
- break;
- default: m_flow = SerialPort::UnknownFlowControl;
- }
- count = ui->flowBox->count();
- for (int i = 0; i < count; ++i) {
- bool ok;
- if (ui->flowBox->itemData(i).toInt(&ok) == m_flow) {
- ui->flowBox->setCurrentIndex(i);
- break;
- }
- }
-
- m_policy = m_port->dataErrorPolicy();
- switch (m_policy) {
- case SerialPort::PassZeroPolicy:
- case SerialPort::IgnorePolicy:
- case SerialPort::StopReceivingPolicy:
- break;
- default: m_flow = SerialPort::UnknownPolicy;
- }
- count = ui->policyBox->count();
- for (int i = 0; i < count; ++i) {
- bool ok;
- if (ui->policyBox->itemData(i).toInt(&ok) == m_policy) {
- ui->policyBox->setCurrentIndex(i);
- break;
- }
- }
-}
-
-
-
-
-
-
-
-
-
-
diff --git a/tests/guiapp/optionsdialog.h b/tests/guiapp/optionsdialog.h
deleted file mode 100644
index c4ac69de..00000000
--- a/tests/guiapp/optionsdialog.h
+++ /dev/null
@@ -1,39 +0,0 @@
-#ifndef OPTIONSDIALOG_H
-#define OPTIONSDIALOG_H
-
-#include <QtGui/QDialog>
-
-namespace Ui {
-class OptionsDialog;
-}
-
-class SerialPort;
-
-class OptionsDialog : public QDialog
-{
- Q_OBJECT
-public:
- explicit OptionsDialog(SerialPort *port, QWidget *parent = 0);
- ~OptionsDialog();
-
-protected:
- void showEvent(QShowEvent *e);
-
-private slots:
- void procFillingOptions();
- void procApplyButtonClick();
-
-private:
- Ui::OptionsDialog *ui;
- SerialPort *m_port;
- int m_rate;
- int m_data;
- int m_parity;
- int m_stop;
- int m_flow;
- int m_policy;
-
- void detectOptions();
-};
-
-#endif // OPTIONSDIALOG_H
diff --git a/tests/guiapp/optionsdialog.ui b/tests/guiapp/optionsdialog.ui
deleted file mode 100644
index 6f5b065c..00000000
--- a/tests/guiapp/optionsdialog.ui
+++ /dev/null
@@ -1,91 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<ui version="4.0">
- <class>OptionsDialog</class>
- <widget class="QDialog" name="OptionsDialog">
- <property name="geometry">
- <rect>
- <x>0</x>
- <y>0</y>
- <width>161</width>
- <height>197</height>
- </rect>
- </property>
- <property name="windowTitle">
- <string>Options</string>
- </property>
- <layout class="QGridLayout" name="gridLayout">
- <item row="0" column="0">
- <widget class="QLabel" name="Label1">
- <property name="text">
- <string>Baud rate:</string>
- </property>
- </widget>
- </item>
- <item row="0" column="1">
- <widget class="QComboBox" name="baudBox"/>
- </item>
- <item row="1" column="0">
- <widget class="QLabel" name="Label2">
- <property name="text">
- <string>Data bits:</string>
- </property>
- </widget>
- </item>
- <item row="1" column="1">
- <widget class="QComboBox" name="dataBox"/>
- </item>
- <item row="2" column="0">
- <widget class="QLabel" name="Label3">
- <property name="text">
- <string>Parity:</string>
- </property>
- </widget>
- </item>
- <item row="2" column="1">
- <widget class="QComboBox" name="parityBox"/>
- </item>
- <item row="3" column="0">
- <widget class="QLabel" name="Label4">
- <property name="text">
- <string>Stop bits:</string>
- </property>
- </widget>
- </item>
- <item row="3" column="1">
- <widget class="QComboBox" name="stopBox"/>
- </item>
- <item row="4" column="0">
- <widget class="QLabel" name="Label5">
- <property name="text">
- <string>Flow control:</string>
- </property>
- </widget>
- </item>
- <item row="4" column="1">
- <widget class="QComboBox" name="flowBox"/>
- </item>
- <item row="5" column="0">
- <widget class="QLabel" name="Label6">
- <property name="text">
- <string>Policy:</string>
- </property>
- </widget>
- </item>
- <item row="5" column="1">
- <widget class="QComboBox" name="policyBox"/>
- </item>
- <item row="6" column="1">
- <widget class="QPushButton" name="applyButton">
- <property name="enabled">
- <bool>true</bool>
- </property>
- <property name="text">
- <string>Apply</string>
- </property>
- </widget>
- </item>
- </layout>
- </widget>
- <resources/>
- <connections/>
-</ui>
diff --git a/tests/guiapp/tracedialog.cpp b/tests/guiapp/tracedialog.cpp
deleted file mode 100644
index f8d6d3ea..00000000
--- a/tests/guiapp/tracedialog.cpp
+++ /dev/null
@@ -1,81 +0,0 @@
-#include <QtGui/QScrollBar>
-
-#include "tracedialog.h"
-#include "ui_tracedialog.h"
-
-#include "serialport.h"
-
-
-/* Public methods */
-
-
-TraceDialog::TraceDialog(SerialPort *port, QWidget *parent)
- : QDialog(parent)
- , ui(new Ui::TraceDialog)
- , m_port(port)
-{
- ui->setupUi(this);
- ui->textEdit->document()->setMaximumBlockCount(100);
-
- connect(ui->sendButton, SIGNAL(clicked()), this, SLOT(procSendButtonClick()));
- connect(ui->clearButton, SIGNAL(clicked()), this, SLOT(procClearButtonClick()));
-
- connect(m_port, SIGNAL(readyRead()), this, SLOT(procReadyRead()));
-}
-
-TraceDialog::~TraceDialog()
-{
- delete ui;
-}
-
-
-/* Protected methods */
-
-
-void TraceDialog::changeEvent(QEvent *e)
-{
- QDialog::changeEvent(e);
- switch (e->type()) {
- case QEvent::LanguageChange:
- ui->retranslateUi(this);
- break;
- default:
- break;
- }
-}
-
-
-/* Private slots */
-
-
-void TraceDialog::printTrace(const QByteArray &data, bool directionRx)
-{
- ui->textEdit->setTextColor((directionRx) ? Qt::darkBlue : Qt::darkGreen);
- ui->textEdit->insertPlainText(QString(data));
-
- QScrollBar *bar = ui->textEdit->verticalScrollBar();
- bar->setValue(bar->maximum());
-}
-
-void TraceDialog::procSendButtonClick()
-{
- QByteArray data;
- data.append(ui->lineEdit->text());
- if (data.size() > 0) {
- m_port->write(data);
- printTrace(data, false);
- ui->lbError->setText(QString::number(m_port->error()));
- }
-}
-
-void TraceDialog::procClearButtonClick()
-{
- ui->textEdit->clear();
-}
-
-void TraceDialog::procReadyRead()
-{
- QByteArray data = m_port->readAll();
- printTrace(data, true);
- ui->lbError->setText(QString::number(m_port->error()));
-}
diff --git a/tests/guiapp/tracedialog.h b/tests/guiapp/tracedialog.h
deleted file mode 100644
index 8d5c58ad..00000000
--- a/tests/guiapp/tracedialog.h
+++ /dev/null
@@ -1,34 +0,0 @@
-#ifndef TRACEDIALOG_H
-#define TRACEDIALOG_H
-
-#include <QtGui/QDialog>
-
-namespace Ui {
-class TraceDialog;
-}
-
-class SerialPort;
-
-class TraceDialog : public QDialog
-{
- Q_OBJECT
-public:
- explicit TraceDialog(SerialPort *port, QWidget *parent = 0);
- ~TraceDialog();
-
-protected:
- void changeEvent(QEvent *e);
-
-private slots:
- void printTrace(const QByteArray &data, bool directionRx);
- void procSendButtonClick();
- void procClearButtonClick();
- void procReadyRead();
-
-private:
- Ui::TraceDialog *ui;
-
- SerialPort *m_port;
-};
-
-#endif // TRACEDIALOG_H
diff --git a/tests/guiapp/tracedialog.ui b/tests/guiapp/tracedialog.ui
deleted file mode 100644
index eef1a989..00000000
--- a/tests/guiapp/tracedialog.ui
+++ /dev/null
@@ -1,70 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<ui version="4.0">
- <class>TraceDialog</class>
- <widget class="QDialog" name="TraceDialog">
- <property name="geometry">
- <rect>
- <x>0</x>
- <y>0</y>
- <width>322</width>
- <height>276</height>
- </rect>
- </property>
- <property name="windowTitle">
- <string>Trace</string>
- </property>
- <layout class="QGridLayout" name="gridLayout">
- <item row="0" column="0" colspan="2">
- <widget class="QTextEdit" name="textEdit">
- <property name="readOnly">
- <bool>true</bool>
- </property>
- </widget>
- </item>
- <item row="1" column="0">
- <widget class="QPushButton" name="sendButton">
- <property name="text">
- <string>Send</string>
- </property>
- </widget>
- </item>
- <item row="1" column="1">
- <widget class="QLineEdit" name="lineEdit"/>
- </item>
- <item row="2" column="0">
- <widget class="QPushButton" name="clearButton">
- <property name="text">
- <string>Clear trace</string>
- </property>
- </widget>
- </item>
- <item row="2" column="1">
- <widget class="QLabel" name="label_1">
- <property name="text">
- <string>(Here enter a line in text a format for sending,
- for example: I will be transferred)</string>
- </property>
- <property name="alignment">
- <set>Qt::AlignCenter</set>
- </property>
- </widget>
- </item>
- <item row="3" column="0">
- <widget class="QLabel" name="label_2">
- <property name="text">
- <string>Last error:</string>
- </property>
- </widget>
- </item>
- <item row="3" column="1">
- <widget class="QLabel" name="lbError">
- <property name="text">
- <string>***</string>
- </property>
- </widget>
- </item>
- </layout>
- </widget>
- <resources/>
- <connections/>
-</ui>
diff --git a/tests/guidevtest/guidevtest.pro b/tests/guidevtest/guidevtest.pro
deleted file mode 100644
index b07e6f90..00000000
--- a/tests/guidevtest/guidevtest.pro
+++ /dev/null
@@ -1,45 +0,0 @@
-#-------------------------------------------------
-#
-# Project created by QtCreator 2011-10-15T16:26:56
-#
-#-------------------------------------------------
-
-QT += core gui
-
-TARGET = guidevtest
-TEMPLATE = app
-
-INCLUDEPATH += \
- ../../include \
- ../../src
-
-HEADERS += \
- ../../include/serialport.h \
- ../../include/serialportinfo.h
-
-include(../../src/src.pri)
-
-SOURCES += \
- main.cpp \
- maindialog.cpp \
- unittestinfo.cpp \
- unittestsignals.cpp \
- unittestwaitforx.cpp \
- unittestio.cpp
-
-HEADERS += \
- maindialog.h \
- unittests.h
-
-FORMS += \
- maindialog.ui
-
-
-
-
-
-
-
-
-
-
diff --git a/tests/guidevtest/main.cpp b/tests/guidevtest/main.cpp
deleted file mode 100644
index 44b9ad15..00000000
--- a/tests/guidevtest/main.cpp
+++ /dev/null
@@ -1,17 +0,0 @@
-#include <QtGui/QApplication>
-
-#include "maindialog.h"
-
-int main(int argc, char *argv[])
-{
- QApplication a(argc, argv);
-
- QCoreApplication::setOrganizationName("Kuzulis");
- QCoreApplication::setOrganizationDomain("kuzulis.com");
- QCoreApplication::setApplicationName("QSerialDevice unit test");
-
- MainDialog w;
- w.show();
-
- return a.exec();
-}
diff --git a/tests/guidevtest/maindialog.cpp b/tests/guidevtest/maindialog.cpp
deleted file mode 100644
index 1e3b7679..00000000
--- a/tests/guidevtest/maindialog.cpp
+++ /dev/null
@@ -1,381 +0,0 @@
-#include "maindialog.h"
-#include "ui_maindialog.h"
-
-#include <QtGui/QTextEdit>
-#include <QtCore/QSettings>
-#include <QtCore/QTimer>
-#include <QtCore/QFile>
-
-#include "unittests.h"
-#include "serialportinfo.h"
-
-
-// Logger
-
-/* Public methods */
-
-Logger::Logger(QObject *parent)
- : QObject(parent), m_file(new QFile(this))
-{
-}
-
-void Logger::setFileName(const QString &name)
-{
- m_file->setFileName(name);
-}
-
-void Logger::addContent(const QString &content, bool clearAll)
-{
- QIODevice::OpenMode mode =
- QIODevice::WriteOnly | QIODevice::Text;
- mode |= (clearAll) ?
- QIODevice::Truncate : QIODevice::Append;
-
- if (m_file->open(mode)) {
- m_file->write(content.toLocal8Bit());
- m_file->close();
- }
-}
-
-
-// UnitTestBase
-
-/* Public methods */
-
-UnitTestBase::UnitTestBase(UnitID id, Logger *logger, QObject *parent)
- : QObject(parent), m_id(id), m_logger(logger)
- , m_srcPort(0), m_dstPort(0)
-{
- Q_ASSERT(logger);
- m_enableParam = "TestID%1/enable";
- m_enableParam = m_enableParam.arg(id);
-}
-
-void UnitTestBase::setPair(const QString &src, const QString &dst)
-{
- m_srcPortName = src;
- m_dstPortName = dst;
-}
-
-void UnitTestBase::setEnable(bool enable)
-{
- QSettings settings;
- settings.setValue(m_enableParam, enable);
-}
-
-bool UnitTestBase::isEnabled() const
-{
- QSettings settings;
- return settings.value(m_enableParam).toBool();
-}
-
-int UnitTestBase::id() const
-{
- return m_id;
-}
-
-QString UnitTestBase::name() const
-{
- return m_name;
-}
-
-QString UnitTestBase::description() const
-{
- return m_description;
-}
-
-
-// UnitTestFactory
-
-/* Public methods */
-
-UnitTestBase *UnitTestFactory::create(UnitTestBase::UnitID id, Logger *logger)
-{
- switch (id) {
- case UnitTestBase::InfoUnitId:
- return new UnitTestInfo(logger);
- case UnitTestBase::SignalsUnitId:
- return new UnitTestSignals(logger);
- case UnitTestBase::WaitForXUnitId:
- return new UnitTestWaitForX(logger);
- case UnitTestBase::IOUnitId:
- return new UnitTestIO(logger);
- default:;
- }
-
- return 0;
-}
-
-
-// TestsViewModel
-
-/* Public methods */
-
-TestsViewModel::TestsViewModel(const QList<UnitTestBase *> &list, QObject *parent)
- : QAbstractListModel(parent)
-{
- m_testsList = list;
-}
-
-int TestsViewModel::rowCount(const QModelIndex &parent) const
-{
- Q_UNUSED(parent);
- return m_testsList.count();
-}
-
-QVariant TestsViewModel::data(const QModelIndex &index, int role) const
-{
- if (index.isValid()
- && (index.row() < m_testsList.count())) {
- UnitTestBase *item = m_testsList.at(index.row());
- if (role == Qt::DisplayRole)
- return item->name();
- if (role == Qt::CheckStateRole)
- return item->isEnabled() ? Qt::Checked : Qt::Unchecked;
- }
- return QVariant();
-}
-
-QVariant TestsViewModel::headerData(int section, Qt::Orientation orientation, int role) const
-{
- Q_UNUSED(section);
- Q_UNUSED(orientation);
- Q_UNUSED(role);
- return QVariant();
-}
-
-Qt::ItemFlags TestsViewModel::flags(const QModelIndex &index) const
-{
- Qt::ItemFlags flag = Qt::ItemIsEnabled;
- if (index.isValid())
- flag |= Qt::ItemIsUserCheckable | Qt::ItemIsSelectable;
- return flag;
-}
-
-bool TestsViewModel::setData(const QModelIndex &index, const QVariant &value, int role)
-{
- if (index.isValid()) {
- UnitTestBase *item = m_testsList.at(index.row());
- if (role == Qt::CheckStateRole) {
- bool enable = value.toBool();
- if (item->isEnabled() != enable) {
- item->setEnable(enable);
- emit dataChanged(index, index);
- return true;
- }
- }
- }
- return false;
-}
-
-QModelIndex TestsViewModel::index(int row, int column, const QModelIndex &parent) const
-{
- Q_UNUSED(parent);
- if (row < m_testsList.count())
- return createIndex(row, column, m_testsList.at(row));
- return QModelIndex();
-}
-
-
-// DescriptionDialog
-
-/* Public methods */
-
-DescriptionDialog::DescriptionDialog(const QString &content, QWidget *parent)
- : QDialog(parent)
-{
- QTextEdit *widget = new QTextEdit;
- widget->setReadOnly(true);
- widget->setText(content);
- QHBoxLayout *layout = new QHBoxLayout;
- layout->addWidget(widget);
- setLayout(layout);
-}
-
-
-// MainDialog
-
-/* Public methods */
-
-MainDialog::MainDialog(QWidget *parent)
- : QDialog(parent), ui(new Ui::MainDialog)
- , m_enabledTestsCount(0), m_it(0)
-{
- ui->setupUi(this);
-
- m_logger = new Logger(this);
-
- fillPairs();
- showSettings();
- createAvailableTests();
-
- m_model = new TestsViewModel(m_testsList, this);
- ui->listView->setModel(m_model);
-
- connect(ui->logLineEdit, SIGNAL(textChanged(QString)),
- this, SLOT(procLogChanged(QString)));
- connect(ui->clearLogCheckBox, SIGNAL(clicked(bool)),
- this, SLOT(procClearLogOnStartChanged(bool)));
- connect(ui->breakAllCheckBox, SIGNAL(clicked(bool)),
- this, SLOT(procBreakAllOnErrorChanged(bool)));
-
- connect(ui->startButton, SIGNAL(clicked()),
- this, SLOT(procStartButtonClick()));
-
- connect(ui->listView, SIGNAL(doubleClicked(QModelIndex)),
- this, SLOT(procItemDoubleClick(QModelIndex)));
-}
-
-MainDialog::~MainDialog()
-{
- delete ui;
-}
-
-/* Private slots */
-
-void MainDialog::procLogChanged(const QString &log)
-{
- QSettings settings;
- settings.setValue(logFileSettingsKey, log);
-}
-
-void MainDialog::procClearLogOnStartChanged(bool enable)
-{
- QSettings settings;
- settings.setValue(clearLogOnStartSettingsKey, enable);
-}
-
-void MainDialog::procBreakAllOnErrorChanged(bool enable)
-{
- QSettings settings;
- settings.setValue(breakOnErrorSettingsKey, enable);
-}
-
-void MainDialog::procStartButtonClick()
-{
- // Check pair
- if (ui->srcComboBox->currentText() == ui->dstComboBox->currentText())
- return;
-
- // Get enabled tests num
- m_enabledTestsCount = 0;
- foreach (UnitTestBase *test, m_testsList) {
- if (test->isEnabled())
- ++m_enabledTestsCount;
- }
- if (!m_enabledTestsCount)
- return;
-
- ui->progressBar->setValue(0);
- ui->progressBar->setMaximum(m_enabledTestsCount);
-
- m_logger->setFileName(qApp->applicationDirPath()
- + "/"
- + ui->logLineEdit->text());
-
- // Start run
- QString header(tr("\n*** S T A R T E D ***\n"));
- m_logger->addContent(header, ui->clearLogCheckBox->isChecked());
- procTestStarted();
- enableUi(false);
-}
-
-void MainDialog::procTestStarted()
-{
- UnitTestBase *test = m_testsList.at(m_it++);
- if (test->isEnabled()) {
- test->setPair(ui->srcComboBox->currentText(),
- ui->dstComboBox->currentText());
- QTimer::singleShot(1000, test, SLOT(start()));
- }
- else
- procTestStarted();
-}
-
-void MainDialog::procTestFinished()
-{
- ui->progressBar->setValue(ui->progressBar->maximum() - (--m_enabledTestsCount));
- if (m_enabledTestsCount == 0) {
- enableUi(true);
- m_it = 0;
-
- QString trailer(tr("\n*** S T O P P E D ***\n"));
- m_logger->addContent(trailer);
- return;
- }
- else
- procTestStarted();
-}
-
-void MainDialog::procTestError()
-{
- if (ui->breakAllCheckBox->isChecked()) {
- m_enabledTestsCount = 0;
- m_it = 0;
- enableUi(true);
- QString trailer(tr("\n*** B R E A K ***\n"));
- m_logger->addContent(trailer);
- } else {
- procTestFinished();
- }
-}
-
-void MainDialog::procItemDoubleClick(const QModelIndex &index)
-{
- QString title(tr("About: <%1>"));
- title = title.arg(index.data().toString());
- DescriptionDialog w(static_cast<UnitTestBase *>(index.internalPointer())->description());
- w.setWindowTitle(title);
- w.exec();
-}
-
-/* Private methods */
-
-const QString MainDialog::logFileSettingsKey = "MainDialog/logFileName";
-const QString MainDialog::breakOnErrorSettingsKey = "MainDialog/breakOnError";
-const QString MainDialog::clearLogOnStartSettingsKey = "MainDialog/clearLogOnStart";
-
-void MainDialog::showSettings()
-{
- QSettings settings;
- ui->logLineEdit->setText(settings.value(logFileSettingsKey).toString());
- ui->clearLogCheckBox->setChecked(settings.value(clearLogOnStartSettingsKey).toBool());
- ui->breakAllCheckBox->setChecked(settings.value(breakOnErrorSettingsKey).toBool());
-}
-
-// Called only in constructor!
-void MainDialog::createAvailableTests()
-{
- // Create "Info test"
- m_testsList.append(UnitTestFactory::create(UnitTestBase::InfoUnitId, m_logger));
- // Create "Signals test"
- m_testsList.append(UnitTestFactory::create(UnitTestBase::SignalsUnitId, m_logger));
- // Create "WaitForX test"
- m_testsList.append(UnitTestFactory::create(UnitTestBase::WaitForXUnitId, m_logger));
- // Create "IO test"
- m_testsList.append(UnitTestFactory::create(UnitTestBase::IOUnitId, m_logger));
-
-
- foreach(UnitTestBase *test, m_testsList) {
- connect(test, SIGNAL(finished()), this, SLOT(procTestFinished()));
- connect(test, SIGNAL(error()), this, SLOT(procTestError()));
- }
-}
-
-// Called only in constructor!
-void MainDialog::fillPairs()
-{
- QStringList list;
- foreach (SerialPortInfo inf, SerialPortInfo::availablePorts()) {
- if (inf.isValid() && !inf.isBusy())
- list.append(inf.portName());
- }
- ui->srcComboBox->addItems(list);
- ui->dstComboBox->addItems(list);
-}
-
-void MainDialog::enableUi(bool enable)
-{
- ui->scrollArea->setEnabled(enable);
- ui->startButton->setEnabled(enable);
-}
diff --git a/tests/guidevtest/maindialog.h b/tests/guidevtest/maindialog.h
deleted file mode 100644
index 3e1a2612..00000000
--- a/tests/guidevtest/maindialog.h
+++ /dev/null
@@ -1,82 +0,0 @@
-#ifndef MAINDIALOG_H
-#define MAINDIALOG_H
-
-#include <QtGui/QDialog>
-#include <QtCore/QAbstractListModel>
-
-
-
-namespace Ui {
-class MainDialog;
-}
-
-class UnitTestBase;
-
-class TestsViewModel : public QAbstractListModel
-{
- Q_OBJECT
-public:
- explicit TestsViewModel(const QList<UnitTestBase *> &list, QObject *parent = 0);
- virtual int rowCount(const QModelIndex &parent = QModelIndex()) const;
- virtual QVariant data(const QModelIndex &index, int role) const;
- virtual QVariant headerData(int section, Qt::Orientation orientation,
- int role = Qt::DisplayRole) const;
- virtual Qt::ItemFlags flags(const QModelIndex &index) const;
- virtual bool setData(const QModelIndex &index, const QVariant &value,
- int role = Qt::EditRole);
- virtual QModelIndex index(int row, int column,
- const QModelIndex &parent = QModelIndex()) const;
-
-private:
- QList<UnitTestBase *> m_testsList;
-};
-
-
-class DescriptionDialog : public QDialog
-{
-public:
- explicit DescriptionDialog(const QString &content, QWidget *parent = 0);
-};
-
-
-class Logger;
-class QModelIndex;
-
-class MainDialog : public QDialog
-{
- Q_OBJECT
-public:
- explicit MainDialog(QWidget *parent = 0);
- ~MainDialog();
-
-private slots:
- void procLogChanged(const QString &log);
- void procClearLogOnStartChanged(bool enable);
- void procBreakAllOnErrorChanged(bool enable);
-
- void procStartButtonClick();
- void procTestStarted();
- void procTestFinished();
- void procTestError();
-
- void procItemDoubleClick(const QModelIndex &index);
-
-private:
- Ui::MainDialog *ui;
- TestsViewModel *m_model;
- QList<UnitTestBase *> m_testsList;
- Logger *m_logger;
- int m_enabledTestsCount;
- int m_it;
-
- static const QString logFileSettingsKey;
- static const QString breakOnErrorSettingsKey;
- static const QString clearLogOnStartSettingsKey;
-
- void showSettings();
- void createAvailableTests();
- void fillPairs();
- void enableUi(bool enable);
-};
-
-#endif // MAINDIALOG_H
diff --git a/tests/guidevtest/maindialog.ui b/tests/guidevtest/maindialog.ui
deleted file mode 100644
index a86bd724..00000000
--- a/tests/guidevtest/maindialog.ui
+++ /dev/null
@@ -1,152 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<ui version="4.0">
- <class>MainDialog</class>
- <widget class="QDialog" name="MainDialog">
- <property name="geometry">
- <rect>
- <x>0</x>
- <y>0</y>
- <width>172</width>
- <height>307</height>
- </rect>
- </property>
- <property name="windowTitle">
- <string>Quick test</string>
- </property>
- <layout class="QVBoxLayout" name="verticalLayout_2">
- <item>
- <widget class="QScrollArea" name="scrollArea">
- <property name="widgetResizable">
- <bool>true</bool>
- </property>
- <widget class="QWidget" name="scrollAreaWidgetContents">
- <property name="geometry">
- <rect>
- <x>0</x>
- <y>0</y>
- <width>158</width>
- <height>248</height>
- </rect>
- </property>
- <layout class="QVBoxLayout" name="verticalLayout">
- <item>
- <widget class="QListView" name="listView">
- <property name="toolTip">
- <string>Double Click by test item for get a description.</string>
- </property>
- </widget>
- </item>
- <item>
- <layout class="QGridLayout" name="gridLayout">
- <item row="0" column="0">
- <widget class="QLabel" name="srcLabel">
- <property name="text">
- <string>Src:</string>
- </property>
- </widget>
- </item>
- <item row="0" column="1">
- <widget class="QComboBox" name="srcComboBox">
- <property name="toolTip">
- <string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
-&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
-p, li { white-space: pre-wrap; }
-&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Sans Serif'; font-size:7pt; font-weight:400; font-style:normal;&quot;&gt;
-&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'MS Shell Dlg 2';&quot;&gt;Select source port for pair.&lt;/span&gt;&lt;/p&gt;
-&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2';&quot;&gt;&lt;/p&gt;
-&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'MS Shell Dlg 2'; text-decoration: underline; color:#ff0000;&quot;&gt;Note:&lt;/span&gt;&lt;span style=&quot; font-family:'MS Shell Dlg 2'; color:#ff0000;&quot;&gt; &lt;/span&gt;&lt;/p&gt;
-&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'MS Shell Dlg 2'; color:#ff0000;&quot;&gt;Source port and destination port should be different!&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
- </property>
- </widget>
- </item>
- <item row="1" column="0">
- <widget class="QLabel" name="dstLabel">
- <property name="text">
- <string>Dst:</string>
- </property>
- </widget>
- </item>
- <item row="1" column="1">
- <widget class="QComboBox" name="dstComboBox">
- <property name="toolTip">
- <string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
-&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
-p, li { white-space: pre-wrap; }
-&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Sans Serif'; font-size:7pt; font-weight:400; font-style:normal;&quot;&gt;
-&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'MS Shell Dlg 2';&quot;&gt;Select destination port for pair.&lt;/span&gt;&lt;/p&gt;
-&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2';&quot;&gt;&lt;/p&gt;
-&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'MS Shell Dlg 2'; text-decoration: underline; color:#ff0000;&quot;&gt;Note:&lt;/span&gt;&lt;span style=&quot; font-family:'MS Shell Dlg 2'; color:#ff0000;&quot;&gt; &lt;/span&gt;&lt;/p&gt;
-&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'MS Shell Dlg 2'; color:#ff0000;&quot;&gt;Source port and destination port should be different!&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
- </property>
- </widget>
- </item>
- <item row="2" column="0">
- <widget class="QLabel" name="logLabel">
- <property name="text">
- <string>Log:</string>
- </property>
- </widget>
- </item>
- <item row="2" column="1">
- <widget class="QLineEdit" name="logLineEdit">
- <property name="toolTip">
- <string>Write here the name of the log file.</string>
- </property>
- <property name="text">
- <string/>
- </property>
- </widget>
- </item>
- <item row="3" column="0" colspan="2">
- <widget class="QCheckBox" name="clearLogCheckBox">
- <property name="toolTip">
- <string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
-&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
-p, li { white-space: pre-wrap; }
-&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Sans Serif'; font-size:7pt; font-weight:400; font-style:normal;&quot;&gt;
-&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'MS Shell Dlg 2';&quot;&gt;Clears the log file before starting the queue test.&lt;/span&gt;&lt;/p&gt;
-&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'MS Shell Dlg 2';&quot;&gt;Otherwise, all subsequent entries will be appended to the end of file.&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
- </property>
- <property name="text">
- <string>Clear log on start.</string>
- </property>
- </widget>
- </item>
- <item row="4" column="0" colspan="2">
- <widget class="QCheckBox" name="breakAllCheckBox">
- <property name="toolTip">
- <string>Terminates all the tests, if at least one test failed.
-Error condition is given by the developer within the test manually.
-Change the condition on which an error, can only change your test code and recompiling the application again.</string>
- </property>
- <property name="text">
- <string>Break all on error</string>
- </property>
- </widget>
- </item>
- </layout>
- </item>
- </layout>
- </widget>
- </widget>
- </item>
- <item>
- <widget class="QPushButton" name="startButton">
- <property name="text">
- <string>Start tests</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QProgressBar" name="progressBar">
- <property name="value">
- <number>0</number>
- </property>
- </widget>
- </item>
- </layout>
- </widget>
- <layoutdefault spacing="6" margin="11"/>
- <resources/>
- <connections/>
-</ui>
diff --git a/tests/guidevtest/unittestinfo.cpp b/tests/guidevtest/unittestinfo.cpp
deleted file mode 100644
index 08bcc260..00000000
--- a/tests/guidevtest/unittestinfo.cpp
+++ /dev/null
@@ -1,64 +0,0 @@
-#include "unittests.h"
-#include "serialportinfo.h"
-
-
-
-/* Public methods */
-
-UnitTestInfo::UnitTestInfo(Logger *logger, QObject *parent)
- : UnitTestBase(UnitTestBase::InfoUnitId, logger, parent)
-{
- m_name = QString(tr("Info Test"));
- m_description = QString(tr("\"Info Test\" tested class SerialPortInfo,\n"
- "by calling its methods and write the results to a log.\n\n"
- "In the log lists all serial ports that were discovered,\n"
- "their properties, states, and supported standard rates."));
-}
-
-/* Public slots */
-
-void UnitTestInfo::start(bool first)
-{
- Q_UNUSED (first);
-
- QString header(tr("\n[ Test: ID#%1, Name: %2 ]\n%3\n\n"));
- header = header
- .arg(m_id)
- .arg(m_name)
- .arg(QString("timestamp"));/*.arg(UnitTestManager::timestamp());*/
-
- m_logger->addContent(header);
-
- int it = 0;
- foreach (SerialPortInfo inf, SerialPortInfo::availablePorts()) {
- QString body(tr("Port# %1, name : %2\n"
- " location : %3\n"
- " description : %4\n"
- " valid : %5\n"
- " busy : %6\n"
- " rates : %7\n"));
-
- QString r;
- foreach (qint32 rate, inf.standardRates()) {
- r.append(QString::number(rate));
- r.append(';');
- }
-
- body = body
- .arg(it++)
- .arg(inf.portName())
- .arg(inf.systemLocation())
- .arg(inf.description())
- .arg(inf.isValid())
- .arg(inf.isBusy())
- .arg(r);
-
- m_logger->addContent(body);
- }
-
- QString trailer(tr("\nFound %1 ports.\n"));
- trailer = trailer.arg(it);
- m_logger->addContent(trailer);
-
- emit finished();
-}
diff --git a/tests/guidevtest/unittestio.cpp b/tests/guidevtest/unittestio.cpp
deleted file mode 100644
index 2aff9c06..00000000
--- a/tests/guidevtest/unittestio.cpp
+++ /dev/null
@@ -1,308 +0,0 @@
-#include "unittests.h"
-#include "serialport.h"
-
-#include <QtCore/QTimer>
-#include <QtCore/QStringList>
-
-
-enum {
- RATES_COUNT = 2,
- DATABITS_COUNT = 1,
- PARITY_COUNT = 5,
- STOPBITS_COUNT = 2,
- FLOW_COUNT = 3
-};
-
-static const SerialPort::Rate vratesarray[RATES_COUNT] = {
- SerialPort::Rate9600,
- SerialPort::Rate115200
-};
-static const char *sratesarray[] = {
- "9600\0",
- "115200\0"
-};
-
-static const SerialPort::DataBits vdatabitsarray[DATABITS_COUNT] = {
- SerialPort::Data8
-};
-static const char *sdatabitsarray[] = {
- "8\0"
-};
-
-static const SerialPort::Parity vparitysarray[PARITY_COUNT] = {
- SerialPort::NoParity,
- SerialPort::EvenParity,
- SerialPort::OddParity,
- SerialPort::SpaceParity,
- SerialPort::MarkParity
-};
-static const char *sparitysarray[] = {
- "none\0",
- "even\0",
- "odd\0",
- "space\0",
- "mark\0"
-};
-
-static const SerialPort::StopBits vstopbitsarray[STOPBITS_COUNT] = {
- SerialPort::OneStop,
- SerialPort::TwoStop
-};
-static const char *sstopbitsarray[] = {
- "one\0",
- "two\0"
-};
-
-static const SerialPort::FlowControl vflowsarray[FLOW_COUNT] = {
- SerialPort::NoFlowControl,
- SerialPort::HardwareControl,
- SerialPort::SoftwareControl
-};
-static const char *sflowsarray[] = {
- "none\0",
- "hardware\0",
- "software\0"
-};
-
-static QString split_on_table(const QByteArray &data, int tablewidth)
-{
- QString result;
- int datacount = data.count();
- int i = 0;
-
- while (i < datacount) {
- result.append(data.mid(i, tablewidth).toHex());
- result.append('\n');
- i += tablewidth;
- }
- return result;
-}
-
-static QByteArray random_data_array(int arraysize)
-{
- QByteArray result;
- while (arraysize--) {
- // Here, protection of control characters 11h, 13h
- // with software flow control.
- char c;
- do {
- c = qrand();
- } while ((c == 0x11) || (c == 0x13));
-
- result.append(c);
- }
- return result;
-}
-
-
-
-/* Public methods */
-
-UnitTestIO::UnitTestIO(Logger *logger, QObject *parent)
- : UnitTestBase(UnitTestBase::IOUnitId, logger, parent)
- , m_rateIterator(0)
- , m_databitsIterator(0)
- , m_parityIterator(0)
- , m_stopbitsIterator(0)
- , m_flowIterator(0)
- , m_bytesWrite(0)
- , m_bytesRead(0)
-{
- m_name = QString(tr("IO Test"));
- m_description = QString(tr("\"IO Test\" designed to test the I/O between the two ports\n"
- "Source port sends a data packet to the destination port,\n"
- "that reads the packet.\n"
- " The default packet size is 500 bytes, the size can be changed\n"
- "programmatically by changing the value of the\n"
- "variable TransferBytesCount. Also, before sending the package\n"
- "is filled with a random value.\n"
- " Both ports after each transaction, change their parameters:\n"
- "speed, number of data bits, parity, number of stop bits,\n"
- "flow regime, until the end all enumerated parameters.\n"
- "After each transaction is recorded in a log the contents of the\n"
- "sent and received packet, and check their size. If the packet\n"
- "sizes are different, the test is aborted with an error which is\n"
- "recorded in the log.\n"
- ));
-
- m_srcPort = new SerialPort(this);
- m_dstPort = new SerialPort(this);
-}
-
-/* Public slots */
-
-void UnitTestIO::start(bool first)
-{
- if (first) {
- QString header(tr("\n[ Test: ID#%1, Name: %2 ]\n%3\n\n"));
- header = header
- .arg(m_id)
- .arg(m_name)
- .arg(QString("timestamp"));/*.arg(UnitTestManager::timestamp());*/
-
- m_logger->addContent(header);
-
- m_srcPort->setPort(m_srcPortName);
- m_dstPort->setPort(m_dstPortName);
-
- if (!(open(UnitTestBase::SrcPort) && open(UnitTestBase::DstPort))) {
- emit error();
- return;
- } else {
- QString content(tr("\nSource and destination ports is opened.\n"));
- m_logger->addContent(content);
- }
-
- m_rateIterator = 0;
- m_databitsIterator = 0;
- m_parityIterator = 0;
- m_stopbitsIterator = 0;
- m_flowIterator = 0;
- }
-
- transaction();
-}
-
-/* Private slots */
-
-void UnitTestIO::procSingleShot()
-{
- QByteArray data = m_dstPort->readAll();
-
- QString content("r:\n%1\n");
- content = content.arg(split_on_table(data, 32));
- m_logger->addContent(content);
-
- m_bytesRead = data.count();
-
- content = QString(tr("= write: %1 read: %2 =\n"));
- content = content
- .arg(m_bytesWrite)
- .arg(m_bytesRead);
- m_logger->addContent(content);
-
- if (m_bytesWrite != m_bytesRead) {
- content = QString(tr("\nError: Mismatch of write and read bytes.\n"));
- m_logger->addContent(content);
- close(UnitTestBase::SrcPort);
- close(UnitTestBase::DstPort);
- emit error();
- return;
- }
-
- ++m_rateIterator;
- if (m_rateIterator == RATES_COUNT) {
- m_rateIterator = 0;
-
- ++m_databitsIterator;
- if (m_databitsIterator == DATABITS_COUNT) {
- m_databitsIterator = 0;
-
- ++m_parityIterator;
- if (m_parityIterator == PARITY_COUNT) {
- m_parityIterator = 0;
-
- ++m_stopbitsIterator;
- if (m_stopbitsIterator == STOPBITS_COUNT) {
- m_stopbitsIterator = 0;
-
- ++m_flowIterator;
- if (m_flowIterator == FLOW_COUNT) {
- m_flowIterator = 0;
-
- close(UnitTestBase::SrcPort);
- close(UnitTestBase::DstPort);
- emit finished();
- return;
- }
- }
- }
- }
- }
-
- transaction();
-}
-
-void UnitTestIO::transaction()
-{
- if (!(configure(UnitTestBase::SrcPort) && configure(UnitTestBase::DstPort))) {
- emit error();
- return;
- }
-
- QString content(tr("\nrate : %1"
- "\ndatabits: %2"
- "\npatity : %3"
- "\nstopbits: %4"
- "\nflow : %5\n\n"));
-
- content = content
- .arg(QString(sratesarray[m_rateIterator]))
- .arg(QString(sdatabitsarray[m_databitsIterator]))
- .arg(QString(sparitysarray[m_parityIterator]))
- .arg(QString(sstopbitsarray[m_stopbitsIterator]))
- .arg(QString(sflowsarray[m_flowIterator]));
-
- m_logger->addContent(content);
-
- QByteArray data = random_data_array(TransferBytesCount);
- m_bytesWrite = m_srcPort->write(data);
-
- content = "w:\n%1\n";
- content = content.arg(split_on_table(data, 32));
- m_logger->addContent(content);
-
- QTimer::singleShot(TransactionMsecDelay, this, SLOT(procSingleShot()));
-}
-
-/* Private */
-
-bool UnitTestIO::open(DirPorts dir)
-{
- SerialPort *port = (dir == UnitTestBase::SrcPort) ?
- m_srcPort : m_dstPort;
- QIODevice::OpenMode mode = (dir == UnitTestBase::SrcPort) ?
- QIODevice::WriteOnly : QIODevice::ReadOnly;
-
- QString error("\nError: Can\'t open port %1\n");
- if (!port->open(mode)) {
- error = error.arg(port->portName());
- m_logger->addContent(error);
- return false;
- }
- return true;
-}
-
-bool UnitTestIO::configure(DirPorts dir)
-{
- SerialPort *port = (dir == UnitTestBase::SrcPort) ?
- m_srcPort : m_dstPort;
-
- if (!(port->setRate(vratesarray[m_rateIterator])
- && port->setDataBits(vdatabitsarray[m_databitsIterator])
- && port->setParity(vparitysarray[m_parityIterator])
- && port->setStopBits(vstopbitsarray[m_stopbitsIterator])
- && port->setFlowControl(vflowsarray[m_flowIterator]))) {
-
- QString error("\nError: Can\'t configure port %1\n");
- error = error.arg(port->portName());
- m_logger->addContent(error);
- return false;
- }
- return true;
-}
-
-void UnitTestIO::close(DirPorts dir)
-{
- if (dir == UnitTestBase::SrcPort) {
- if (m_srcPort->isOpen())
- m_srcPort->close();
- } else {
- if (m_dstPort->isOpen())
- m_dstPort->close();
- }
-}
-
-
-
-
diff --git a/tests/guidevtest/unittests.h b/tests/guidevtest/unittests.h
deleted file mode 100644
index 0b2fd94a..00000000
--- a/tests/guidevtest/unittests.h
+++ /dev/null
@@ -1,168 +0,0 @@
-#ifndef UNITTESTS_H
-#define UNITTESTS_H
-
-#include <QtCore/QObject>
-
-
-class QFile;
-
-class Logger : public QObject
-{
- Q_OBJECT
-public:
- explicit Logger(QObject *parent = 0);
- void setFileName(const QString &name);
- void addContent(const QString &content, bool clearAll = false);
-
-private:
- QFile *m_file;
-};
-
-class SerialPort;
-
-class UnitTestBase : public QObject
-{
- Q_OBJECT
-signals:
- void finished();
- void error();
-
-public:
- enum UnitID {
- InfoUnitId,
- SignalsUnitId,
- WaitForXUnitId,
- IOUnitId,
-
- };
-
- explicit UnitTestBase(UnitID id, Logger *logger, QObject *parent = 0);
- void setPair(const QString &src, const QString &dst);
- void setEnable(bool enable);
- bool isEnabled() const;
- int id() const;
- QString name() const;
- QString description() const;
-
-public slots:
- virtual void start(bool first = true) = 0;
-
-protected:
- enum DirPorts { SrcPort, DstPort };
- int m_id;
- QString m_name;
- QString m_description;
- QString m_enableParam;
- Logger *m_logger;
- SerialPort *m_srcPort;
- SerialPort *m_dstPort;
- QString m_srcPortName;
- QString m_dstPortName;
-};
-
-
-class UnitTestInfo : public UnitTestBase
-{
- Q_OBJECT
-public:
- explicit UnitTestInfo(Logger *logger, QObject *parent = 0);
-
-public slots:
- virtual void start(bool first);
-};
-
-class UnitTestSignals : public UnitTestBase
-{
- Q_OBJECT
-public:
- explicit UnitTestSignals(Logger *logger, QObject *parent = 0);
-
-public slots:
- virtual void start(bool first);
-
-private slots:
- void procSignalBytesWritten(qint64 bw);
- void procSignalReadyRead();
- void procSingleShot();
- void transaction();
-
-private:
- enum {
- TransactionLimit = 5,
- TransactionMsecDelay = 1000,
- MinBytesToWrite = 1,
- StepBytesToWrite = 100
- };
-
- bool m_started;
- int m_transactionNum;
- qint64 m_bytesToWrite;
- qint64 m_bytesReallyWrited;
- int m_countSignalsBytesWritten;
- int m_countSignalsReadyRead;
-
-
- bool open(DirPorts dir);
- bool configure(DirPorts dir);
- void close(DirPorts dir);
-};
-
-class UnitTestWaitForX : public UnitTestBase
-{
- Q_OBJECT
-public:
- explicit UnitTestWaitForX(Logger *logger, QObject *parent = 0);
-
-public slots:
- virtual void start(bool first);
-};
-
-class UnitTestIO : public UnitTestBase
-{
- Q_OBJECT
-public:
- explicit UnitTestIO(Logger *logger, QObject *parent = 0);
-
-public slots:
- virtual void start(bool first);
-
-private slots:
- void procSingleShot();
- void transaction();
-
-private:
- enum {
- TransferBytesCount = 500,
- TransactionMsecDelay = 700
- };
-
- int m_rateIterator;
- int m_databitsIterator;
- int m_parityIterator;
- int m_stopbitsIterator;
- int m_flowIterator;
-
- qint64 m_bytesWrite;
- qint64 m_bytesRead;
-
- bool open(DirPorts dir);
- bool configure(DirPorts dir);
- void close(DirPorts dir);
-};
-
-
-
-
-
-
-
-
-
-class UnitTestFactory
-{
-public:
- static UnitTestBase *create(UnitTestBase::UnitID id, Logger *logger);
-};
-
-
-#endif // UNITTESTS_H
diff --git a/tests/guidevtest/unittestsignals.cpp b/tests/guidevtest/unittestsignals.cpp
deleted file mode 100644
index ade48771..00000000
--- a/tests/guidevtest/unittestsignals.cpp
+++ /dev/null
@@ -1,218 +0,0 @@
-#include "unittests.h"
-#include "serialport.h"
-
-#include <QtCore/QTimer>
-//#include <QtCore/QByteArray>
-
-
-/* Public methods */
-
-UnitTestSignals::UnitTestSignals(Logger *logger, QObject *parent)
- : UnitTestBase(UnitTestBase::SignalsUnitId, logger, parent)
- , m_started(false), m_transactionNum(0), m_bytesToWrite(0)
- , m_bytesReallyWrited(0), m_countSignalsBytesWritten(0)
- , m_countSignalsReadyRead(0)
-{
- m_name = QString(tr("Signals Test"));
- m_description = QString(tr("\"Signals Test\" monitors and verifies the correctness of the\n"
- "emission signals bytesWritten() and readyRead().\n\n"
- "This test uses the source port and destination port.\n\n"
- "The source port is opened only as write-only, and this\n"
- "test from the port set control a signal bytesWritten().\n"
- "In this case, count the number of emit signals bytesWritten()\n"
- "and the number of bytes of data transmitted in the signal for\n"
- "a single emit.\n\n"
- "The destination port is opened as read-only, and this\n"
- "test from the port set control a signal readyRead().\n"
- "At the same time count the number of signals readyRead().\n\n"
- "By default ports are opened in the mode: 9600 8 N 1, no flow control.\n"
- "The testing process consists of several stages:\n\n"
- " Stage1. Opened and initialized ports. If an error occurs, it is\n"
- "recorded in the log and testing is completed with failure. If\n"
- "everything goes well, then go to stage 2.\n\n"
- " Stage2. Run single shot the timer interval to 1 second, and\n"
- "further, the source port sends a byte, at the same time are tracked\n"
- "and logged signals from the ports. Further, when the timer works,\n"
- "there is a processing of the results of the signals. Compares the\n"
- "number of bytes sent and received, and these results or an error is\n"
- "generated with the termination of the test, or go to stage 3.\n\n"
- " Stage3. No different from stage 2 with the exception of the number\n"
- "of bytes transmitted. Now write not one but several bytes. The number\n"
- "of bytes transmitted is now increasing, according to the formula:\n"
- "NumCurr = NumPrev + K, where K - some constant. Further, the\n"
- "termination of a test or go to stage 4.\n\n"
- " Stage4. Does not differ from step 3, except the number of bytes.\n\n"
- " StageN. No different from the previous steps.\n\n"
- "By default, the number of transactions (steps) for the transfer of\n"
- "data is five, but this value can be changed by editing the source\n"
- "code of the test. In the source code you can change settings such as:\n"
- "- timeout of timer (by default 1 sec)\n"
- "- number of steps (by default 5)\n"
- "- initial number of bytes transmitted (by default 1 byte)\n"
- "- constant growth rate K of transmitted bytes (by default 100 byte)."));
-
- m_srcPort = new SerialPort(this);
- m_dstPort = new SerialPort(this);
-
- connect(m_srcPort, SIGNAL(bytesWritten(qint64)),
- this, SLOT(procSignalBytesWritten(qint64)));
- connect(m_dstPort, SIGNAL(readyRead()),
- this, SLOT(procSignalReadyRead()));
-}
-
-/* Public slots */
-
-void UnitTestSignals::start(bool first)
-{
- if (first) {
- QString header(tr("\n[ Test: ID#%1, Name: %2 ]\n%3\n\n"));
- header = header
- .arg(m_id)
- .arg(m_name)
- .arg(QString("timestamp"));/*.arg(UnitTestManager::timestamp());*/
-
- m_logger->addContent(header);
-
- m_srcPort->setPort(m_srcPortName);
- m_dstPort->setPort(m_dstPortName);
-
- if (!(open(UnitTestBase::SrcPort) && open(UnitTestBase::DstPort)
- && configure(UnitTestBase::SrcPort) && configure(UnitTestBase::DstPort))) {
-
- close(UnitTestBase::SrcPort);
- close(UnitTestBase::DstPort);
- emit error();
- return;
- } else {
- QString content(tr("\nSource and destination ports\n"
- "opened as 9600 8 N 1 by default.\n"));
- m_logger->addContent(content);
- }
-
- // Prepare transaction begin.
- m_transactionNum = 0;
- m_bytesToWrite = MinBytesToWrite;
- m_bytesReallyWrited = 0;
- m_countSignalsBytesWritten = 0;
- m_countSignalsReadyRead = 0;
- }
-
- transaction();
-}
-
-/* Private slots */
-
-void UnitTestSignals::procSignalBytesWritten(qint64 bw)
-{
- QString content(">signal bytesWritten(%1)\n");
- content = content.arg(bw);
- m_logger->addContent(content);
- ++m_countSignalsBytesWritten;
- m_bytesReallyWrited += bw;
-}
-
-void UnitTestSignals::procSignalReadyRead()
-{
- ++m_countSignalsReadyRead;
-}
-
-void UnitTestSignals::procSingleShot()
-{
- QByteArray data = m_dstPort->readAll();
- qint64 reallyRead = data.count();
-
- QString content(tr("- count signals bytesWritten : %1\n"
- "- count signals readyRead : %2\n"
- "- bytes really write : %3\n"
- "- bytes really read : %4\n"));
- content = content
- .arg(m_countSignalsBytesWritten)
- .arg(m_countSignalsReadyRead)
- .arg(m_bytesReallyWrited)
- .arg(reallyRead);
-
- m_logger->addContent(content);
-
- m_countSignalsBytesWritten = 0;
- m_countSignalsReadyRead = 0;
-
- if ((m_bytesReallyWrited != m_bytesToWrite)
- || (m_bytesToWrite != reallyRead)) {
-
- content = QString(tr("\nError: Mismatch of sent and received bytes.\n"));
- m_logger->addContent(content);
- close(UnitTestBase::SrcPort);
- close(UnitTestBase::DstPort);
- emit error();
- }
-
- m_bytesReallyWrited = 0;
- m_bytesToWrite += StepBytesToWrite;
-
- transaction();
-}
-
-void UnitTestSignals::transaction()
-{
- if (m_transactionNum++ != TransactionLimit) {
- QString content(tr("\nTransaction #%1, bytes to write: %2\n"));
- content = content.arg(m_transactionNum).arg(m_bytesToWrite);
- m_logger->addContent(content);
-
- QByteArray data(m_bytesToWrite, qrand());
- QTimer::singleShot(TransactionMsecDelay, this, SLOT(procSingleShot()));
- m_srcPort->write(data);
- } else {
- close(UnitTestBase::SrcPort);
- close(UnitTestBase::DstPort);
- emit finished();
- }
-}
-
-/* Private */
-
-bool UnitTestSignals::open(DirPorts dir)
-{
- SerialPort *port = (dir == UnitTestBase::SrcPort) ?
- m_srcPort : m_dstPort;
- QIODevice::OpenMode mode = (dir == UnitTestBase::SrcPort) ?
- QIODevice::WriteOnly : QIODevice::ReadOnly;
-
- QString error("\nError: Can\'t open port %1\n");
- if (!port->open(mode)) {
- error = error.arg(port->portName());
- m_logger->addContent(error);
- return false;
- }
- return true;
-}
-
-bool UnitTestSignals::configure(DirPorts dir)
-{
- SerialPort *port = (dir == UnitTestBase::SrcPort) ?
- m_srcPort : m_dstPort;
-
- if (!(port->setRate(9600) && port->setDataBits(SerialPort::Data8)
- && port->setParity(SerialPort::NoParity) && port->setStopBits(SerialPort::OneStop)
- && port->setFlowControl(SerialPort::NoFlowControl))) {
-
- QString error("\nError: Can\'t configure port %1\n");
- error = error.arg(port->portName());
- m_logger->addContent(error);
- return false;
- }
- return true;
-}
-
-void UnitTestSignals::close(DirPorts dir)
-{
- if (dir == UnitTestBase::SrcPort) {
- if (m_srcPort->isOpen())
- m_srcPort->close();
- } else {
- if (m_dstPort->isOpen())
- m_dstPort->close();
- }
-}
-
-
diff --git a/tests/guidevtest/unittestwaitforx.cpp b/tests/guidevtest/unittestwaitforx.cpp
deleted file mode 100644
index a9dd3cb7..00000000
--- a/tests/guidevtest/unittestwaitforx.cpp
+++ /dev/null
@@ -1,33 +0,0 @@
-#include "unittests.h"
-#include "serialport.h"
-
-
-
-/* Public methods */
-
-UnitTestWaitForX::UnitTestWaitForX(Logger *logger, QObject *parent)
- : UnitTestBase(UnitTestBase::WaitForXUnitId, logger, parent)
-{
- m_name = QString(tr("WaitForX Test"));
- m_description = QString(tr("\"WaitForX Test\" ..."));
-}
-
-/* Public slots */
-
-void UnitTestWaitForX::start(bool first)
-{
- Q_UNUSED(first);
-
- QString header(tr("\n[ Test: ID#%1, Name: %2 ]\n%3\n\n"));
- header = header
- .arg(m_id)
- .arg(m_name)
- .arg(QString("timestamp"));/*.arg(UnitTestManager::timestamp());*/
-
- m_logger->addContent(header);
-
- ////
-
- emit finished();
-}
-