[PATCH] Switch to new gpsd API

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/baseband-devel@lists.osmocom.org/.

Paul Wise pabs3 at bonedaddy.net
Tue Jan 3 03:01:08 UTC 2012


---
 src/host/layer23/src/common/gps.c |   26 +++++++++++++-------------
 1 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/src/host/layer23/src/common/gps.c b/src/host/layer23/src/common/gps.c
index 38aae2c..2bdfb97 100644
--- a/src/host/layer23/src/common/gps.c
+++ b/src/host/layer23/src/common/gps.c
@@ -56,7 +56,7 @@ static struct osmo_fd gps_bfd;
 
 #ifdef _HAVE_GPSD
 
-static struct gps_data_t* gdata;
+static struct gps_data_t gdata;
 
 int osmo_gpsd_cb(struct osmo_fd *bfd, unsigned int what)
 {
@@ -66,25 +66,25 @@ int osmo_gpsd_cb(struct osmo_fd *bfd, unsigned int what)
 	g.valid = 0;
 
 	/* gps is offline */
-	if (gdata->online)
+	if (gdata.online)
 	    goto gps_not_ready;
 
 	/* gps has no data */
-	if (gps_waiting(gdata))
+	if (gps_waiting(&gdata, 500))
 	    goto gps_not_ready;
 
 	/* polling returned an error */
-	if (gps_poll(gdata))
+	if (gps_read(&gdata))
 	    goto gps_not_ready;
 
 	/* data are valid */
-	if (gdata->set & LATLON_SET) {
+	if (gdata.set & LATLON_SET) {
 		g.valid = 1;
-		g.gmt = gdata->fix.time;
+		g.gmt = gdata.fix.time;
 		tm = localtime(&g.gmt);
 		diff = time(NULL) - g.gmt;
-		g.latitude = gdata->fix.latitude;
-		g.longitude = gdata->fix.longitude;
+		g.latitude = gdata.fix.latitude;
+		g.longitude = gdata.fix.longitude;
 
 		LOGP(DGPS, LOGL_INFO, " time=%02d:%02d:%02d %04d-%02d-%02d, "
 			"diff-to-host=%d, latitude=%do%.4f, longitude=%do%.4f\n",
@@ -111,16 +111,15 @@ int osmo_gpsd_open(void)
 	gps_bfd.when = BSC_FD_READ;
 	gps_bfd.cb = osmo_gpsd_cb;
 
-	gdata = gps_open(g.gpsd_host, g.gpsd_port);
-	if (gdata == NULL) {
+	if (gps_open(g.gpsd_host, g.gpsd_port, &gdata) == -1) {
 		LOGP(DGPS, LOGL_ERROR, "Can't connect to gpsd\n");
 		return -1;
 	}
-	gps_bfd.fd = gdata->gps_fd;
+	gps_bfd.fd = gdata.gps_fd;
 	if (gps_bfd.fd < 0)
 		return gps_bfd.fd;
 
-	if (gps_stream(gdata, WATCH_ENABLE, NULL) == -1) {
+	if (gps_stream(&gdata, WATCH_ENABLE, NULL) == -1) {
 		LOGP(DGPS, LOGL_ERROR, "Error in gps_stream()\n");
 		return -1;
 	}
@@ -139,7 +138,8 @@ void osmo_gpsd_close(void)
 
 	osmo_fd_unregister(&gps_bfd);
 
-	gps_close(gdata);
+	gps_stream(&gdata, WATCH_DISABLE, NULL);
+	gps_close(&gdata);
 	gps_bfd.fd = -1; /* -1 or 0 indicates: 'close' */
 }
 
-- 
1.7.7.3





More information about the baseband-devel mailing list