summaryrefslogtreecommitdiff
path: root/gpspipe.c
diff options
context:
space:
mode:
authorRobert Norris <rw_norris@hotmail.com>2017-03-05 18:43:40 +0000
committerFred Wright <fw@fwright.net>2017-03-05 13:43:14 -0800
commite8d8c8bc9ea7a5d4aa87831835d0228743ea964a (patch)
tree7df7d2fb636405df2528ebbc0ed68b78f5a9cf3e /gpspipe.c
parent9f870a11218d0bc6364d6b333fd878106746adf9 (diff)
downloadgpsd-e8d8c8bc9ea7a5d4aa87831835d0228743ea964a.tar.gz
Enable Windows version of gpspipe
Use recv() rather than read() for Windows compatibility. Disable serial port code not available on Windows. Add open flag that's not available on Windows. TESTED: Built gpspipe for Windows under cross compiler. Run gpspipe on a Windows system and successfully connects to an instance of gpsd and dumps NMEA output to the terminal or a specified output file. Still builds and runs on a Linux system including the daemon option. Signed-off-by: Fred Wright <fw@fwright.net>
Diffstat (limited to 'gpspipe.c')
-rw-r--r--gpspipe.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/gpspipe.c b/gpspipe.c
index 0d4a7899..72eed301 100644
--- a/gpspipe.c
+++ b/gpspipe.c
@@ -37,11 +37,21 @@
#include <string.h>
#include <strings.h>
#include <fcntl.h>
+#ifdef HAVE_TERMIOS_H
#include <termios.h>
+#endif /* HAVE_TERMIOS_H */
#include <sys/time.h>
#include <sys/types.h>
#include <sys/stat.h>
+#ifdef HAVE_SYS_SELECT_H
#include <sys/select.h>
+#endif /* HAVE_SYS_SELECT_H */
+#ifdef HAVE_SYS_SOCKET_H
+#include <sys/socket.h>
+#endif /* HAVE_SYS_SOCKET_H */
+#ifdef HAVE_WINSOCK2_H
+#include <winsock2.h>
+#endif /* HAVE_WINSOCK2_H */
#include <unistd.h>
#include "gpsd.h"
@@ -74,6 +84,7 @@ static void open_serial(char *device)
exit(EXIT_FAILURE);
}
+#ifdef HAVE_TERMIOS_H
/* Save current serial port settings for later */
if (tcgetattr(fd_out, &oldtio) != 0) {
(void)fprintf(stderr, "gpspipe: error reading serial port settings\n");
@@ -94,6 +105,7 @@ static void open_serial(char *device)
(void)fprintf(stderr, "gpspipe: error configuring serial port\n");
exit(EXIT_FAILURE);
}
+#endif /* HAVE_TERMIOS_H */
}
static void usage(void)
@@ -319,7 +331,7 @@ int main(int argc, char **argv)
/* reading directly from the socket avoids decode overhead */
errno = 0;
- r = (int)read(gpsdata.gps_fd, buf, sizeof(buf));
+ r = (int)recv(gpsdata.gps_fd, buf, sizeof(buf), 0);
if (r > 0) {
int i = 0;
int j = 0;