A simple C++ GPS class

24 01 2008

The gpsd library is really good to get information from your GPS device. But it’s C++ interface is really poor. For that reason I wrote a C++ wrapper with more features. It needs libsigc++ and pthread to compile. The licence is BSD. Have fun with it.

Here are the files:
GPSConnection.h
GPSConnection.cpp

See how easy it is to use the class:

void onGPSData (struct gps_data_t *gpsData);
GPSConnection gpsCon;

if (gpsCon.open ("localhost", "2947"))
{
  gpsCon.query ("r\n");   // activate raw NMEA protocol
  gpsCon.query ("w+\n");  // set watcher mode
  gpsCon.query ("j=1\n"); // smooth GPS data
  gpsCon.setSignaling (true);
}

gpsCon.signalData.connect (sigc::mem_fun (this, &Navigation::onGPSData));

void Navigation::onGPSData (struct gps_data_t *gpsData)
{
  if (gpsData->status == STATUS_FIX)
  {
    ...
  }
}

Copyright (C) 2008 Andreas Volz

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the “Software”), to
deal in the Software without restriction, including without limitation the
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
sell copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies of the Software and its Copyright notices. In addition publicly
documented acknowledgment must be given that this software has been used if no
source code of this software is made available publicly. This includes
acknowledgments in either Copyright notices, Manuals, Publicity and Marketing
documents or any documentation provided with any product containing this
software. This License does not apply to any software that links to the
libraries provided by this software (statically or dynamically), but only to
the software provided.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Advertisements

Actions

Information

2 responses

3 10 2012
Diego Aguilera

Is this project current? I am having trouble compiling. It says the library is missing. It is clearly there.

3 10 2012
andreasvolz

I think libgps may have changed API since this article. See here me latest version:
https://gitorious.org/openinfotainment/oisp/blobs/master/src/OISPNavigation_libosmscout/GPSConnection.cpp
https://gitorious.org/openinfotainment/oisp/blobs/master/src/OISPNavigation_libosmscout/GPSConnection.h

It’s part of my OpenInfotainment project:
https://gitorious.org/openinfotainment
https://sourceforge.net/projects/openinfo/

I just started uploading all sources. But feel free to try this newer version.

And if you say a library is missing please ensure to link against libgpsd!!

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s




%d bloggers like this: