From 353a26d3e7ebff1a913c227d8768ae042e676eb3 Mon Sep 17 00:00:00 2001 From: Christian Gagneraud Date: Fri, 1 Jun 2012 16:57:22 +0100 Subject: gpsdecode: honor scale flag Currently gpsdecode doesn't care about the -u (unscaled) flag. Fix that. This patch will allow aivdm-regress to run tests in scaled mode. scons check passed. --- SConstruct | 6 +++--- gpsdecode.c | 4 ++++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/SConstruct b/SConstruct index 7cbf3f4a..0e112e60 100644 --- a/SConstruct +++ b/SConstruct @@ -1387,13 +1387,13 @@ rtcm_regress = Utility('rtcm-regress', [gpsdecode], [ 'for f in $SRCDIR/test/*.rtcm2; do ' 'echo "Testing $${f}..."; ' 'TMPFILE=`mktemp -t gpsd-test-XXXXXXXXXXXXXX.chk`; ' - '$SRCDIR/gpsdecode -j <$${f} >$${TMPFILE}; ' + '$SRCDIR/gpsdecode -u -j <$${f} >$${TMPFILE}; ' 'diff -ub $${f}.chk $${TMPFILE}; ' 'rm -f $${TMPFILE}; ' 'done;', '@echo "Testing idempotency of JSON dump/decode for RTCM2"', 'TMPFILE=`mktemp -t gpsd-test-XXXXXXXXXXXXXX.chk`; ' - '$SRCDIR/gpsdecode -e -j $${TMPFILE}; ' + '$SRCDIR/gpsdecode -u -e -j $${TMPFILE}; ' 'grep -v "^#" test/synthetic-rtcm2.json | diff -ub - $${TMPFILE}; ' 'rm -f $${TMPFILE}; ', ]) @@ -1417,7 +1417,7 @@ aivdm_regress = Utility('aivdm-regress', [gpsdecode], [ 'done;', '@echo "Testing idempotency of JSON dump/decode for AIS"', 'TMPFILE=`mktemp -t gpsd-test-XXXXXXXXXXXXXX.chk`; ' - '$SRCDIR/gpsdecode -e -j <$SRCDIR/test/synthetic-ais.json >$${TMPFILE}; ' + '$SRCDIR/gpsdecode -u -e -j <$SRCDIR/test/synthetic-ais.json >$${TMPFILE}; ' 'grep -v "^#" $SRCDIR/test/synthetic-ais.json | diff -ub - $${TMPFILE}; ' 'rm -f $${TMPFILE}; ', ]) diff --git a/gpsdecode.c b/gpsdecode.c index 3ade9b8c..51a9c2eb 100644 --- a/gpsdecode.c +++ b/gpsdecode.c @@ -511,6 +511,7 @@ static void decode(FILE *fpin, FILE*fpout) //(void)strlcpy(session.gpsdata.dev.path, "stdin", sizeof(session.gpsdata.dev.path)); memset(&policy, '\0', sizeof(policy)); policy.json = json; + policy.scaled = scaled; gps_context_init(&context); gpsd_time_init(&context, time(NULL)); @@ -576,6 +577,9 @@ static void encode(FILE *fpin, FILE *fpout) "stdin", sizeof(session.gpsdata.dev.path)); policy.json = true; + /* Parsing is always made in unscaled mode, + * this policy applies to the dumping */ + policy.scaled = scaled; while (fgets(inbuf, (int)sizeof(inbuf), fpin) != NULL) { int status; -- cgit v1.2.1