summaryrefslogtreecommitdiff
path: root/gpxlogger.c
diff options
context:
space:
mode:
authorEric S. Raymond <esr@thyrsus.com>2011-03-09 01:50:53 -0500
committerEric S. Raymond <esr@thyrsus.com>2011-03-09 01:50:53 -0500
commit2663033714a98a9c9ea1165c330371b949faec0d (patch)
tree0090a6f172564371681b899f2a8663b2b78cf752 /gpxlogger.c
parent9d6dc2f1f95d0179c6175955c3dae0c5299e9a78 (diff)
downloadgpsd-2663033714a98a9c9ea1165c330371b949faec0d.tar.gz
Give gps_waiting() a timeout argument. Use it systematically in test clients.
cgps and gpxlogger are live-tested and work. All regression tests pass.
Diffstat (limited to 'gpxlogger.c')
-rw-r--r--gpxlogger.c18
1 files changed, 3 insertions, 15 deletions
diff --git a/gpxlogger.c b/gpxlogger.c
index ffe8899d..99e465ca 100644
--- a/gpxlogger.c
+++ b/gpxlogger.c
@@ -12,7 +12,6 @@
#include <errno.h>
#include <libgen.h>
#include <signal.h>
-#include <sys/time.h> /* for select() */
#ifndef S_SPLINT_S
#include <unistd.h>
#endif /* S_SPLINT_S */
@@ -299,7 +298,6 @@ static struct fixsource_t source;
/*@-mustfreefresh -compdestroy@*/
static int socket_mainloop(void)
{
- fd_set fds;
unsigned int flags = WATCH_ENABLE;
if (gps_open(source.server, source.port, &gpsdata) != 0) {
@@ -314,20 +312,10 @@ static int socket_mainloop(void)
(void)gps_stream(&gpsdata, flags, source.device);
for (;;) {
- int data;
- struct timeval tv;
-
- FD_ZERO(&fds);
- FD_SET(gpsdata.gps_fd, &fds);
-
- tv.tv_usec = 250000;
- tv.tv_sec = 0;
- data = select(gpsdata.gps_fd + 1, &fds, NULL, NULL, &tv);
-
- if (data == -1) {
- (void)fprintf(stderr, "%s\n", strerror(errno));
+ if (!gps_waiting(&gpsdata, 5000000)) {
+ (void)fprintf(stderr, "%s: error whille waiting\n", progname);
break;
- } else if (data) {
+ } else {
(void)gps_read(&gpsdata);
conditionally_log_fix(&gpsdata);
}