summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsleske <sleske@ffa7fe5e-494d-0410-b361-a75ebd5db220>2013-11-25 20:25:31 +0000
committersleske <sleske@ffa7fe5e-494d-0410-b361-a75ebd5db220>2013-11-25 20:25:31 +0000
commit7aff72d1cb06932f76a9c2b870440b580cbe6fc7 (patch)
tree69a9efb9d0c5b7b44fac98f239a5230c6d7b8470
parent208957c6e038df6768a28eb06a3101173619f1fa (diff)
downloadnavit-svn-7aff72d1cb06932f76a9c2b870440b580cbe6fc7.tar.gz
Fix:vehicle_gpsd:Mostly revert rev.5642 to allow N810 to use old libgps. Warn in CMake build.|Fixes #1179.
git-svn-id: http://svn.code.sf.net/p/navit/code/trunk/navit@5719 ffa7fe5e-494d-0410-b361-a75ebd5db220
-rwxr-xr-xCMakeLists.txt13
-rw-r--r--configure.in12
-rw-r--r--navit/vehicle/gpsd/CMakeLists.txt7
-rw-r--r--navit/vehicle/gpsd/vehicle_gpsd.c56
4 files changed, 85 insertions, 3 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 7b7223d6..134ae225 100755
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -134,7 +134,11 @@ if(PKG_CONFIG_FOUND)
pkg_check_modules(QUESOGLC quesoglc)
pkg_check_modules(LIBLOCATION liblocation)
pkg_check_modules(LIBOSSO libosso)
- pkg_check_modules(LIBGPS libgps>=3.1) # libgpsd<V3.1 is buggy if LC_ALL is set.
+ # Accept even old versions of libgps, because N810 uses an old version (see #1179).
+ pkg_check_modules(LIBGPS libgps)
+ pkg_check_modules(LIBGPS19 libgps>=2.90)
+ # libgpsd<V3.1 is buggy if LC_ALL is set.
+ pkg_check_modules(LIBGPS_NEW libgps>=3.1)
pkg_check_modules(LIBGARMIN libgarmin)
pkg_check_modules(IMLIB2 imlib2)
if(IMLIB2_FOUND)
@@ -316,7 +320,12 @@ if(SDL_FOUND AND SDLIMAGE_FOUND AND FREETYPE_FOUND)
endif(SDL_FOUND AND SDLIMAGE_FOUND AND FREETYPE_FOUND)
if (LIBGPS_FOUND)
- set_with_reason(vehicle/gpsd "gpsd lib found" TRUE ${LIBGPS_LDFLAGS})
+ if (LIBGPS_NEW_FOUND)
+ set(VEHICLE_GPSD_REASON "gpsd lib found")
+ else(LIBGPS_NEW_FOUND)
+ set(VEHICLE_GPSD_REASON "WARNING: old gpsd lib found, buggy if LC_ALL is set")
+ endif(LIBGPS_NEW_FOUND)
+ set_with_reason(vehicle/gpsd ${VEHICLE_GPSD_REASON} TRUE ${LIBGPS_LDFLAGS})
endif(LIBGPS_FOUND)
if (GYPSY_FOUND)
diff --git a/configure.in b/configure.in
index 24690191..1ba2f879 100644
--- a/configure.in
+++ b/configure.in
@@ -1056,10 +1056,20 @@ AM_CONDITIONAL(VEHICLE_DEMO, test "x${vehicle_demo}" = "xyes")
AC_ARG_ENABLE(vehicle-file, [ --disable-vehicle-file disable vehicle type file], vehicle_file=$enableval;vehicle_file_reason="configure parameter")
AM_CONDITIONAL(VEHICLE_FILE, test "x${vehicle_file}" = "xyes")
# gpsd
+# We accept even old, buggy versions of libgps, because N810 uses an old version (see #1179).
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
- PKG_CHECK_MODULES([GPSD], [libgps >= 3.10], ,vehicle_gpsd="no";vehicle_gpsd_reason="package libgps >=V3.1 missing")
+ 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
+ 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 and no gpsd pkgconfig" )
+ fi
fi
AC_SUBST(GPSD_CFLAGS)
AC_SUBST(GPSD_LIBS)
diff --git a/navit/vehicle/gpsd/CMakeLists.txt b/navit/vehicle/gpsd/CMakeLists.txt
index 1c204f6b..091df2f7 100644
--- a/navit/vehicle/gpsd/CMakeLists.txt
+++ b/navit/vehicle/gpsd/CMakeLists.txt
@@ -1 +1,8 @@
module_add_library(vehicle_gpsd vehicle_gpsd.c)
+if (LIBGPS19_FOUND)
+ set_property(
+ TARGET vehicle_gpsd
+ APPEND PROPERTY COMPILE_DEFINITIONS HAVE_LIBGPS19=1
+ )
+endif (LIBGPS19_FOUND)
+
diff --git a/navit/vehicle/gpsd/vehicle_gpsd.c b/navit/vehicle/gpsd/vehicle_gpsd.c
index 766a454d..cb3ebd0c 100644
--- a/navit/vehicle/gpsd/vehicle_gpsd.c
+++ b/navit/vehicle/gpsd/vehicle_gpsd.c
@@ -70,7 +70,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, const char *buf, size_t len)
+#else
+vehicle_gpsd_callback(struct gps_data_t *data, const char *buf, size_t len,
+ int level)
+#endif
{
char *pos,*nmea_data_buf;
int i=0,sats_signal=0;
@@ -112,16 +117,34 @@ vehicle_gpsd_callback(struct gps_data_t *data, const char *buf, size_t len)
data->set &= ~ALTITUDE_SET;
}
if (data->set & SATELLITE_SET) {
+// We cannot rely on GPSD_API_MAJOR_VERSION here because it was not
+// incremented for this change :-(.
+#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);
}
@@ -139,10 +162,17 @@ vehicle_gpsd_callback(struct gps_data_t *data, const 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;
@@ -177,19 +207,31 @@ vehicle_gpsd_try_open(struct vehicle_priv *priv)
}
dbg(0,"Trying to connect to %s:%s\n",source+7,port?port:"default");
+#if GPSD_API_MAJOR_VERSION >= 5
/* gps_open returns 0 on success */
if (gps_open(source + 7, port, priv->gps)) {
+#else
+ priv->gps = gps_open(source + 7, port);
+ if(!priv->gps) {
+#endif
dbg(0,"gps_open failed for '%s'. Retrying in %d seconds. Have you started gpsd?\n", priv->source, priv->retry_interval);
g_free(source);
return TRUE;
}
g_free(source);
+#ifdef HAVE_LIBGPS19
if (strchr(priv->gpsd_query,'r'))
gps_stream(priv->gps, WATCH_ENABLE|WATCH_NMEA|WATCH_JSON, NULL);
else
gps_stream(priv->gps, WATCH_ENABLE|WATCH_JSON, NULL);
+#else
+ gps_query(priv->gps, priv->gpsd_query);
+#endif
+#if GPSD_API_MAJOR_VERSION < 5
+ gps_set_raw_hook(priv->gps, vehicle_gpsd_callback);
+#endif
priv->cb = callback_new_1(callback_cast(vehicle_gpsd_io), priv);
priv->cbt = callback_new_1(callback_cast(vehicle_gpsd_try_open), priv);
priv->evwatch = event_add_watch((void *)priv->gps->gps_fd, event_watch_cond_read, priv->cb);
@@ -251,7 +293,9 @@ vehicle_gpsd_close(struct vehicle_priv *priv)
}
if (priv->gps) {
gps_close(priv->gps);
+#if GPSD_API_MAJOR_VERSION >= 5
g_free(priv->gps);
+#endif
priv->gps = NULL;
}
#ifdef HAVE_GPSBT
@@ -269,6 +313,7 @@ vehicle_gpsd_io(struct vehicle_priv *priv)
dbg(1, "enter\n");
if (priv->gps) {
vehicle_last = priv;
+#if GPSD_API_MAJOR_VERSION >= 5
if(gps_read(priv->gps)==-1) {
dbg(0,"gps_poll failed\n");
vehicle_gpsd_close(priv);
@@ -279,6 +324,13 @@ vehicle_gpsd_io(struct vehicle_priv *priv)
buf = gps_data(priv->gps);
vehicle_gpsd_callback(priv->gps,buf,strlen(buf));
}
+#else
+ if (gps_poll(priv->gps)) {
+ dbg(0,"gps_poll failed\n");
+ vehicle_gpsd_close(priv);
+ vehicle_gpsd_open(priv);
+ }
+#endif
}
}
@@ -290,7 +342,9 @@ vehicle_gpsd_destroy(struct vehicle_priv *priv)
g_free(priv->source);
if (priv->gpsd_query)
g_free(priv->gpsd_query);
+#if GPSD_API_MAJOR_VERSION >= 5
g_free(priv->gps);
+#endif
g_free(priv);
}
@@ -376,7 +430,9 @@ vehicle_gpsd_new_gpsd(struct vehicle_methods
dbg(1, "enter\n");
source = attr_search(attrs, NULL, attr_source);
ret = g_new0(struct vehicle_priv, 1);
+#if GPSD_API_MAJOR_VERSION >= 5
ret->gps = g_new0(struct gps_data_t, 1);
+#endif
ret->source = g_strdup(source->u.str);
query = attr_search(attrs, NULL, attr_gpsd_query);
if (query) {