Commit 9d32ca15 authored by Bryant's avatar Bryant

Removed unneeded qserialport library.

Replaced by /libs/serialport.
parent efe8e8b2
This diff is collapsed.
This diff is collapsed.
Installing QSerialPort
----------------------
QSerialPort requires Qt 4.6 or greater.
For Mac/Unix/Linux/Embedded Linux:
./configure
make
make install
/sbin/ldconfig, if necessary
For Windows:
configure
nmake (or make)
installwin
For Wince:
qmake -r qserialport.pro -spec <platform-name>
nmake
i.e "qmake -r qserialport.pro -spec wince50standard-x86-msvc2005" for wince 5.0 standard sdk
Notes
-----
- On unix, use --prefix=$PWD to build in-place
- if 'configure' doesn't work on Mac OSX (it doesn't work if QT is installed as SDK), use the following instead:
qmake -r qserialport.pro -spec macx-g++
make
make install
Optionally add lib_bundle config value to build it as framework:
qmake -r qserialport.pro -spec macx-g++ CONFIG+=lib_bundle
- To build QSerialPort as static library try CONFIG+=static with qmake or add it into conf.pri file.
- Visual Studio 2005 solution and project files are included into the package. Current solution is prepared for WIN32 builds.
If you want to build QSerialPort for WINCE using Visual Studio then do the following:
o replace qserialportnative_win32.cpp with qserialportnative_wince.cpp
o add wincommevtbreaker.cpp and wincommevtbreaker.h files into the project
Please report problems to:
labs@inbiza.com
This diff is collapsed.
/**
\mainpage Unofficial Qt Serial Port Library
%QSerialPort is a cross-platform serial port library, using Qt datatypes and
conventions. %QSerialPort inherits from <a href="http://doc.trolltech.com/4.7/qiodevice.html">QIODevice
</a> and works natively with any Qt class that uses QIODevice objects as input or output.
%QSerialPort should work everywhere %Qt does, including Windows/Unix/Linux/Embedded Linux/WinCE/MacOSX. This
version of %QSerialPort is for Qt4, and requires no Qt3 compatibility code.
\section Characteristics Device Characteristics
%QSerialPort has the following QIODevice characteristics:
- Supports event-driven and polling programming models
- It is a sequential device like <a href="http://doc.trolltech.com/4.7/qprocess.html">QProcess</a> and
<a href="http://doc.trolltech.com/4.7/qtcpsocket.html">QTcpSocket</a>
- It is an unbuffered device
\section using Using QSerialPort
The application simply includes &lt;QSerialPort> and links to
libqserialport. There are additional examples available in the "examples" directory.
You will notice that %QSerialPort is part of TNX namespace. TNX stands for Tonix
which is a Qt based cross-platform hardware control framework with built in JavaScript support. Since Tonix
is specially designed for embedded system development and robotics projects %QSerialPort is an essential part of it.
Example:
\code
#include <QSerialPort>
int main(int argc, char *argv[])
{
using namespace TNX;
QCoreApplication a(argc, argv);
QSerialPort serport("COM5", "9600,8,n,1");
if ( !serport.open() )
qFatal("Cannot open serial port %s. Exiting..", qPrintable(portName));
if ( !serport.setCommTimeouts(QSerialPort::CtScheme_NonBlockingRead) )
qWarning("Cannot set communications timeout values at port %s.", qPrintable(portName));
int byteCounter = 0;
forever {
if ( serport.waitForReadyRead(5000) ) { // 5sec
QByteArray data = serport.read(512);
byteCounter += data.size();
std::cout << "Received data @ " << qPrintable(QDateTime::currentDateTime().toString("hh:mm:ss.zzz")) <<
". Echo back." << std::endl;
serport.write(data);
if ( byteCounter >= 4096 )
break;
}
else {
std::cout << "Timeout while waiting for incoming data @ " <<
qPrintable(QDateTime::currentDateTime().toString("hh:mm:ss.zzz")) << std::endl;
}
}
std::cout << "Polling example is terminated successfully." << std::endl;
return 0;
}
\endcode
*/
Unofficial Qt Serial Port library version 1.0.0 alpha
-----------------------------------------------------
Date: October 15th, 2010
Website: http://www.inbiza.com/labs
Description
-----------
QSerialPort is a high performance cross platform serial library based on the QIODevice class from the Qt framework. Building this library on QIODevice allows for a much more integrated and native experience when developing Qt based applications.
The project stems from our work on high performance embedded systems where we need to squeeze out as much IO performance as possible from hardware with limited resources.
This library has been tested on:
Ð Linux on x86 and ARM ;
Ð Windows XP and CE 5 on x86;
Ð OS X 10.6 on x86 with a FTDI USB to Serial bridge.
API Documentation is located in the 'apidocs' subdirectory. Run 'make doc' to generate the documentation on a Linux system with Doxygen installed.
Special Thanks
--------------
We used Qt Cryptographic Architecture (QCA) project's layout
and qmake configuration as a model for our project. We thank to
Justin Karneges and QCA team for their great work.
Install
-------
For installation or compiling instructions, see the INSTALL file.
License
-------
This software is distributed under the terms of the GNU Lesser General Public License version 2.1.
Changes
-------
<none>
* 1.0.0 Alpha
o Symbian support
o mingw test/support
o Increase testing coverage - see TestPlan for details
o Make sure that QSerialPort works properly when created by a thread other than the main thread
o Add breakState() method
o Test line signal related methods
o Code cleanup
o Better documentation
##
## Unofficial Qt Serial Port Library
##
## Copyright (c) 2010 Inbiza Systems Inc. All rights reserved.
##
## This program is free software: you can redistribute it and/or modify it
## under the terms of the GNU Lesser General Public License as published by the
## Free Software Foundation, either version 3 of the License, or (at your
## option) any later version.
##
## This program is distributed in the hope that it will be useful, but WITHOUT
## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
## more details.
##
## You should have received a copy of the GNU Lesser General Public License
## along with this program. If not, see <http://www.gnu.org/licenses/>
##
##
## @file app.pri
## www.inbiza.com
##
include(confapp.pri)
include(base.pri)
macx:QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.6 #for universal
# qmake configuring apps with staticlib poses linking problems
windows|wince*:staticlib {
CONFIG-=shared
CONFIG-=staticlib
CONFIG+=static
}
exists(qserialport.prf) {
# our apps should build against the qserialport in this tree
include(qserialport.prf)
} else {
# attempt to use system-wide qserialport
CONFIG *= qserialport
}
##
## Unofficial Qt Serial Port Library
##
## Copyright (c) 2010 Inbiza Systems Inc. All rights reserved.
##
## This program is free software: you can redistribute it and/or modify it
## under the terms of the GNU Lesser General Public License as published by the
## Free Software Foundation, either version 3 of the License, or (at your
## option) any later version.
##
## This program is distributed in the hope that it will be useful, but WITHOUT
## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
## more details.
##
## You should have received a copy of the GNU Lesser General Public License
## along with this program. If not, see <http://www.gnu.org/licenses/>
##
##
## @file base.pri
## www.inbiza.com
##
!isEmpty( QMAKESPEC ) {
MKSPEC = $$replace(QMAKESPEC,-," ")
MKSPEC = $$join(MKSPEC, " -L", )
PLATFORM_NAME = $$member(MKSPEC)
}
else{
unix:PLATFORM_NAME = $$system( uname -s )
windows: PLATFORM_NAME = Win32
}
QSERIALPORT_BASE = $$PWD
QSERIALPORT_SRCBASE = $$QSERIALPORT_BASE/src
QSERIALPORT_INCBASE = $$QSERIALPORT_BASE/include
QSERIALPORT_LIBDIR = $$QSERIALPORT_BASE/lib
QSERIALPORT_BUILDDIR = $$QSERIALPORT_BASE/build/$$PLATFORM_NAME
QSERIALPORT_BINDESTDIR = $$QSERIALPORT_BASE/bin
# qconf
PREFIX = /usr/local
BINDIR = /usr/local/bin
DATADIR = /usr/local/share
##
## Unofficial Qt Serial Port Library
##
## Copyright (c) 2010 Inbiza Systems Inc. All rights reserved.
##
## This program is free software: you can redistribute it and/or modify it
## under the terms of the GNU Lesser General Public License as published by the
## Free Software Foundation, either version 3 of the License, or (at your
## option) any later version.
##
## This program is distributed in the hope that it will be useful, but WITHOUT
## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
## more details.
##
## You should have received a copy of the GNU Lesser General Public License
## along with this program. If not, see <http://www.gnu.org/licenses/>
##
##
## @file qserialport.prf
## www.inbiza.com
##
CONFIG += release
This diff is collapsed.
##
## Unofficial Qt Serial Port Library
##
## Copyright (c) 2010 Inbiza Systems Inc. All rights reserved.
##
## This program is free software: you can redistribute it and/or modify it
## under the terms of the GNU Lesser General Public License as published by the
## Free Software Foundation, either version 3 of the License, or (at your
## option) any later version.
##
## This program is distributed in the hope that it will be useful, but WITHOUT
## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
## more details.
##
## You should have received a copy of the GNU Lesser General Public License
## along with this program. If not, see <http://www.gnu.org/licenses/>
##
##
## @file echo_eventmode.pro
## www.inbiza.com
##
include(../examples.pri)
DEPENDPATH += . $$QSERIALPORT_INCBASE/QtSerialPort
QT += network
!windows:TARGET = $$QSERIALPORT_BINDESTDIR/$$TARGET
# Input
SOURCES += main.cpp \
host.cpp
HEADERS += host.h
MOC_DIR = $$QSERIALPORT_BUILDDIR/GeneratedFiles/eventdriven
CONFIG(debug, debug|release) {
OBJECTS_DIR = $$QSERIALPORT_BUILDDIR/Debug/eventdriven
macx:TARGET = $$member(TARGET, 0)_debug
windows:TARGET = $$member(TARGET, 0)d
unix:!macx:TARGET = $$member(TARGET, 0).debug
}
else {
OBJECTS_DIR = $$QSERIALPORT_BUILDDIR/Release/eventdriven
}
/*
* Unofficial Qt Serial Port Library
*
* Copyright (c) 2010 Inbiza Systems Inc. All rights reserved.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by the
* Free Software Foundation, either version 3 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
* author labs@inbiza.com
*/
#include <iostream>
#include <QtCore/QCoreApplication>
#include <QThread>
#include <QSerialPort>
#include <QTimerEvent>
#include <QDateTime>
#include "host.h"
Host::Host(TNX::QSerialPort &serPort, QObject *parent)
: QObject(parent), serialPort_(serPort), timerId_(0), byteCounter_(0)
{
using TNX::QSerialPort;
timerId_ = startTimer(5000);
connect(&serialPort_, SIGNAL(readyRead()), SLOT(onDataReceived()));
if ( !serialPort_.setCommTimeouts(QSerialPort::CtScheme_NonBlockingRead) )
qWarning("Cannot set communications timeout values at port %s.", qPrintable(serialPort_.portName()));
}
Host::~Host()
{
}
void Host::onDataReceived()
{
if ( timerId_ )
killTimer(timerId_);
QByteArray data = serialPort_.read(512);
byteCounter_ += data.size();
std::cout << "Thread id: " << QThread::currentThreadId() << " Received data @ " <<
qPrintable(QDateTime::currentDateTime().toString("hh:mm:ss.zzz")) << ". Echo back." << std::endl;
serialPort_.write(data);
if ( byteCounter_ >= 4096 ) {
std::cout << "Event-Driven example is terminated successfully." << std::endl;
qApp->exit(0);
}
// create a wait timer for the next packet
timerId_ = startTimer(5000); // 5sec
}
void Host::timerEvent(QTimerEvent *event)
{
Q_ASSERT(timerId_ == event->timerId());
killTimer(event->timerId());
timerId_ = 0;
std::cout << "Timeout occurred." << std::endl;
}
/*
* Unofficial Qt Serial Port Library
*
* Copyright (c) 2010 Inbiza Systems Inc. All rights reserved.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by the
* Free Software Foundation, either version 3 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
* author labs@inbiza.com
*/
#ifndef HOST_H__
#define HOST_H__
#include <QObject>
class QTimerEvent;
namespace TNX { class QSerialPort; }
class Host : public QObject
{
Q_OBJECT
public:
Host(TNX::QSerialPort &serPort, QObject *parent = 0);
~Host();
protected:
virtual void timerEvent(QTimerEvent *event);
private slots:
void onDataReceived();
private:
TNX::QSerialPort &serialPort_;
int timerId_;
int byteCounter_;
};
#endif // HOST_H__
/*
* Unofficial Qt Serial Port Library
*
* Copyright (c) 2010 Inbiza Systems Inc. All rights reserved.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by the
* Free Software Foundation, either version 3 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
* author labs@inbiza.com
*/
#include <iostream>
#include <QtCore/QCoreApplication>
#include <QThread>
#include <QString>
#include <QStringList>
#include <QDebug>
#include <QSerialPort>
#include "host.h"
void printHelp()
{
std::cout << "Usage: echo_eventmode [--help] [--port=<serial port>] [--set=<port settings>]" << std::endl;
std::cout << std::endl;
#if defined(Q_OS_WIN)
std::cout << "Example: echo_eventmode --port=COM3 --set=9600,8,N,1" << std::endl;
#else
std::cout << "Example: echo_eventmode --port=/dev/ttyS0 --set=9600,8,N,1" << std::endl;
#endif
}
bool processArgs(const QStringList &args, QString &serPort, QString &settings)
{
QHash<QString, QString> argPairs;
foreach( QString ar, args ) {
if ( ar.split('=').size() == 2 ) {
argPairs.insert(ar.split('=').at(0), ar.split('=').at(1));
}
else {
if ( ar == "--help" )
goto LPrintHelpAndExit;
}
}
settings = argPairs.value("--set", "9600,8,n,1");
#if defined(Q_OS_WIN)
serPort = argPairs.value("--port", "COM3");
#else
serPort = argPairs.value("--port", "/dev/ttyS0");
#endif
return true;
LPrintHelpAndExit:
printHelp();
return false;
}
int main(int argc, char *argv[])
{
using TNX::QSerialPort;
QCoreApplication a(argc, argv);
std::cout << "Serial port echo example with event-driven model, Copyright (c) 2010 Inbiza Systems Inc." << std::endl;
std::cout << "Created by Inbiza Labs <labs@inbiza.com>" << std::endl;
std::cout << std::endl;
std::cout << "Main thread id: " << QThread::currentThreadId() << std::endl;
QString portName;
QString settings;
if ( !processArgs(a.arguments(), portName, settings) )
return 0;
QSerialPort serport(portName, settings);
if ( !serport.open() )
qFatal("Cannot open serial port %s. Exiting..", qPrintable(portName));
Host host(serport);
return a.exec();
}
##
## Unofficial Qt Serial Port Library
##
## Copyright (c) 2010 Inbiza Systems Inc. All rights reserved.
##
## This program is free software: you can redistribute it and/or modify it
## under the terms of the GNU Lesser General Public License as published by the
## Free Software Foundation, either version 3 of the License, or (at your
## option) any later version.
##
## This program is distributed in the hope that it will be useful, but WITHOUT
## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
## more details.
##
## You should have received a copy of the GNU Lesser General Public License
## along with this program. If not, see <http://www.gnu.org/licenses/>
##
##
## @file echo_pollingmode.pro
## www.inbiza.com
##
include(../examples.pri)
DEPENDPATH += . $$QSERIALPORT_INCBASE/QtSerialPort
QT += network
!windows:TARGET = $$QSERIALPORT_BINDESTDIR/$$TARGET
# Input
SOURCES += main.cpp
#HEADERS +=
MOC_DIR = $$QSERIALPORT_BUILDDIR/GeneratedFiles/polling
CONFIG(debug, debug|release) {
OBJECTS_DIR = $$QSERIALPORT_BUILDDIR/Debug/polling
macx:TARGET = $$member(TARGET, 0)_debug
windows:TARGET = $$member(TARGET, 0)d
unix:!macx:TARGET = $$member(TARGET, 0).debug
}
else {
OBJECTS_DIR = $$QSERIALPORT_BUILDDIR/Release/polling
}
/*
* Unofficial Qt Serial Port Library
*
* Copyright (c) 2010 Inbiza Systems Inc. All rights reserved.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by the
* Free Software Foundation, either version 3 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
* author labs@inbiza.com
*/
#include <iostream>
#include <QtCore/QCoreApplication>
#include <QString>
#include <QStringList>
#include <QDateTime>
#include <QDebug>
#include <QSerialPort>
void printHelp()
{
std::cout << "Usage: echo_pollingmode [--help] [--port=<serial port>] [--set=<port settings>]" << std::endl;
std::cout << std::endl;
#if defined(Q_OS_WIN)
std::cout << "Example: echo_pollingmode --port=COM3 --set=9600,8,N,1" << std::endl;
#else
std::cout << "Example: echo_pollingmode --port=/dev/ttyS0 --set=9600,8,N,1" << std::endl;
#endif
}
bool processArgs(const QStringList &args, QString &serPort, QString &settings)
{
QHash<QString, QString> argPairs;
foreach( QString ar, args ) {
if ( ar.split('=').size() == 2 ) {
argPairs.insert(ar.split('=').at(0), ar.split('=').at(1));
}
else {
if ( ar == "--help" )
goto LPrintHelpAndExit;
}
}
settings = argPairs.value("--set", "9600,8,n,1");
#if defined(Q_OS_WIN)
serPort = argPairs.value("--port", "COM3");
#else
serPort = argPairs.value("--port", "/dev/ttyS0");
#endif
return true;
LPrintHelpAndExit:
printHelp();
return false;
}
int main(int argc, char *argv[])