Permalink
Show file tree
Hide file tree
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
[FEATURE] add gpsd support to live gps tracking
git-svn-id: http://svn.osgeo.org/qgis/trunk@14331 c8812cc2-4d05-0410-92ff-de0c093fc19c
- Loading branch information
jef
committed
Oct 4, 2010
1 parent
8ffd816
commit 7b1fc1b
Showing
7 changed files
with
481 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/*************************************************************************** | ||
qgsgpsdconnection.cpp - description | ||
--------------------- | ||
begin : October 4th, 2010 | ||
copyright : (C) 2010 by Jürgen E. Fischer, norBIT GmbH | ||
email : jef at norbit dot de | ||
***************************************************************************/ | ||
|
||
/*************************************************************************** | ||
* * | ||
* This program 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 2 of the License, or * | ||
* (at your option) any later version. * | ||
* * | ||
***************************************************************************/ | ||
|
||
#include "qgsgpsdconnection.h" | ||
#include "qgslogger.h" | ||
|
||
#include <QTcpSocket> | ||
|
||
QgsGpsdConnection::QgsGpsdConnection( QString host, qint16 port, QString device ) | ||
: QgsNMEAConnection( new QTcpSocket() ) | ||
, mDevice( device ) | ||
{ | ||
QTcpSocket *socket = qobject_cast< QTcpSocket * >( mSource ); | ||
|
||
QObject::connect( socket, SIGNAL( connected() ), this, SLOT( connected() ) ); | ||
QObject::connect( socket, SIGNAL( error( QAbstractSocket::SocketError ) ), this, SLOT( error( QAbstractSocket::SocketError ) ) ); | ||
socket->connectToHost( host, port ); | ||
} | ||
|
||
QgsGpsdConnection::~QgsGpsdConnection() | ||
{ | ||
//connection will be closed by base class | ||
QgsDebugMsg( "entered." ); | ||
} | ||
|
||
void QgsGpsdConnection::connected() | ||
{ | ||
QgsDebugMsg( "connected!" ); | ||
QTcpSocket *socket = qobject_cast< QTcpSocket * >( mSource ); | ||
socket->write( QString( "?WATCH={\"enable\":true,\"nmea\":true%1};" ).arg( mDevice.isEmpty() ? mDevice : QString( "\"device\":%1" ).arg( mDevice ) ).toUtf8() ); | ||
} | ||
|
||
void QgsGpsdConnection::error( QAbstractSocket::SocketError socketError ) | ||
{ | ||
QTcpSocket *socket = qobject_cast< QTcpSocket * >( mSource ); | ||
QgsDebugMsg( QString( "error: %1 %2" ).arg( socketError ).arg( socket->errorString() ) ); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/*************************************************************************** | ||
qgsgpsdconnection.h - description | ||
------------------- | ||
begin : October 4th, 2010 | ||
copyright : (C) 2010 by Jürgen E. Fischer, norBIT GmbH | ||
email : jef at norbit dot de | ||
***************************************************************************/ | ||
|
||
/*************************************************************************** | ||
* * | ||
* This program 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 2 of the License, or * | ||
* (at your option) any later version. * | ||
* * | ||
***************************************************************************/ | ||
|
||
#ifndef QGSGPSDCONNECTION_H | ||
#define QGSGPSDCONNECTION_H | ||
|
||
#include "qgsgpsdconnection.h" | ||
#include "qgsnmeaconnection.h" | ||
|
||
#include <QAbstractSocket> | ||
|
||
/**Evaluates NMEA sentences coming from gpsd*/ | ||
class CORE_EXPORT QgsGpsdConnection: public QgsNMEAConnection | ||
{ | ||
Q_OBJECT | ||
public: | ||
QgsGpsdConnection( QString host, qint16 port, QString device ); | ||
~QgsGpsdConnection(); | ||
|
||
private slots: | ||
void connected(); | ||
void error( QAbstractSocket::SocketError ); | ||
|
||
private: | ||
QString mDevice; | ||
}; | ||
|
||
#endif // QGSGPSDCONNECTION_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.