On Thu, June 20, 2019 10:08, Kirill Bychkov wrote:
> Hi!
> Long time ago I've started update of gpsd from 2.x to 3.x.
> Upstream moved from auto crap to scons so it gave me some
> headache.
> Before switching to new gpsd we need to prepare some ports
> which are linking against libgps because API has changed.
> Here are the diffs for foxtrotgps, geoclue and qlandkaretegt.
> (diff for geo/viking is still WIP):

Hi!
Diff for viking is attached. This update adds support for
newer gpsd API.
Successfuly buuilds on amd64, i386 and macppc. Works fine
on amd64.
OK?


>
> Index: patches/patch-src_gps_functions_c
> ===================================================================
> RCS file: patches/patch-src_gps_functions_c
> diff -N patches/patch-src_gps_functions_c
> --- /dev/null 1 Jan 1970 00:00:00 -0000
> +++ patches/patch-src_gps_functions_c 14 Jun 2019 07:04:02 -0000
> @@ -0,0 +1,20 @@
> +$OpenBSD$
> +
> +Fix build with newer gpsd API.
> +https://bazaar.launchpad.net/~foxtrotgps-team/foxtrotgps/trunk/revision/316
> +
> +Index: src/gps_functions.c
> +--- src/gps_functions.c.orig
> ++++ src/gps_functions.c
> +@@ -738,7 +738,11 @@ cb_gpsd_data(GIOChannel *src, GIOCondition condition,
> +     if (!libgps_initialized)
> +             return FALSE;
> +
> ++#if GPSD_API_MAJOR_VERSION >= 7 /* API change. gpsd version 3.18 and
> subsequent. */
> ++    ret = gps_read(&libgps_gpsdata, NULL, 0);
> ++#else
> +     ret = gps_read(&libgps_gpsdata);
> ++#endif
> +     /* Note that gps_read() will never actually return 0
> +        (zero-length reads are converted internally to a -1 return,
> +         since they mean that the connection to the daemon has closed),
>
>
> ____________________________________________
>
> Index: patches/patch-providers_gpsd_geoclue-gpsd_c
> ===================================================================
> RCS file: patches/patch-providers_gpsd_geoclue-gpsd_c
> diff -N patches/patch-providers_gpsd_geoclue-gpsd_c
> --- /dev/null 1 Jan 1970 00:00:00 -0000
> +++ patches/patch-providers_gpsd_geoclue-gpsd_c       14 Jun 2019 07:11:23 
> -0000
> @@ -0,0 +1,72 @@
> +$OpenBSD$
> +
> +Fix build with newer gpsd API.
> +
> +--- providers/gpsd/geoclue-gpsd.c.orig       Tue Jul 31 20:47:05 2012
> ++++ providers/gpsd/geoclue-gpsd.c    Sun Mar 27 12:35:47 2016
> +@@ -40,7 +40,12 @@
> + #include <geoclue/gc-iface-position.h>
> + #include <geoclue/gc-iface-velocity.h>
> +
> ++#if GPSD_API_MAJOR_VERSION >= 5
> ++/* gps_data conflicts with gps_data function */
> ++typedef struct gps_data_t gps_data_l;
> ++#else
> + typedef struct gps_data_t gps_data;
> ++#endif
> + typedef struct gps_fix_t gps_fix;
> +
> + /* only listing used tags */
> +@@ -59,7 +64,11 @@ typedef struct {
> +     char *host;
> +     char *port;
> +
> ++#if GPSD_API_MAJOR_VERSION >= 5
> ++    gps_data_l *gpsdata;
> ++#else
> +     gps_data *gpsdata;
> ++#endif
> +
> +     gps_fix *last_fix;
> +
> +@@ -397,10 +406,16 @@ geoclue_gpsd_stop_gpsd (GeoclueGpsd *self)
> + static gboolean
> + geoclue_gpsd_start_gpsd (GeoclueGpsd *self)
> + {
> ++#if GPSD_API_MAJOR_VERSION >= 5
> ++    int status = gps_open (self->host, self->port, self->gpsdata);
> ++    if (status == 0) {
> ++            gps_stream(self->gpsdata, WATCH_ENABLE | WATCH_NMEA, NULL);
> ++#else
> +     self->gpsdata = gps_open (self->host, self->port);
> +     if (self->gpsdata) {
> +             gps_stream(self->gpsdata, WATCH_ENABLE | WATCH_NMEA | 
> POLL_NONBLOCK,
> NULL);
> +             gps_set_raw_hook (self->gpsdata, gpsd_raw_hook);
> ++#endif
> +             return TRUE;
> +     } else {
> +             g_warning ("gps_open() failed, is gpsd running 
> (host=%s,port=%s)?",
> self->host, self->port);
> +@@ -413,10 +428,23 @@ gpsd_poll(gpointer data)
> + {
> +     GeoclueGpsd *self = (GeoclueGpsd*)data;
> +     if (self->gpsdata) {
> ++#if GPSD_API_MAJOR_VERSION >= 5
> ++            /* gps_poll and gps_set_raw_hook no longer present in this API 
> version */
> ++            if (gps_waiting(self->gpsdata, 500)) {
> ++                    if (gps_read(self->gpsdata) == -1) {
> ++                            geoclue_gpsd_set_status (self, 
> GEOCLUE_STATUS_ERROR);
> ++                            geoclue_gpsd_stop_gpsd(self);
> ++                            return FALSE;
> ++                    } else {
> ++                            /* Call existing raw_hook to process the data */
> ++                            gpsd_raw_hook(self->gpsdata, NULL, 0);
> ++                    }
> ++#else
> +             if (gps_poll(self->gpsdata) < 0) {
> +                     geoclue_gpsd_set_status (self, GEOCLUE_STATUS_ERROR);
> +                     geoclue_gpsd_stop_gpsd(self);
> +                     return FALSE;
> ++#endif
> +             }
> +     }
> +     return TRUE;
>
>
> ______________________________________________________
>
> Index: patches/patch-src_CDeviceGPSD_cpp
> ===================================================================
> RCS file: patches/patch-src_CDeviceGPSD_cpp
> diff -N patches/patch-src_CDeviceGPSD_cpp
> --- /dev/null 1 Jan 1970 00:00:00 -0000
> +++ patches/patch-src_CDeviceGPSD_cpp 16 Jun 2019 07:14:21 -0000
> @@ -0,0 +1,18 @@
> +$OpenBSD$
> +
> +Fix build with newer gpsd API
> +
> +Index: src/CDeviceGPSD.cpp
> +--- src/CDeviceGPSD.cpp.orig
> ++++ src/CDeviceGPSD.cpp
> +@@ -212,7 +212,9 @@ void CGPSDThread::run()
> +             }                    // if
> +             else if( FD_ISSET( gpsdata->gps_fd, &fds ) )
> +             {
> +-#if GPSD_API_MAJOR_VERSION >= 5
> ++#if GPSD_API_MAJOR_VERSION >= 7
> ++                gps_read( gpsdata, NULL, 0 );
> ++#elif GPSD_API_MAJOR_VERSION >= 5
> +                 gps_read( gpsdata );
> + #else
> +                 gps_poll( gpsdata );
>
> Build was tested on amd64 with gpsd-3.18. No tests with gps yet.
> Comments?
>
>
>
>


Reply via email to