Contents of /trunk/src/gps.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 243 - (show annotations)
Mon Dec 14 20:07:54 2009 UTC (14 years, 4 months ago) by harbaum
File MIME type: text/plain
File size: 3973 byte(s)
Various search related bug fixes
1 /*
2 * Copyright (C) 2008 Till Harbaum <till@harbaum.org>.
3 *
4 * This file is based upon parts of gpsd/libgps
5 *
6 * This file is part of GPXView.
7 *
8 * GPXView is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation, either version 3 of the License, or
11 * (at your option) any later version.
12 *
13 * GPXView is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with GPXView. If not, see <http://www.gnu.org/licenses/>.
20 *
21 */
22
23 #ifndef GPS_H
24 #define GPS_H
25
26 #include "gpx.h"
27
28 #ifndef NAN
29 #define NAN (0.0/0.0)
30 #endif /* !NAN */
31
32 #define MAXCHANNELS 20
33 #define MAXTAGLEN 8 /* maximum length of sentence tag name */
34 #define MPS_TO_KNOTS 1.9438445 /* Meters per second to knots */
35
36 struct gps_fix_t {
37 int mode; /* Mode of fix */
38 #define MODE_NOT_SEEN 0 /* mode update not seen yet */
39 #define MODE_NO_FIX 1 /* none */
40 #define MODE_2D 2 /* good for latitude/longitude */
41 #define MODE_3D 3 /* good for altitude/climb too */
42 pos_t pos; /* Latitude/Longitude in degrees (valid if mode >= 2) */
43 float eph; /* Horizontal position uncertainty, meters */
44 float track; /* Course made good (relative to true north) */
45 };
46
47 typedef unsigned int gps_mask_t;
48
49 struct gps_data_t {
50 gps_mask_t set; /* has field been set since this was last cleared? */
51 #define LATLON_SET 0x00000008u
52 #define SPEED_SET 0x00000020u
53 #define TRACK_SET 0x00000040u
54 #define STATUS_SET 0x00000100u
55 #define MODE_SET 0x00000200u
56 #define HERR_SET 0x00008000u
57 #define SATELLITE_SET 0x00040000u
58 struct gps_fix_t fix; /* accumulated PVT data */
59
60 /* GPS status -- always valid */
61 int status; /* Do we have a fix? */
62 #define STATUS_NO_FIX 0 /* no */
63 #define STATUS_FIX 1 /* yes, without DGPS */
64 #define STATUS_DGPS_FIX 2 /* yes, with DGPS */
65
66 /* precision of fix -- valid if satellites_used > 0 */
67 int satellites_used; /* Number of satellites used in solution */
68 int used[MAXCHANNELS]; /* PRNs of satellites used in solution */
69
70 /* satellite status -- valid when satellites > 0 */
71 int satellites; /* # of satellites in view */
72 int PRN[MAXCHANNELS]; /* PRNs of satellite */
73 int elevation[MAXCHANNELS]; /* elevation of satellite */
74 int azimuth[MAXCHANNELS]; /* azimuth */
75 int ss[MAXCHANNELS]; /* signal-to-noise ratio (dB) */
76 };
77
78 #ifdef USE_MAEMO
79 #ifdef ENABLE_GPSBT
80 #include <gpsbt.h>
81 #include <gpsmgr.h>
82 #endif
83 #include <errno.h>
84 #endif
85
86 #ifdef ENABLE_LIBLOCATION
87 #include <location/location-gps-device.h>
88 #include <location/location-gpsd-control.h>
89 #endif
90
91 typedef struct {
92 int num;
93 int *PRN;
94 int *ss;
95 int *used;
96 } gps_sat_t;
97
98 typedef void (*gps_cb)(struct gps_state *, gpointer data);
99 #define GPS_CB(f) ((gps_cb)(f))
100
101 typedef struct {
102 gps_cb cb;
103 gpointer data;
104 } gps_cb_t;
105
106 typedef struct gps_state {
107 #ifndef ENABLE_LIBLOCATION
108 #ifdef ENABLE_GPSBT
109 gpsbt_t context;
110 #endif
111
112 GThread* thread_p;
113 GMutex *mutex;
114 GnomeVFSInetConnection *iconn;
115 GnomeVFSSocket *socket;
116
117 struct gps_data_t gpsdata;
118 #else
119 LocationGPSDevice *device;
120 LocationGPSDControl *control;
121 gboolean in_use;
122 guint idd_changed;
123 int fields;
124
125 struct gps_fix_t fix;
126 gps_sat_t sats;
127 #endif
128
129 GSList *cb;
130
131 } gps_state_t;
132
133 void gps_init(appdata_t *appdata);
134 void gps_release(appdata_t *appdata);
135 pos_t *gps_get_pos(appdata_t *appdata);
136 float gps_get_heading(appdata_t *appdata);
137 float gps_get_eph(appdata_t *appdata);
138 gps_sat_t *gps_get_sats(appdata_t *appdata);
139 void gps_change_state(appdata_t *appdata);
140
141 void *gps_register_callback(appdata_t *appdata, gps_cb cb, gpointer data);
142 void gps_unregister_callback(appdata_t *appdata, void *cb);
143
144 #endif // GPS_H