Skip to content


Add sip files for gps connection. Patch from Marcel Huber, ticket #4826
Browse files Browse the repository at this point in the history
  • Loading branch information
mhugent committed Feb 1, 2012
1 parent e23450e commit 83f95b8
Show file tree
Hide file tree
Showing 7 changed files with 157 additions and 0 deletions.
2 changes: 2 additions & 0 deletions python/CMakeLists.txt
Expand Up @@ -29,6 +29,8 @@ INCLUDE_DIRECTORIES(

Expand Down
6 changes: 6 additions & 0 deletions python/core/core.sip
Expand Up @@ -92,3 +92,9 @@
%Include qgsnetworkaccessmanager.sip

%Include symbology-ng-core.sip

%Include qgsgpsconnection.sip
%Include qgsgpsconnectionregistry.sip
%Include qgsgpsdconnection.sip
%Include qgsnmeaconnection.sip
%Include qgsgpsdetector.sip
71 changes: 71 additions & 0 deletions python/core/qgsgpsconnection.sip
@@ -0,0 +1,71 @@
struct QgsSatelliteInfo {
#include <qgsgpsconnection.h>
int id;
bool inUse;
int elevation;
int azimuth;
int signal;

struct QgsGPSInformation {
#include <qgsgpsconnection.h>
double latitude;
double longitude;
double elevation;
double speed; //in km/h
double direction;
QList<QgsSatelliteInfo> satellitesInView;
double pdop;
double hdop;
double vdop;
QDateTime utcDateTime;
QChar fixMode;
int fixType;
int quality; // from GPGGA
int satellitesUsed; // from GPGGA
QChar status; // from GPRMC A,V
QList<int> satPrn; // list of SVs in use; needed for QgsSatelliteInfo.inUse and other uses
bool satInfoComplete; // based on GPGSV sentences - to be used to determine when to graph signal and satellite position

/**Abstract base class for connection to a GPS device*/
class QgsGPSConnection: QObject {
#include <qgsgpsconnection.h>
enum Status {
NotConnected, Connected, DataReceived, GPSDataReceived

@param dev input device for the connection (e.g. serial device). The class takes ownership of the object
@param pollIntervall update intervall in milliseconds*/
QgsGPSConnection(QIODevice* dev);
virtual ~QgsGPSConnection();
/**Opens connection to device*/
bool connect();
/**Closes connection to device*/
bool close();

/**Sets the GPS source. The class takes ownership of the device class*/
void setSource(QIODevice* source);

/**Returns the status. Possible state are not connected, connected, data received*/
Status status() const;

/**Returns the current gps information (lat, lon, etc.)*/
QgsGPSInformation currentGPSInformation() const;

void stateChanged( const QgsGPSInformation& info );
void nmeaSentenceReceived(const QString& substring); // added to capture 'raw' data

protected slots:
/**Parse available data source content*/
virtual void parseData() = 0;
20 changes: 20 additions & 0 deletions python/core/qgsgpsconnectionregistry.sip
@@ -0,0 +1,20 @@
/**A singleton class to register / unregister existing GPS connections such that the information
is available to all classes and plugins*/
class QgsGPSConnectionRegistry {
#include <qgsgpsconnectionregistry.h>
static QgsGPSConnectionRegistry* instance();

/**Inserts a connection into the registry. The connection is owned by the registry class until it is unregistered again*/
void registerConnection(QgsGPSConnection* c);
/**Unregisters connection. The registry does no longer own the connection*/
void unregisterConnection(QgsGPSConnection* c);

QList<const QgsGPSConnection*> connectionList() const;

13 changes: 13 additions & 0 deletions python/core/qgsgpsdconnection.sip
@@ -0,0 +1,13 @@
/**Evaluates NMEA sentences coming from gpsd*/
class QgsGpsdConnection: QgsNMEAConnection {
#include "qgsgpsdconnection.h"
QgsGpsdConnection(QString host, qint16 port, QString device);

private slots:
void connected();
void error(QAbstractSocket::SocketError);
20 changes: 20 additions & 0 deletions python/core/qgsgpsdetector.sip
@@ -0,0 +1,20 @@
// Class to detect the GPS port
class QgsGPSDetector: QObject {
#include "qgsgpsdetector.h"
QgsGPSDetector(QString portName);

static QList<QPair<QString, QString> > availablePorts();

public slots:
void advance();
void detected(const QgsGPSInformation&);
void connDestroyed(QObject *);

void detected( QgsGPSConnection * );
void detectionFailed();
25 changes: 25 additions & 0 deletions python/core/qgsnmeaconnection.sip
@@ -0,0 +1,25 @@
/**Evaluates NMEA sentences coming from a GPS device*/
class QgsNMEAConnection: QgsGPSConnection {
#include "qgsnmeaconnection.h"
QgsNMEAConnection(QIODevice *dev);

//bool poll( QgsGPSInformation& info, int maxTime );

protected slots:
/**Parse available data source content*/
void parseData();

/**Splits mStringBuffer into sentences and calls libnmea*/
void processStringBuffer();
//handle the different sentence type
void processGGASentence(const char* data, int len);
void processRMCSentence(const char* data, int len);
void processGSVSentence(const char* data, int len);
void processVTGSentence(const char* data, int len);
void processGSASentence(const char* data, int len);

0 comments on commit 83f95b8

Please sign in to comment.