Ticket #518: libgps-2.90-fix

File libgps-2.90-fix, 4.8 KB (added by pini, 12 years ago)
Line 
1d5db05b5fd83c961237aea1f51b74cb448c221c7
2diff --git a/navit/attr_def.h b/navit/attr_def.h
3index d2ee03e..03fbe67 100644
4--- a/navit/attr_def.h
5+++ b/navit/attr_def.h
6@@ -226,7 +226,6 @@ ATTR(description)
7 ATTR(gc_type)
8 ATTR(layout)
9 ATTR(position_nmea)
10-ATTR(gpsd_query)
11 ATTR(on_eof)
12 ATTR(command)
13 ATTR(src)
14diff --git a/navit/navit_shipped.xml b/navit/navit_shipped.xml
15index b975d8e..b6af6b8 100644
16--- a/navit/navit_shipped.xml
17+++ b/navit/navit_shipped.xml
18@@ -99,7 +99,7 @@ Navigation</text></img>
19                <osd enabled="no" type="button" x="-96" y="-96" command="zoom_in()" src="zoom_in.xpm"/>
20                <osd enabled="no" type="button" x="0" y="-96" command="zoom_out()" src="zoom_out.xpm"/>
21 
22-               <vehicle name="Local GPS" profilename="car" enabled="yes" active="1" source="gpsd://localhost" gpsd_query="w+xj">
23+               <vehicle name="Local GPS" profilename="car" enabled="yes" active="1" source="gpsd://localhost">
24                        <!-- Navit can write a tracklog in several formats (gpx, nmea or textfile): -->
25                        <log enabled="no" type="gpx" attr_types="position_time_iso8601,position_direction,position_speed,profilename,position_radius" data="track_%Y%m%d-%i.gpx" flush_size="1000" flush_time="30"/>
26                </vehicle>
27diff --git a/navit/vehicle/gpsd/vehicle_gpsd.c b/navit/vehicle/gpsd/vehicle_gpsd.c
28index 4bba75f..a51d93f 100644
29--- a/navit/vehicle/gpsd/vehicle_gpsd.c
30+++ b/navit/vehicle/gpsd/vehicle_gpsd.c
31@@ -36,7 +36,6 @@
32 
33 static struct vehicle_priv {
34        char *source;
35-       char *gpsd_query;
36        struct callback_list *cbl;
37        struct callback *cb;
38        struct event_watch *evwatch;
39@@ -69,8 +68,7 @@ static struct vehicle_priv {
40 static void vehicle_gpsd_io(struct vehicle_priv *priv);
41 
42 static void
43-vehicle_gpsd_callback(struct gps_data_t *data, char *buf, size_t len,
44-                     int level)
45+vehicle_gpsd_callback(struct gps_data_t *data, char *buf, size_t len)
46 {
47        char *pos,*nmea_data_buf;
48         int i=0,sats_signal=0;
49@@ -108,16 +106,16 @@ vehicle_gpsd_callback(struct gps_data_t *data, char *buf, size_t len,
50                data->set &= ~ALTITUDE_SET;
51        }
52        if (data->set & SATELLITE_SET) {
53-                if(data->satellites > 0) {
54+                if(data->satellites_visible > 0) {
55                         sats_signal=0;
56-                        for( i=0;i<data->satellites;i++) {
57+                        for( i=0;i<data->satellites_visible;i++) {
58                                if (data->ss[i] > 0)
59                                         sats_signal++;
60                         }
61                 }
62-               if (priv->sats_used != data->satellites_used || priv->sats != data->satellites || priv->sats_signal != sats_signal ) {
63+               if (priv->sats_used != data->satellites_used || priv->sats != data->satellites_visible || priv->sats_signal != sats_signal ) {
64                        priv->sats_used = data->satellites_used;
65-                       priv->sats = data->satellites;
66+                       priv->sats = data->satellites_visible;
67                         priv->sats_signal = sats_signal;
68                        callback_list_call_attr_0(priv->cbl, attr_position_sats);
69                }
70@@ -135,10 +133,10 @@ vehicle_gpsd_callback(struct gps_data_t *data, char *buf, size_t len,
71                priv->fix_time = data->fix.time;
72                data->set &= ~TIME_SET;
73        }
74-       if (data->set & PDOP_SET) {
75-               dbg(1, "pdop : %g\n", data->pdop);
76-               priv->hdop = data->hdop;
77-               data->set &= ~PDOP_SET;
78+       if (data->set & DOP_SET) {
79+               dbg(1, "pdop : %g\n", data->dop.pdop);
80+               priv->hdop = data->dop.pdop;
81+               data->set &= ~DOP_SET;
82        }
83        if (data->set & LATLON_SET) {
84                priv->geo.lat = data->fix.latitude;
85@@ -180,7 +178,7 @@ vehicle_gpsd_try_open(gpointer *data)
86                dbg(0,"gps_open failed for '%s'. Retrying in %d seconds. Have you started gpsd?\n", priv->source, priv->retry_interval);
87                return TRUE;
88        }
89-       gps_query(priv->gps, priv->gpsd_query);
90+       gps_stream(priv->gps, WATCH_ENABLE, NULL);
91        gps_set_raw_hook(priv->gps, vehicle_gpsd_callback);
92        priv->cb = callback_new_1(callback_cast(vehicle_gpsd_io), priv);
93        priv->evwatch = event_add_watch((void *)priv->gps->gps_fd, event_watch_cond_read, priv->cb);
94@@ -268,8 +266,6 @@ vehicle_gpsd_destroy(struct vehicle_priv *priv)
95        vehicle_gpsd_close(priv);
96        if (priv->source)
97                g_free(priv->source);
98-       if (priv->gpsd_query)
99-               g_free(priv->gpsd_query);
100        g_free(priv);
101 }
102 
103@@ -350,19 +346,12 @@ vehicle_gpsd_new_gpsd(struct vehicle_methods
104                      *cbl, struct attr **attrs)
105 {
106        struct vehicle_priv *ret;
107-       struct attr *source, *query, *retry_int;
108+       struct attr *source, *retry_int;
109 
110        dbg(1, "enter\n");
111        source = attr_search(attrs, NULL, attr_source);
112        ret = g_new0(struct vehicle_priv, 1);
113        ret->source = g_strdup(source->u.str);
114-       query = attr_search(attrs, NULL, attr_gpsd_query);
115-       if (query) {
116-               ret->gpsd_query = g_strconcat(query->u.str, "\n", NULL);
117-       } else {
118-               ret->gpsd_query = g_strdup("w+x\n");
119-       }
120-       dbg(1,"Format string for gpsd_query: %s\n",ret->gpsd_query);
121        retry_int = attr_search(attrs, NULL, attr_retry_interval);
122        if (retry_int) {
123                ret->retry_interval = retry_int->u.num;