Commited pini's patch http://trac.navit-project.org/ticket/518 that solve the gpsd...
authorworldcitizen <worldcitizen@ffa7fe5e-494d-0410-b361-a75ebd5db220>
Mon, 25 Jan 2010 23:20:16 +0000 (23:20 +0000)
committerHenning Heinold <heinold@inf.fu-berlin.de>
Thu, 4 Feb 2010 23:46:35 +0000 (00:46 +0100)
git-svn-id: https://navit.svn.sourceforge.net/svnroot/navit/trunk/navit@2923 ffa7fe5e-494d-0410-b361-a75ebd5db220

configure.in
navit/attr.h
navit/attr_def.h
navit/map/garmin/Makefile.am
navit/vehicle/gpsd/vehicle_gpsd.c

index 4d83836..43fb8b0 100644 (file)
@@ -785,7 +785,17 @@ AM_CONDITIONAL(VEHICLE_FILE, test "x${vehicle_file}" = "xyes")
 AC_ARG_ENABLE(vehicle-gpsd, [  --disable-vehicle-gpsd              disable vehicle type gpsd], vehicle_gpsd=$enableval;vehicle_gpsd_reason="configure parameter")
 if test "x${vehicle_gpsd}" = xyes
 then
-       AC_CHECK_HEADER(gps.h, AC_DEFINE([HAVE_LIBGPS],[],Define to 1 if you have the <gps.h> header file.) GPSD_LIBS="-lgps", vehicle_gpsd=no; vehicle_gpsd_reason="no gps.h" )
+       PKG_CHECK_MODULES([GPSD], [libgps], have_libgps="yes", have_libgps="no")
+       if test "x$have_libgps" = "xyes"; then
+               AC_DEFINE([HAVE_LIBGPS],[],Define to 1 if you have libgps.)
+               PKG_CHECK_MODULES([LIBGPS19], [libgps >= 2.90], have_libgps19="yes", have_libgps19="no")
+               if test "x$have_libgps19" = "xyes"; then
+                       AC_DEFINE([HAVE_LIBGPS19],[],Define to 1 if you have libgps19.)
+               fi
+       else
+               vehicle_gpsd=no; vehicle_gpsd_reason="no libgps"
+       fi
+dnl    AC_CHECK_HEADER(gps.h, AC_DEFINE([HAVE_LIBGPS],[],Define to 1 if you have the <gps.h> header file.) GPSD_LIBS="-lgps", vehicle_gpsd=no; vehicle_gpsd_reason="no gps.h" )
 fi
 AC_SUBST(GPSD_CFLAGS)
 AC_SUBST(GPSD_LIBS)
index 5c2ec81..19c5662 100644 (file)
@@ -25,6 +25,7 @@ extern "C" {
 #endif
 
 #include "projection.h"
+#include "config.h"
 
 enum item_type;
 
index 9403042..252c6e9 100644 (file)
@@ -231,7 +231,9 @@ ATTR(description)
 ATTR(gc_type)
 ATTR(layout)
 ATTR(position_nmea)
+#ifndef HAVE_LIBGPS19
 ATTR(gpsd_query)
+#endif
 ATTR(on_eof)
 ATTR(command)
 ATTR(src)
index 1372459..8fa224f 100644 (file)
@@ -20,7 +20,7 @@ noinst_PROGRAMS=gentypes$(EXEEXT)
 gentypes_SOURCES=gentypes.c
 
 gentypes.$(OBJEXT): gentypes.c
-       $(CC_FOR_BUILD) -I$(top_srcdir)/navit -c -o $@ $<
+       $(CC_FOR_BUILD) -I$(top_srcdir)/navit -I$(top_srcdir) -c -o $@ $<
 
 gentypes$(EXEEXT): $(gentypes_OBJECTS) $(gentypes_DEPENDENCIES) 
        @rm -f gentypes$(EXEEXT)
index 4bba75f..3edbbb6 100644 (file)
@@ -36,7 +36,9 @@
 
 static struct vehicle_priv {
        char *source;
+#ifndef HAVE_LIBGPS19
        char *gpsd_query;
+#endif
        struct callback_list *cbl;
        struct callback *cb;
        struct event_watch *evwatch;
@@ -69,8 +71,12 @@ static struct vehicle_priv {
 static void vehicle_gpsd_io(struct vehicle_priv *priv);
 
 static void
+#ifdef HAVE_LIBGPS19
+vehicle_gpsd_callback(struct gps_data_t *data, char *buf, size_t len)
+#else
 vehicle_gpsd_callback(struct gps_data_t *data, char *buf, size_t len,
                      int level)
+#endif
 {
        char *pos,*nmea_data_buf;
         int i=0,sats_signal=0;
@@ -108,16 +114,32 @@ vehicle_gpsd_callback(struct gps_data_t *data, char *buf, size_t len,
                data->set &= ~ALTITUDE_SET;
        }
        if (data->set & SATELLITE_SET) {
+#ifdef HAVE_LIBGPS19
+                if(data->satellites_visible > 0) {
+#else
                 if(data->satellites > 0) {
+#endif
                         sats_signal=0;
+#ifdef HAVE_LIBGPS19
+                        for( i=0;i<data->satellites_visible;i++) {
+#else
                         for( i=0;i<data->satellites;i++) {
+#endif
                                if (data->ss[i] > 0)
                                         sats_signal++;
                         }
                 }
+#ifdef HAVE_LIBGPS19
+               if (priv->sats_used != data->satellites_used || priv->sats != data->satellites_visible || priv->sats_signal != sats_signal ) {
+#else
                if (priv->sats_used != data->satellites_used || priv->sats != data->satellites || priv->sats_signal != sats_signal ) {
+#endif
                        priv->sats_used = data->satellites_used;
+#ifdef HAVE_LIBGPS19
+                       priv->sats = data->satellites_visible;
+#else
                        priv->sats = data->satellites;
+#endif
                         priv->sats_signal = sats_signal;
                        callback_list_call_attr_0(priv->cbl, attr_position_sats);
                }
@@ -135,10 +157,17 @@ vehicle_gpsd_callback(struct gps_data_t *data, char *buf, size_t len,
                priv->fix_time = data->fix.time;
                data->set &= ~TIME_SET;
        }
+#ifdef HAVE_LIBGPS19
+       if (data->set & DOP_SET) {
+               dbg(1, "pdop : %g\n", data->dop.pdop);
+               priv->hdop = data->dop.pdop;
+               data->set &= ~DOP_SET;
+#else
        if (data->set & PDOP_SET) {
                dbg(1, "pdop : %g\n", data->pdop);
                priv->hdop = data->hdop;
                data->set &= ~PDOP_SET;
+#endif
        }
        if (data->set & LATLON_SET) {
                priv->geo.lat = data->fix.latitude;
@@ -180,7 +209,11 @@ vehicle_gpsd_try_open(gpointer *data)
                dbg(0,"gps_open failed for '%s'. Retrying in %d seconds. Have you started gpsd?\n", priv->source, priv->retry_interval);
                return TRUE;
        }
+#ifdef HAVE_LIBGPS19
+       gps_stream(priv->gps, WATCH_ENABLE, NULL);
+#else
        gps_query(priv->gps, priv->gpsd_query);
+#endif
        gps_set_raw_hook(priv->gps, vehicle_gpsd_callback);
        priv->cb = callback_new_1(callback_cast(vehicle_gpsd_io), priv);
        priv->evwatch = event_add_watch((void *)priv->gps->gps_fd, event_watch_cond_read, priv->cb);
@@ -268,8 +301,10 @@ vehicle_gpsd_destroy(struct vehicle_priv *priv)
        vehicle_gpsd_close(priv);
        if (priv->source)
                g_free(priv->source);
+#ifndef HAVE_LIBGPS19
        if (priv->gpsd_query)
                g_free(priv->gpsd_query);
+#endif
        g_free(priv);
 }
 
@@ -350,12 +385,17 @@ vehicle_gpsd_new_gpsd(struct vehicle_methods
                      *cbl, struct attr **attrs)
 {
        struct vehicle_priv *ret;
+#ifdef HAVE_LIBGPS19
+       struct attr *source, *retry_int;
+#else
        struct attr *source, *query, *retry_int;
+#endif
 
        dbg(1, "enter\n");
        source = attr_search(attrs, NULL, attr_source);
        ret = g_new0(struct vehicle_priv, 1);
        ret->source = g_strdup(source->u.str);
+#ifndef HAVE_LIBGPS19
        query = attr_search(attrs, NULL, attr_gpsd_query);
        if (query) {
                ret->gpsd_query = g_strconcat(query->u.str, "\n", NULL);
@@ -363,6 +403,7 @@ vehicle_gpsd_new_gpsd(struct vehicle_methods
                ret->gpsd_query = g_strdup("w+x\n");
        }
        dbg(1,"Format string for gpsd_query: %s\n",ret->gpsd_query);
+#endif
        retry_int = attr_search(attrs, NULL, attr_retry_interval);
        if (retry_int) {
                ret->retry_interval = retry_int->u.num;