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)
static struct vehicle_priv {
char *source;
+#ifndef HAVE_LIBGPS19
char *gpsd_query;
+#endif
struct callback_list *cbl;
struct callback *cb;
struct event_watch *evwatch;
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;
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);
}
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;
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);
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);
}
*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);
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;