3(3)

NAME
libgpsd - service library for GPS applications

SYNOPSIS

C:

#include <gpsd.h>

struct gps_session_t * gpsd_init (char * dgpsserver);

int gpsd_activate (struct gps_session_t * session);

void gpsd_deactivate (struct gps_session_t * session);

int gpsd_poll (struct gps_session_t * session);

void gpsd_wrap (struct gps_session_t * session);

void gpsd_report (int d, const char * fmt, ...);

Python:

import gpsd

session = gpsd.gpsd(device="/dev/gps", dgps=None, logger=None) session.activate()

session.deactivate()

session.poll()

del session

DESCRIPTION

libgps is a service library which supports querying GPS devices; link it with the linker option -lgps. There are two interfaces supported in it; one high-level interface that goes through gpsd(1) and is intended for concurrent use by several applications, and one low-level interface that speaks directly with the serial or USB device to which the GPS is attached. This page describes the low-level interface, which gpsd(1) itself uses. See gpsd(3) for a description of the high-level interface, which is almost certainly what you want.

Calling gpsd_init() initializes a session structure to hold the data collected by the GPS.

You must specify a device type by key letter; to list key letters, run gpsd -h. It is generally safe to specify 'n', as most modern GPSes speak NMEA. (The Python binding no longer requires setting a device type; this is a future direction for the C binding)

You may optionally specify a DGPS server, either as a string containing a server name or a string containining server name followed by a colon and a port name or number. To specify no DGPS, pass the null pointer.

After the session structure has been set up, you may modify some of its members.

gpsd_device
    This member should hold the path name of the device; it defaults to /dev/gps.

baudrate
    Communication speed in bits per second. The default is set by the driver type. For NMEA devices, the library automatically hunts through all plausible baud rates, stoppong on the one where it sees valid NMEA

raw_hook
    A hook function to be executed on each NMEA sentence as it is read from the GPS. The data from non-NMEA GPSes like the EarthMate will be translated to an NMEA sentence before being passed to the hook.

gpsd_activate() initializes the connection to the GPS. gpsd_deactivate() closes the connection. These functions are provided so that long-running programs can release a connection when there is no activity requiring the GPS, and re-acquire it later.

gpsd_poll() queries the GPS and updates the part of the session structure that holds position, speed, GPS signal quality, and other data returned by the GPS. It returns the number of characters waiting (-1 if the GPS is inaccessible)

gpsd_wrap() ends the session, implicitly performing a gpsd_deactivate().

The calling application must define one additional function: gpsd_report(). The library will use this to issue ordinary status messages. Use first argument of 0 for errors, 1 for ordinary status messages, and 2 or higher for debugging messages.

The Python implementation supports the same facilities as the C library, but only for straight NMEA devices with a 1-second send cycle (no Zodiac or Garmin binary-protocol support). gps_init() is replaced by the initialization of a gpsd session object; the other calls are methods of that object. Resources within the session object will be properly released when it is garbage-collected.

SEE ALSO

 gpsd(1) libgpsd(3)

AUTHOR

Eric S. Raymond <esr@thyrsus.com> based partly on earlier work by Remco Treffkorn, Derrick Brashear, and Russ Nelson.