summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cgps.c2
-rw-r--r--gps.h1
-rw-r--r--gpsctl.c4
-rw-r--r--gpxlogger.c2
-rw-r--r--lcdgps.c3
-rw-r--r--libgps_core.c27
6 files changed, 25 insertions, 14 deletions
diff --git a/cgps.c b/cgps.c
index 66b261da..46df2225 100644
--- a/cgps.c
+++ b/cgps.c
@@ -899,7 +899,7 @@ int main(int argc, char *argv[])
exit(2);
} else if (data) {
errno = 0;
- if (gps_poll(&gpsdata) != 0) {
+ if (gps_read(&gpsdata) == -1) {
fprintf(stderr, "cgps: socket error 4\n");
die(errno == 0 ? GPS_GONE : GPS_ERROR);
}
diff --git a/gps.h b/gps.h
index 6c39db7b..23ff0bf5 100644
--- a/gps.h
+++ b/gps.h
@@ -1049,6 +1049,7 @@ extern int gps_open_r(/*@null@*/const char *, /*@null@*/const char *,
extern /*@null@*/struct gps_data_t *gps_open(const char *, const char *);
extern int gps_close(struct gps_data_t *);
extern int gps_send(struct gps_data_t *, const char *, ... );
+extern int gps_read(/*@out@*/struct gps_data_t *);
extern int gps_poll(/*@out@*/struct gps_data_t *);
extern bool gps_waiting(struct gps_data_t *);
extern int gps_stream(struct gps_data_t *, unsigned int, /*@null@*/void *);
diff --git a/gpsctl.c b/gpsctl.c
index 1a6db974..f45baab1 100644
--- a/gpsctl.c
+++ b/gpsctl.c
@@ -81,7 +81,7 @@ static int gps_query(struct gps_data_t *gpsdata, const char *fmt, ... )
return -1;
}
gpsd_report(LOG_PROG, "gps_query(), wrote, %s\n", buf);
- ret = gps_poll(gpsdata);
+ ret = gps_read(gpsdata);
if (ERROR_IS & gpsdata->set) {
gpsd_report(LOG_ERROR, "gps_query() error '%s'\n", gpsdata->error);
}
@@ -267,7 +267,7 @@ int main(int argc, char **argv)
if (!lowlevel) {
/* OK, there's a daemon instance running. Do things the easy way */
struct devconfig_t *devlistp;
- (void)gps_poll(&gpsdata);
+ (void)gps_read(&gpsdata);
if ((gpsdata.set & DEVICELIST_SET) != 0) {
gpsd_report(LOG_ERROR, "no VERSION response received; update your gpsd.\n");
(void)gps_close(&gpsdata);
diff --git a/gpxlogger.c b/gpxlogger.c
index 5e079749..b9cb5781 100644
--- a/gpxlogger.c
+++ b/gpxlogger.c
@@ -330,7 +330,7 @@ static int socket_mainloop(void)
(void)fprintf(stderr, "%s\n", strerror(errno));
break;
} else if (data)
- (void)gps_poll(&gpsdata);
+ (void)gps_read(&gpsdata);
}
(void)gps_close(&gpsdata);
return 0;
diff --git a/lcdgps.c b/lcdgps.c
index 25945f6f..3b7627c2 100644
--- a/lcdgps.c
+++ b/lcdgps.c
@@ -540,8 +540,7 @@ int main(int argc, char *argv[])
exit(2);
}
else if (data) {
- /* code that calls gps_poll(gpsdata) */
- (void)gps_poll(&gpsdata);
+ (void)gps_read(&gpsdata);
}
}
diff --git a/libgps_core.c b/libgps_core.c
index 5e16b4ee..996b42f8 100644
--- a/libgps_core.c
+++ b/libgps_core.c
@@ -541,7 +541,7 @@ bool gps_waiting(struct gps_data_t * gpsdata)
}
/*@-compdef -usedef -uniondef@*/
-int gps_poll(/*@out@*/struct gps_data_t *gpsdata)
+int gps_read(/*@out@*/struct gps_data_t *gpsdata)
/* wait for and read data being streamed from the daemon */
{
char *eol;
@@ -614,10 +614,21 @@ int gps_poll(/*@out@*/struct gps_data_t *gpsdata)
priv->waiting -= response_length;
gpsdata->set |= PACKET_SET;
- return 0;
+ return status;
}
/*@+compdef -usedef +uniondef@*/
+int gps_poll(/*@out@*/struct gps_data_t *gpsdata)
+/* for backwards compatibility */
+{
+ int status = gps_read(gpsdata);
+
+ if (status > 0)
+ status = 0;
+
+ return status;
+}
+
int gps_send(struct gps_data_t *gpsdata, const char *fmt, ...)
/* send a command to the gpsd instance */
{
@@ -804,10 +815,10 @@ int main(int argc, char *argv[])
exit(1);
} else if (optind < argc) {
gps_set_raw_hook(collect, dumpline);
- strlcpy(buf, argv[optind], BUFSIZ);
- strlcat(buf, "\n", BUFSIZ);
- gps_send(collect, buf);
- gps_poll(collect);
+ (void)strlcpy(buf, argv[optind], BUFSIZ);
+ (void)strlcat(buf, "\n", BUFSIZ);
+ (void)gps_send(collect, buf);
+ (void)gps_read(collect);
libgps_dump_state(collect, time(NULL));
(void)gps_close(collect);
} else {
@@ -825,8 +836,8 @@ int main(int argc, char *argv[])
break;
}
collect->set = 0;
- gps_send(collect, buf);
- gps_poll(collect);
+ (void)gps_send(collect, buf);
+ (void)gps_read(collect);
libgps_dump_state(collect, time(NULL));
}
(void)gps_close(collect);