gpsd-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[gpsd-dev] [PATCH 3/4] Allow test_gpsmm program to connect to gpsd on a


From: Robert Norris
Subject: [gpsd-dev] [PATCH 3/4] Allow test_gpsmm program to connect to gpsd on a specified server and port
Date: Fri, 10 Feb 2017 22:53:40 +0000

Reuse gpsd_source_spec() to process command line arguments.

TESTED.
Successfully connected with gpsd that's listening on a specified port.
---
 test_gpsmm.cpp | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/test_gpsmm.cpp b/test_gpsmm.cpp
index dab1bfc2..d9668f5b 100644
--- a/test_gpsmm.cpp
+++ b/test_gpsmm.cpp
@@ -12,7 +12,12 @@
 #include <getopt.h>
 
 #include "libgpsmm.h"
-
+#include "gpsdclient.c"
+/*     YES   --->  ^^^^
+ Using .c rather than the .h to embed gpsd_source_spec() source here
+  so that it is compiled in C++ rather than C of the gps library
+ (otherwise fails to link as the signatures are unavailable/different)
+*/
 using namespace std;
 
 /*
@@ -127,7 +132,15 @@ int main(int argc, char *argv[])
         }
     }
 
-    gpsmm gps_rec("localhost", DEFAULT_GPSD_PORT);
+    struct fixsource_t source;
+    /* Grok the server, port, and device. */
+    if (optind < argc) {
+       gpsd_source_spec(argv[optind], &source);
+    } else
+       gpsd_source_spec(NULL, &source);
+
+    //gpsmm gps_rec("localhost", DEFAULT_GPSD_PORT);
+    gpsmm gps_rec(source.server, source.port);
 
     if (gps_rec.stream(WATCH_ENABLE|WATCH_JSON) == NULL) {
         cerr << "No GPSD running.\n";
-- 
2.11.0




reply via email to

[Prev in Thread] Current Thread [Next in Thread]