I intended this more as a learning experience, but as it corrects several defects in other gps/gis programs, I am turning it loose on the world under same terms as gpsd, i.e. under the BSD license. Readers may find it useful for studying GTK+ programming (or not…) as well as libgps programming (again, or not…).
I use this as I travel to keep an eye on altitude, speed and quality of the fix, none of which is readily available in other GPS display programs I use. Here, "readily available" means in large enough font that I can glance at the laptop while I drive and read it without squinting.
Requirements
Gnome-gps is designed to work with gpsd 3.0 et seq., gps protocol version 5.0 and up. You should be able to install a recent version of gpsd from your distribution's repositories. Or you may prefer the head version of gpsd from the git repo. Compiling gnome-gps will require several development packages. See the README file for details.
Gnome-gps identifies itself like so:
charles@yendi:~$ gnome-gps -V gnome-gps: Copyright © 2009-2011 Charles Curley This program is released under the same terms as gpsd itself, i.e. under the BSD License. See the file Copying in the gpsd distribution. This program comes with ABSOLUTELY NO WARRANTY. 0.91, compiled for gpsd API version 5.0. Usage: gnome-gps [-d d] [-m] [-k] [-p port] [-u] [-v] [-V] [host] charles@yendi:~$
Running it in verbose mode reveals, among other things, GPSD version: 3.0~dev Rev: release-2.96-631-g43a0117, Protocol 3.4. There is a compile time check for gpsd API 5.0 or greater.
I compile and run this on Debian but any recent Linux or Unix system that runs GTK and gpsd should do.
Features
There are several features common to gps display programs, like the ability to display data in various units. The program can save settings to a resource file, a dot file named after the program. (If you rename the executable, you change the name of the dot file that executable will look for.)
One thing that is unusual about this program is that most of the time it uses a progress bar to show the relative proportion of visible satellites and the number used in the fix. It also uses the progress bar for user information, such as announcing when it makes a connection to gpsd.
The program doesn't display the quality of the fix as text. Rather, it changes the background color:
- Grey, no gpsd daemon.
- Red, no fix or some other problem.
- Yellow, two dimensional fix.
- Green, three dimensional fix.
Your GPS receiver may send a bogus time when it has just fired up. This program will display that bogus time.
The code detects the loss of a connection to gpsd, and puts an appropriate message into the progress bar and changes its color to grey. It may also will detect when gpsd has lost contact with the GPS receiver, and places a different appropriate message in the progress bar. It will recover once the fault is repaired. These features rely on code in the 5.0 protocol.
You can specify a font from the GUI. You can also force the program to attempt to reconnect to gpsd, or to another gpsd. Since recovery from loss of a connection should be automatic, the resynch option should be useful mainly to change the host and/or port of the gpsd connection. The defaults are "localhost" and the port indicated by the gpsd code at compile time, TCP port 2947.
No ./configure or ./autogen folderol. "make" is all you need.
Bugs
The window will expand nicely if the user selects a larger font. However, I haven't found out how to make it shrink when the user selects a smaller font. Workaround: manually resize it. Volunteers?
It would be nice if one could preserve the location of the window on the screen in the resource file. Volunteers?
Much as I dislike Gnome's pseudo-registry, it might be nice to move to that to preserve options.
Internationalization: there is none.
Not a bug yet, but this program is GTK2 compliant, not GTK3.
Options
A somewhat more detailed look at the options:
- [-d d] ("degrees") Specify display of lat and long in one of d: degrees and decimal degrees (ddd.ddddd), m: degrees, minutes and decimal minutes (ddd mm.mmmm), s: degrees, minutes, seconds, and decimal seconds (dd mm ss.ss).
- [-m] ("metric") Set metric units.
- [-k] ("knots") Set the speed unit to knots, others to appropriate US measurements.
- [-p port] Specify the port at which to attach. The default is the gpsd standard, as provided by the gpsd code at compilation.
- [-u] ("US") Set units to US units, including statutory miles.
- [-v] ("Verbose") Set verbose mode: print lots of stuff to stdout, including fixes.
- [-V] ("Version") Print out the version and other information, and exit.
- [host] Specify an optional host. The default is "localhost".
Once you have set these options, using command line switches as above, or from the menus, you can preserve them with control s, or, using the mouse, File -> Save.
The Code
The code is available on github.
Notes on specific files.
The Icon File
The icon code, "icon.image.c". I took a screen capture of the program running. I then generated the C source with:
gdk-pixbuf-csource gnome-gps.logo.png > icon.image.c
I then removed the keyword "static" and added a #include for <gtk/gtk.h> and added the file to the make file.
Originally published Sunday, 2010-05-09 15:11 MDT. Updated July 2011.