Commit 3d1f55cf authored by Lorenz Meier's avatar Lorenz Meier

Merged master, fixed local 3D init

parents ad64e8a0 2a692725
This diff is collapsed.
# -------------------------------------------------
# QGroundControl - Micro Air Vehicle Groundstation
# Please see our website at <http://qgroundcontrol.org>
# Maintainer:
# Lorenz Meier <lm@inf.ethz.ch>
# (c) 2009-2014 QGroundControl Developers
# This file is part of the open groundstation project
# QGroundControl is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# QGroundControl 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 General Public License
# along with QGroundControl. If not, see <http://www.gnu.org/licenses/>.
# -------------------------------------------------
installer {
MacBuild {
QMAKE_POST_LINK += && macdeployqt $${DESTDIR}/qgroundcontrol.app -dmg
}
WindowsBuild {
QMAKE_POST_LINK += $$escape_expand(\\n) $$quote("\"C:\\Program Files \(x86\)\\NSIS\\makensis.exe\"" /NOCD "\"/XOutFile $${DESTDIR_WIN}\\qgroundcontrol-installer-win32.exe\"" "$$BASEDIR_WIN\\deploy\\qgroundcontrol_installer.nsi")
}
}
......@@ -153,10 +153,11 @@ MacBuild {
}
WindowsBuild {
# Copy dependencies
BASEDIR_WIN = $$replace(BASEDIR,"/","\\")
DESTDIR_WIN = $$replace(DESTDIR,"/","\\")
# Copy dependencies
QMAKE_POST_LINK += $$escape_expand(\\n) $$quote($$QMAKE_COPY_DIR "$$(QTDIR)\\plugins" "$$DESTDIR_WIN")
COPY_FILE_DESTDIR = $$DESTDIR_WIN
......@@ -188,9 +189,10 @@ WindowsBuild {
# Copy Visual Studio DLLs
# Note that this is only done for release because the debugging versions of these DLLs cannot be redistributed.
# I'm not certain of the path for VS2008, so this only works for VS2010.
# This currently only works for VS2010.
win32-msvc2010 {
QMAKE_POST_LINK += $$escape_expand(\\n) $$quote(xcopy /D /Y "\"C:\\Program Files \(x86\)\\Microsoft Visual Studio 10.0\\VC\\redist\\x86\\Microsoft.VC100.CRT\\*.dll\"" "$$DESTDIR_WIN\\")
QMAKE_POST_LINK += $$escape_expand(\\n) $$quote($$QMAKE_COPY "C:\\Windows\\System32\\msvcp100.dll" "$$DESTDIR_WIN\\")
QMAKE_POST_LINK += $$escape_expand(\\n) $$quote($$QMAKE_COPY "C:\\Windows\\System32\\msvcr100.dll" "$$DESTDIR_WIN\\")
}
}
}
This diff is collapsed.
#!/bin/sh
cp -r ../../build-qgroundcontrol-Qt_4_8_1-Release/release/qgroundcontrol.app .
cp -r ../release/qgroundcontrol.app .
cp -r ../files/audio qgroundcontrol.app/Contents/MacOs/.
......@@ -7,9 +7,10 @@ mkdir -p qgroundcontrol.app/Contents/Frameworks/
mkdir -p qgroundcontrol.app/Contents/PlugIns/imageformats
mkdir -p qgroundcontrol.app/Contents/PlugIns/codecs
mkdir -p qgroundcontrol.app/Contents/PlugIns/accessible
cp -r /usr/local/Cellar/qt/4.8.5/plugins/ qgroundcontrol.app/Contents/PlugIns/.
# SDL is not copied by Qt - for whatever reason
cp -r /Library/Frameworks/SDL.framework qgroundcontrol.app/Contents/Frameworks/.
echo -e '\n\nStarting to create disk image. This may take a while..\n'
$HOME/QtSDK/Desktop/Qt/4.8.1/gcc/bin/macdeployqt qgroundcontrol.app -dmg
macdeployqt qgroundcontrol.app -dmg
rm -rf qgroundcontrol.app
echo -e '\n\n QGroundControl .DMG file is now ready for publishing\n'
Name "QGroundcontrol"
OutFile "qgroundcontrol-installer-win32.exe"
InstallDir $PROGRAMFILES\qgroundcontrol
Page license
......@@ -11,12 +9,12 @@ Page instfiles
UninstPage uninstConfirm
UninstPage instfiles
LicenseData ..\license.txt
LicenseData license.txt
Section ""
SetOutPath $INSTDIR
File /r ..\release\*.*
File /r release\*.*
WriteUninstaller $INSTDIR\QGroundControl_uninstall.exe
SectionEnd
......
......@@ -28,6 +28,11 @@
#include <qmath.h>
// These pragmas are local modifications to this third party library to silence warnings
#ifdef Q_OS_LINUX
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-but-set-variable"
#endif
namespace projections {
LKS94Projection::LKS94Projection():MinLatitude (53.33 ), MaxLatitude (56.55 ), MinLongitude (20.22 ),
......@@ -787,3 +792,8 @@ Size LKS94Projection::GetTileMatrixMaxXY(int const& zoom)
}
}
#ifdef Q_OS_LINUX
#pragma GCC diagnostic pop
#endif
......@@ -57,6 +57,16 @@ Point MercatorProjectionYandex::FromLatLngToPixel(double lat, double lng, const
return ret;
}
// These pragmas are local modifications to this third party library to silence warnings
#ifdef Q_OS_LINUX
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-but-set-variable"
#elif defined(Q_OS_MAC)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-variable"
#endif
internals::PointLatLng MercatorProjectionYandex::FromPixelToLatLng(const int &x, const int &y, const int &zoom)
{
Size s = GetTileMatrixSizePixel(zoom);
......@@ -82,6 +92,11 @@ internals::PointLatLng MercatorProjectionYandex::FromPixelToLatLng(const int &x,
return ret;
}
#ifndef Q_OS_WIN
#pragma GCC diagnostic pop
#endif
double MercatorProjectionYandex::Clip(const double &n, const double &minValue, const double &maxValue) const
{
return qMin(qMax(n, minValue), maxValue);
......
/*!
* \file qextserialenumerator.h
* \author Michal Policht
* \see QextSerialEnumerator
*/
#ifndef _QEXTSERIALENUMERATOR_H_
#define _QEXTSERIALENUMERATOR_H_
#include <QtCore/qglobal.h>
//#ifdef QEXTSERIALPORT_LIB
//# define QEXTSERIALPORT_EXPORT Q_DECL_EXPORT
//#else
//# define QEXTSERIALPORT_EXPORT Q_DECL_IMPORT
//#endif
#define QEXTSERIALPORT_EXPORT
#include <QString>
#include <QList>
#include <QObject>
//#include "qextserialport_global.h"
#ifdef Q_OS_WIN
#include <windows.h>
#include <setupapi.h>
#include <dbt.h>
#endif /*Q_OS_WIN*/
#ifdef Q_OS_MAC
#include <IOKit/usb/IOUSBLib.h>
#endif
/*!
* Structure containing port information.
*/
struct QextPortInfo {
QString portName; ///< Port name.
QString physName; ///< Physical name.
QString friendName; ///< Friendly name.
QString enumName; ///< Enumerator name.
int vendorID; ///< Vendor ID.
int productID; ///< Product ID
};
#ifdef Q_OS_WIN
#ifdef QT_GUI_LIB
#include <QWidget>
class QextSerialEnumerator;
class QextSerialRegistrationWidget : public QWidget
{
Q_OBJECT
public:
QextSerialRegistrationWidget( QextSerialEnumerator* qese ) {
this->qese = qese;
}
~QextSerialRegistrationWidget( ) { }
protected:
QextSerialEnumerator* qese;
bool winEvent( MSG* message, long* result );
};
#endif // QT_GUI_LIB
#endif // Q_OS_WIN
/*!
Provides list of ports available in the system.
\section Usage
To poll the system for a list of connected devices, simply use getPorts(). Each
QextPortInfo structure will populated with information about the corresponding device.
\b Example
\code
QList<QextPortInfo> ports = QextSerialEnumerator::getPorts();
foreach( QextPortInfo port, ports ) {
// inspect port...
}
\endcode
To enable event-driven notification of device connection events, first call
setUpNotifications() and then connect to the deviceDiscovered() and deviceRemoved()
signals. Event-driven behavior is currently available only on Windows and OS X.
\b Example
\code
QextSerialEnumerator* enumerator = new QextSerialEnumerator();
connect(enumerator, SIGNAL(deviceDiscovered(const QextPortInfo &)),
myClass, SLOT(onDeviceDiscovered(const QextPortInfo &)));
connect(enumerator, SIGNAL(deviceRemoved(const QextPortInfo &)),
myClass, SLOT(onDeviceRemoved(const QextPortInfo &)));
\endcode
\section Credits
Windows implementation is based on Zach Gorman's work from
<a href="http://www.codeproject.com">The Code Project</a> (http://www.codeproject.com/system/setupdi.asp).
OS X implementation, see
http://developer.apple.com/documentation/DeviceDrivers/Conceptual/AccessingHardware/AH_Finding_Devices/chapter_4_section_2.html
\author Michal Policht, Liam Staskawicz
*/
class QEXTSERIALPORT_EXPORT QextSerialEnumerator : public QObject
{
Q_OBJECT
public:
QextSerialEnumerator( );
~QextSerialEnumerator( );
#ifdef Q_OS_WIN
LRESULT onDeviceChangeWin( WPARAM wParam, LPARAM lParam );
private:
/*!
* Get value of specified property from the registry.
* \param key handle to an open key.
* \param property property name.
* \return property value.
*/
static QString getRegKeyValue(HKEY key, LPCTSTR property);
/*!
* Get specific property from registry.
* \param devInfo pointer to the device information set that contains the interface
* and its underlying device. Returned by SetupDiGetClassDevs() function.
* \param devData pointer to an SP_DEVINFO_DATA structure that defines the device instance.
* this is returned by SetupDiGetDeviceInterfaceDetail() function.
* \param property registry property. One of defined SPDRP_* constants.
* \return property string.
*/
static QString getDeviceProperty(HDEVINFO devInfo, PSP_DEVINFO_DATA devData, DWORD property);
/*!
* Search for serial ports using setupapi.
* \param infoList list with result.
*/
static void setupAPIScan(QList<QextPortInfo> & infoList);
void setUpNotificationWin( );
static bool getDeviceDetailsWin( QextPortInfo* portInfo, HDEVINFO devInfo,
PSP_DEVINFO_DATA devData, WPARAM wParam = DBT_DEVICEARRIVAL );
static void enumerateDevicesWin( const GUID & guidDev, QList<QextPortInfo>* infoList );
bool matchAndDispatchChangedDevice(const QString & deviceID, const GUID & guid, WPARAM wParam);
#ifdef QT_GUI_LIB
QextSerialRegistrationWidget* notificationWidget;
#endif
#endif /*Q_OS_WIN*/
#ifdef Q_OS_UNIX
#ifdef Q_OS_MAC
private:
/*!
* Search for serial ports using IOKit.
* \param infoList list with result.
*/
static void scanPortsOSX(QList<QextPortInfo> & infoList);
static void iterateServicesOSX(io_object_t service, QList<QextPortInfo> & infoList);
static bool getServiceDetailsOSX( io_object_t service, QextPortInfo* portInfo );
void setUpNotificationOSX( );
void onDeviceDiscoveredOSX( io_object_t service );
void onDeviceTerminatedOSX( io_object_t service );
friend void deviceDiscoveredCallbackOSX( void *ctxt, io_iterator_t serialPortIterator );
friend void deviceTerminatedCallbackOSX( void *ctxt, io_iterator_t serialPortIterator );
IONotificationPortRef notificationPortRef;
#else // Q_OS_MAC
private:
/*!
* Search for serial ports on unix.
* \param infoList list with result.
*/
static void scanPortsNix(QList<QextPortInfo> & infoList);
#endif // Q_OS_MAC
#endif /* Q_OS_UNIX */
public:
/*!
Get list of ports.
\return list of ports currently available in the system.
*/
static QList<QextPortInfo> getPorts();
/*!
Enable event-driven notifications of board discovery/removal.
*/
void setUpNotifications( );
signals:
/*!
A new device has been connected to the system.
setUpNotifications() must be called first to enable event-driven device notifications.
Currently only implemented on Windows and OS X.
\param info The device that has been discovered.
*/
void deviceDiscovered( const QextPortInfo & info );
/*!
A device has been disconnected from the system.
setUpNotifications() must be called first to enable event-driven device notifications.
Currently only implemented on Windows and OS X.
\param info The device that was disconnected.
*/
void deviceRemoved( const QextPortInfo & info );
};
#endif /*_QEXTSERIALENUMERATOR_H_*/
This diff is collapsed.
#include "qextserialenumerator.h"
#include <QDebug>
#include <QMetaType>
#include <QStringList>
#include <QDir>
QextSerialEnumerator::QextSerialEnumerator( )
{
if( !QMetaType::isRegistered( QMetaType::type("QextPortInfo") ) )
qRegisterMetaType<QextPortInfo>("QextPortInfo");
}
QextSerialEnumerator::~QextSerialEnumerator( )
{
}
QList<QextPortInfo> QextSerialEnumerator::getPorts()
{
QList<QextPortInfo> infoList;
#ifdef Q_OS_LINUX
QStringList portNamePrefixes, portNameList;
portNamePrefixes << "ttyS*"; // list normal serial ports first
QDir dir("/dev");
portNameList = dir.entryList(portNamePrefixes, (QDir::System | QDir::Files), QDir::Name);
// remove the values which are not serial ports for e.g. /dev/ttysa
for (int i = 0; i < portNameList.size(); i++) {
bool ok;
QString current = portNameList.at(i);
// remove the ttyS part, and check, if the other part is a number
current.remove(0,4).toInt(&ok, 10);
if (!ok) {
portNameList.removeAt(i);
i--;
}
}
// get the non standard serial ports names
// (USB-serial, bluetooth-serial, 18F PICs, and so on)
// if you know an other name prefix for serial ports please let us know
portNamePrefixes.clear();
portNamePrefixes << "ttyACM*" << "ttyUSB*" << "rfcomm*";
portNameList.append(dir.entryList(portNamePrefixes, (QDir::System | QDir::Files), QDir::Name));
foreach (QString str , portNameList) {
QextPortInfo inf;
inf.physName = "/dev/"+str;
inf.portName = str;
if (str.contains("ttyS")) {
inf.friendName = "Serial port "+str.remove(0, 4);
}
else if (str.contains("ttyUSB")) {
inf.friendName = "USB-serial adapter "+str.remove(0, 6);
}
else if (str.contains("rfcomm")) {
inf.friendName = "Bluetooth-serial adapter "+str.remove(0, 6);
}
inf.enumName = "/dev"; // is there a more helpful name for this?
infoList.append(inf);
}
#else
qCritical("Enumeration for POSIX systems (except Linux) is not implemented yet.");
#endif
return infoList;
}
void QextSerialEnumerator::setUpNotifications( )
{
qCritical("Notifications for *Nix/FreeBSD are not implemented yet");
}
#include "qextserialenumerator.h"
#include <QDebug>
#include <QMetaType>
#include <objbase.h>
#include <initguid.h>
//#include "qextserialport.h"
#include <QRegExp>
#ifdef Q_OS_WIN
#ifndef _MSC_VER
#include <windows.h>
#include <dbt.h>
#include <QtCore/qglobal.h>
#endif
#endif
QextSerialEnumerator::QextSerialEnumerator( )
{
if( !QMetaType::isRegistered( QMetaType::type("QextPortInfo") ) )
qRegisterMetaType<QextPortInfo>("QextPortInfo");
#if (defined QT_GUI_LIB)
notificationWidget = 0;
#endif // Q_OS_WIN
}
QextSerialEnumerator::~QextSerialEnumerator( )
{
#if (defined QT_GUI_LIB)
if( notificationWidget )
delete notificationWidget;
#endif
}
// see http://msdn.microsoft.com/en-us/library/ms791134.aspx for list of GUID classes
#ifndef GUID_DEVCLASS_PORTS
DEFINE_GUID(GUID_DEVCLASS_PORTS, 0x4D36E978, 0xE325, 0x11CE, 0xBF, 0xC1, 0x08, 0x00, 0x2B, 0xE1, 0x03, 0x18 );
#endif
/* Gordon Schumacher's macros for TCHAR -> QString conversions and vice versa */
#ifdef UNICODE
#define QStringToTCHAR(x) (wchar_t*) x.utf16()
#define PQStringToTCHAR(x) (wchar_t*) x->utf16()
#define TCHARToQString(x) QString::fromUtf16((ushort*)(x))
#define TCHARToQStringN(x,y) QString::fromUtf16((ushort*)(x),(y))
#else
#define QStringToTCHAR(x) x.local8Bit().constData()
#define PQStringToTCHAR(x) x->local8Bit().constData()
#define TCHARToQString(x) QString::fromLocal8Bit((x))
#define TCHARToQStringN(x,y) QString::fromLocal8Bit((x),(y))
#endif /*UNICODE*/
//static
QString QextSerialEnumerator::getRegKeyValue(HKEY key, LPCTSTR property)
{
DWORD size = 0;
DWORD type;
RegQueryValueEx(key, property, NULL, NULL, NULL, & size);
BYTE* buff = new BYTE[size];
QString result;
if( RegQueryValueEx(key, property, NULL, &type, buff, & size) == ERROR_SUCCESS )
result = TCHARToQString(buff);
RegCloseKey(key);
delete [] buff;
return result;
}
//static
QString QextSerialEnumerator::getDeviceProperty(HDEVINFO devInfo, PSP_DEVINFO_DATA devData, DWORD property)
{
DWORD buffSize = 0;
SetupDiGetDeviceRegistryProperty(devInfo, devData, property, NULL, NULL, 0, & buffSize);
BYTE* buff = new BYTE[buffSize];
SetupDiGetDeviceRegistryProperty(devInfo, devData, property, NULL, buff, buffSize, NULL);
QString result = TCHARToQString(buff);
delete [] buff;
return result;
}
QList<QextPortInfo> QextSerialEnumerator::getPorts()
{
QList<QextPortInfo> ports;
enumerateDevicesWin(GUID_DEVCLASS_PORTS, &ports);
return ports;
}
void QextSerialEnumerator::enumerateDevicesWin( const GUID & guid, QList<QextPortInfo>* infoList )
{
HDEVINFO devInfo;
if( (devInfo = SetupDiGetClassDevs(&guid, NULL, NULL, DIGCF_PRESENT)) != INVALID_HANDLE_VALUE)
{
SP_DEVINFO_DATA devInfoData;
devInfoData.cbSize = sizeof(SP_DEVINFO_DATA);
for(int i = 0; SetupDiEnumDeviceInfo(devInfo, i, &devInfoData); i++)
{
QextPortInfo info;
info.productID = info.vendorID = 0;
getDeviceDetailsWin( &info, devInfo, &devInfoData );
infoList->append(info);
}
SetupDiDestroyDeviceInfoList(devInfo);
}
}
#ifdef QT_GUI_LIB
bool QextSerialRegistrationWidget::winEvent( MSG* message, long* result )
{
if ( message->message == WM_DEVICECHANGE ) {
qese->onDeviceChangeWin( message->wParam, message->lParam );
*result = 1;
return true;
}
return false;
}
#endif
void QextSerialEnumerator::setUpNotifications( )
{
#ifdef QT_GUI_LIB
if(notificationWidget)
return;
notificationWidget = new QextSerialRegistrationWidget(this);
DEV_BROADCAST_DEVICEINTERFACE dbh;
ZeroMemory(&dbh, sizeof(dbh));
dbh.dbcc_size = sizeof(dbh);
dbh.dbcc_devicetype = DBT_DEVTYP_DEVICEINTERFACE;
CopyMemory(&dbh.dbcc_classguid, &GUID_DEVCLASS_PORTS, sizeof(GUID));
if( RegisterDeviceNotification( notificationWidget->winId( ), &dbh, DEVICE_NOTIFY_WINDOW_HANDLE ) == NULL)
qWarning() << "RegisterDeviceNotification failed:" << GetLastError();
// setting up notifications doesn't tell us about devices already connected
// so get those manually
foreach( QextPortInfo port, getPorts() )
emit deviceDiscovered( port );
#else
qWarning("QextSerialEnumerator: GUI not enabled - can't register for device notifications.");
#endif // QT_GUI_LIB
}
LRESULT QextSerialEnumerator::onDeviceChangeWin( WPARAM wParam, LPARAM lParam )
{
if ( DBT_DEVICEARRIVAL == wParam || DBT_DEVICEREMOVECOMPLETE == wParam )
{
PDEV_BROADCAST_HDR pHdr = (PDEV_BROADCAST_HDR)lParam;
if( pHdr->dbch_devicetype == DBT_DEVTYP_DEVICEINTERFACE )
{
PDEV_BROADCAST_DEVICEINTERFACE pDevInf = (PDEV_BROADCAST_DEVICEINTERFACE)pHdr;
// delimiters are different across APIs...change to backslash. ugh.
QString deviceID = TCHARToQString(pDevInf->dbcc_name).toUpper().replace("#", "\\");
matchAndDispatchChangedDevice(deviceID, GUID_DEVCLASS_PORTS, wParam);
}
}
return 0;
}
bool QextSerialEnumerator::matchAndDispatchChangedDevice(const QString & deviceID, const GUID & guid, WPARAM wParam)
{
bool rv = false;
DWORD dwFlag = (DBT_DEVICEARRIVAL == wParam) ? DIGCF_PRESENT : DIGCF_ALLCLASSES;
HDEVINFO devInfo;
if( (devInfo = SetupDiGetClassDevs(&guid,NULL,NULL,dwFlag)) != INVALID_HANDLE_VALUE )
{
SP_DEVINFO_DATA spDevInfoData;
spDevInfoData.cbSize = sizeof(SP_DEVINFO_DATA);
for(int i=0; SetupDiEnumDeviceInfo(devInfo, i, &spDevInfoData); i++)
{
DWORD nSize=0 ;
TCHAR buf[MAX_PATH];
if ( SetupDiGetDeviceInstanceId(devInfo, &spDevInfoData, buf, MAX_PATH, &nSize) &&
deviceID.contains(TCHARToQString(buf))) // we found a match
{
rv = true;
QextPortInfo info;
info.productID = info.vendorID = 0;
getDeviceDetailsWin( &info, devInfo, &spDevInfoData, wParam );
if( wParam == DBT_DEVICEARRIVAL )
emit deviceDiscovered(info);
else if( wParam == DBT_DEVICEREMOVECOMPLETE )
emit deviceRemoved(info);
break;
}
}
SetupDiDestroyDeviceInfoList(devInfo);
}
return rv;
}
bool QextSerialEnumerator::getDeviceDetailsWin( QextPortInfo* portInfo, HDEVINFO devInfo, PSP_DEVINFO_DATA devData, WPARAM wParam )
{
portInfo->friendName = getDeviceProperty(devInfo, devData, SPDRP_FRIENDLYNAME);
if( wParam == DBT_DEVICEARRIVAL)
portInfo->physName = getDeviceProperty(devInfo, devData, SPDRP_PHYSICAL_DEVICE_OBJECT_NAME);
portInfo->enumName = getDeviceProperty(devInfo, devData, SPDRP_ENUMERATOR_NAME);
QString hardwareIDs = getDeviceProperty(devInfo, devData, SPDRP_HARDWAREID);
HKEY devKey = SetupDiOpenDevRegKey(devInfo, devData, DICS_FLAG_GLOBAL, 0, DIREG_DEV, KEY_READ);
QRegExp rx("^COM(\\d+)");
QString fullName(getRegKeyValue(devKey, TEXT("PortName")));
if(fullName.contains(rx)) {
int portnum = rx.cap(1).toInt();
if(portnum > 9) // COM ports greater than 9 need \\.\ prepended
fullName.prepend("\\\\.\\");
}
portInfo->portName = fullName;
QRegExp idRx("VID_(\\w+)&PID_(\\w+)");
if( hardwareIDs.toUpper().contains(idRx) )
{
bool dummy;
portInfo->vendorID = idRx.cap(1).toInt(&dummy, 16);
portInfo->productID = idRx.cap(2).toInt(&dummy, 16);
//qDebug() << "got vid:" << vid << "pid:" << pid;
}
return true;
}
......@@ -533,6 +533,15 @@ QwtRasterData::ContourLines QwtPlotSpectrogram::renderContourLines(
d_data->contourLevels, d_data->conrecAttributes );
}
// These pragmas are local modifications to this third party library to silence warnings
#ifdef Q_OS_LINUX
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-but-set-variable"
#elif defined(Q_OS_MAC)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-variable"
#endif
/*!
Paint the contour lines
......@@ -578,6 +587,10 @@ void QwtPlotSpectrogram::drawContourLines(QPainter *painter,
}
}
#ifndef Q_OS_WIN
#pragma GCC diagnostic pop
#endif
/*!
\brief Draw the spectrogram
......
......@@ -85,8 +85,19 @@ public:
public slots:
void moveBy(double x, double y);
// These pragmas are local modifications to this third party library to silence warnings
#ifndef Q_OS_WIN
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Woverloaded-virtual"
#endif
virtual void move(double x, double y);
#ifndef Q_OS_WIN
#pragma GCC diagnostic pop
#endif
virtual void zoom(const QwtDoubleRect &);
virtual void zoom(int up);
......
......@@ -55,4 +55,4 @@ unix:!symbian {
}
}
HEADERS += $$PUBLIC_HEADERS $$PRIVATE_HEADERS
HEADERS *= $$PUBLIC_HEADERS $$PRIVATE_HEADERS
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[])
{
using namespace TNX;
QCoreApplication a(argc, argv);
std::cout << "Serial port echo example with polling model, Copyright (c) 2010 Inbiza Systems Inc." << std::endl;
std::cout << "Created by Inbiza Labs <labs@inbiza.com>" << 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));
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;
}
##
## 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 examples.pri
## www.inbiza.com
##
include(../app.pri)
# default to console (individual programs can always override this if needed)
CONFIG += console
CONFIG -= app_bundle
QT -= gui
##
## 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 examples.pro
## www.inbiza.com
##
TEMPLATE = subdirs
SUBDIRS += \
tranceiver \
serial2tcpbridge \
echo_eventmode \
echo_pollingmode
/*
* 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 <QTcpSocket>
#include <QTcpServer>
#include <QSerialPort>
#include "host.h"
Host::Host(const QString &serPort, int tcpPort, QObject *parent)
: QObject(parent), tcpPort_(tcpPort), tcpSocket_(NULL)
{
using TNX::QSerialPort;
serialPort_ = new QSerialPort(serPort, "9600,8,N,1", this);
tcpServer_ = new QTcpServer(this);
}
Host::~Host()
{
stop();
}
int Host::start()
{
// deal with serial port
if ( serialPort_->open() ) {
serialPort_->flushInBuffer();
serialPort_->flushOutBuffer();
}
else {
qFatal("Cannot open serial port: \"%s\". Giving up.", qPrintable(serialPort_->errorString()));
return -1;
}
connect(serialPort_, SIGNAL(readyRead()), SLOT(onDataReceivedSerial()));
// deal with tcp port
std::cout << "Waiting for connection on tcp port " << tcpPort_ << std::endl;
if ( tcpServer_->listen(QHostAddress::Any, tcpPort_) ) {
std::cout << "Listening on " << qPrintable(tcpServer_->serverAddress().toString()) << ":" << tcpServer_->serverPort() << std::endl;
connect(tcpServer_, SIGNAL(newConnection()), SLOT(onNewTcpConnection()));
}
else {
qFatal("Cannot listening tcp port: \"%s\". Giving up.", qPrintable(tcpServer_->errorString()));
return -1;
}
return 0;
}
int Host::stop()
{
serialPort_->close();
disconnect(serialPort_, SIGNAL(readyRead()), this, SLOT(onDataReceivedSerial()));
tcpServer_->close();
disconnect(tcpServer_, SIGNAL(newConnection()), this, SLOT(onNewTcpConnection()));
return 0;
}
void Host::onDataReceivedNetwork()
{
serialPort_->write(tcpSocket_->read(2048));
}
void Host::onDataReceivedSerial()
{
if ( tcpSocket_->state() == QAbstractSocket::ConnectedState ) {
tcpSocket_->write(serialPort_->read(2048));
}
}
void Host::onNewTcpConnection()
{
tcpSocket_ = tcpServer_->nextPendingConnection();
connect(tcpSocket_, SIGNAL(readyRead()), SLOT(onDataReceivedNetwork()));
std::cout << "Connection is established with " << qPrintable(tcpSocket_->peerAddress().toString()) << std::endl;
}
#include "qportsettings.h"
#include "qserialportnative.h"
#include "qserialport.h"
This diff is collapsed.
libQtSerialPort.debug.so.1.0.0
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment