13(3) GPSD Documentation 3(3)
2
3
4
6 libgpsd - service library for GPS applications
7
9 C:
10
11 #include <gpsd.h>
12
13
14 int gpsd_open_dgps(char * dgpsserver);
15
16 void gpsd_init(struct gps_device_t *session, struct * gps_context_t *,
17 char * device);
18
19 int gpsd_activate(struct gps_device_t *session);
20
21 void gpsd_deactivate(struct gps_device_t * session);
22
23 gps_mask_t gpsd_poll(struct gps_device_t * session);
24
25 void gpsd_wrap(struct gps_device_t * session);
26
27 void gpsd_report(int d, const char * fmt, ...);
28
30 libgpsd is a service library which supports querying GPS devices; link
31 it with the linker option -lgpsd. It is a set of low-level
32 device-handling calls, which gpsd(1) itself uses. See gpsd(3) for a
33 description of the high-level interface, which is almost certainly what
34 you want.
35
36 Calling gpsd_init() initializes a session structure to hold the data
37 collected by the GPS.
38
39 The second argument must be a context structure. The library will use
40 it for information that need to be shared between sessions; presently
41 this includes the leap-second correction and possibly a pointer to a
42 shared-memory segment used to communicate with the Network Time
43 Protocol daemon.
44
45 After the session structure has been set up, you may modify some of its
46 members.
47
48 gpsd_device
49 This member should hold the path name of the device.
50
51 baudrate
52 Communication speed in bits per second. For NMEA or SiRF devices,
53 the library automatically hunts through all plausible baud rates,
54 stopping on the one where it sees valid packets. By setting this
55 field you can designate a speed to be tried at the front of the
56 hunt queue
57
58 raw_hook
59 A hook function to be executed on each NMEA sentence or as it is
60 read from the GPS. The data from non-NMEA GPSes like the EarthMate
61 will be translated to an NMEA sentence before being passed to the
62 hook. Parameters are a pointer to a gps_data structure full of
63 parsed data, the sentence, and the length of the sentene..
64
65 gpsd_activate() initializes the connection to the GPS.
66 gpsd_deactivate() closes the connection. These functions are provided
67 so that long-running programs can release a connection when there is no
68 activity requiring the GPS, and re-acquire it later.
69
70 gpsd_poll() queries the GPS and updates the part of the session
71 structure that holds position, speed, GPS signal quality, and other
72 data returned by the GPS. It returns a mask describing which fields
73 have changed.
74
75 gpsd_wrap() ends the session, implicitly performing a
76 gpsd_deactivate().
77
78 The calling application must define one additional function:
79 gpsd_report(). The library will use this to issue ordinary status
80 messages. Use first argument of 0 for errors, 1 for ordinary status
81 messages, and 2 or higher for debugging messages.
82
83 The low-level functions do not allocate or free any dynamic storage.
84 They can thus be used in a long-running application (such as gpsd(8)
85 itself) with a guarantee that they won't cause memory leaks.
86
88 Writes to the context structure members are not guarded by a mutex.
89
91 gpsd(8), gps(1), libgps(3).
92
94 Eric S. Raymond <esr@thyrsus.com> based partly on earlier work by Remco
95 Treffkorn, Derrick Brashear, and Russ Nelson.
96
97
98
99The GPSD Project 14 Aug 2004 3(3)