summaryrefslogtreecommitdiff
path: root/gpsdecode.c
diff options
context:
space:
mode:
authorEric S. Raymond <esr@thyrsus.com>2009-08-27 15:18:53 +0000
committerEric S. Raymond <esr@thyrsus.com>2009-08-27 15:18:53 +0000
commit195c8ccbd426de1163768c3d2f6a7dccc82844a6 (patch)
tree65003630b15690396277ba7cd4b5f8390696cbc3 /gpsdecode.c
parent8c6a94d3122e3d58843f81ba8ad7c71b5abcd719 (diff)
downloadgpsd-195c8ccbd426de1163768c3d2f6a7dccc82844a6.tar.gz
Give gpsdecode the capability to encode from RTCM2 JSON. Not yet tested.
Diffstat (limited to 'gpsdecode.c')
-rw-r--r--gpsdecode.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/gpsdecode.c b/gpsdecode.c
index 6232fe15..d5a8f851 100644
--- a/gpsdecode.c
+++ b/gpsdecode.c
@@ -13,6 +13,7 @@
#include "gpsd_config.h"
#include "gpsd.h"
+#include "gps_json.h"
static int verbose = 0;
static bool scaled = true;
@@ -102,7 +103,7 @@ static void pass(FILE *fpin, FILE *fpout)
else if (buf[0] == '.')
continue;
- status = rtcm2_undump(&rtcm, buf);
+ status = rtcm2_sager_undump(&rtcm, buf);
if (status == 0) {
(void)memset(lexer.isgps.buf, 0, sizeof(lexer.isgps.buf));
@@ -131,9 +132,15 @@ static void encode(FILE *fpin, FILE *fpout)
memset(&lexer, 0, sizeof(lexer));
while (fgets(buf, (int)sizeof(buf), fpin) != NULL) {
int status;
-
- status = rtcm2_undump(&rtcm, buf);
-
+ char dummypath[PATH_MAX];
+
+ if (buf[0] == '{')
+ status = json_rtcm2_read(buf,
+ dummypath, sizeof(dummypath),
+ &rtcm,
+ NULL);
+ else
+ status = rtcm2_sager_undump(&rtcm, buf);
if (status == 0) {
(void)memset(lexer.isgps.buf, 0, sizeof(lexer.isgps.buf));
(void)rtcm2_repack(&rtcm, lexer.isgps.buf);