summaryrefslogtreecommitdiff
path: root/test_gpsmm.cpp
diff options
context:
space:
mode:
authorRobert Norris <rw_norris@hotmail.com>2017-02-10 22:53:40 +0000
committerFred Wright <fw@fwright.net>2017-02-11 19:32:35 -0800
commitb139396726bb4d951d98ce733538459f4cf21b7c (patch)
tree4468ccefc98304c7f70a912613ae47c1f75c6475 /test_gpsmm.cpp
parent11f097da5779694f70b00cdb388c45abbe6cbe9f (diff)
downloadgpsd-b139396726bb4d951d98ce733538459f4cf21b7c.tar.gz
Allow test_gpsmm program to connect to gpsd on a specified server and port
Reuse gpsd_source_spec() to process command line arguments. TESTED. Successfully connected with gpsd that's listening on a specified port. Signed-off-by: Fred Wright <fw@fwright.net>
Diffstat (limited to 'test_gpsmm.cpp')
-rw-r--r--test_gpsmm.cpp17
1 files 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";