summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric S. Raymond <esr@thyrsus.com>2011-10-06 12:02:27 -0400
committerEric S. Raymond <esr@thyrsus.com>2011-10-06 12:02:27 -0400
commit7fd45864bb080b74fd94bef17468648dd4d5f891 (patch)
tree2cf0c9ae4cf5a95fdc630e4f71a3a8cdfbfaabb5
parentdf3db5a870dfccfb4a3d57fc3eaafca718af1cdc (diff)
downloadgpsd-7fd45864bb080b74fd94bef17468648dd4d5f891.tar.gz
New -f option of gpspsprof to save JSON input.
-rwxr-xr-xgpsprof20
-rw-r--r--gpsprof.xml8
2 files changed, 21 insertions, 7 deletions
diff --git a/gpsprof b/gpsprof
index 05fabc24..1851d0b2 100755
--- a/gpsprof
+++ b/gpsprof
@@ -53,7 +53,7 @@ class plotter:
self.device.get('driver', "unknown"), self.device['bps'],
9 - self.device['stopbits'],
self.device['stopbits'], self.device['cycle'])
- def collect(self, verbose):
+ def collect(self, verbose, logfp=None):
"Collect data from the GPS."
try:
self.session = gps.gps(verbose=verbose)
@@ -102,6 +102,8 @@ class plotter:
if countdown == await:
sys.stderr.write("first fix in %.2fsec, gathering %d samples..." % (time.time()-basetime,await))
if plotter.sample():
+ if logfp:
+ logfp.write(self.session.response)
countdown -= 1
baton.end()
finally:
@@ -297,7 +299,7 @@ formatters = (spaceplot, uninstrumented, instrumented)
if __name__ == '__main__':
try:
- (options, arguments) = getopt.getopt(sys.argv[1:], "d:f:hm:n:s:t:T:D:")
+ (options, arguments) = getopt.getopt(sys.argv[1:], "d:f:hl:m:n:s:t:T:D:")
plotmode = "space"
raw = False
@@ -307,19 +309,25 @@ if __name__ == '__main__':
verbose = 0
terminal = None
dumpfile = None
+ logfp = None
for (switch, val) in options:
if (switch == '-f'):
plotmode = val
elif (switch == '-m'):
threshold = int(val)
elif (switch == '-n'):
- await = int(val)
+ if val[-1] == 'h':
+ await = int(val[:-1]) * 360
+ else:
+ await = int(val)
elif (switch == '-t'):
title = val
elif (switch == '-T'):
terminal = val
elif (switch == '-d'):
dumpfile = val
+ elif (switch == '-l'):
+ logfp = open(val, "w")
elif (switch == '-D'):
verbose = int(val)
elif (switch == '-h'):
@@ -337,12 +345,14 @@ if __name__ == '__main__':
sys.stderr.write("gpsprof: no such formatter.\n")
sys.exit(1)
# Get fix data from the GPS
- plotter.collect(verbose)
+ plotter.collect(verbose, logfp)
plotter.postprocess()
- # Save the raw data for post-analysis if required.
+ # Save the timing data (only) for post-analysis if required.
if dumpfile:
with open(dumpfile, "w") as fp:
fp.write(plotter.dump())
+ if logfp:
+ logfp.close()
# Ship the plot to standard output
if not title:
title = plotter.whatami()
diff --git a/gpsprof.xml b/gpsprof.xml
index 107c4e76..4e4449c2 100644
--- a/gpsprof.xml
+++ b/gpsprof.xml
@@ -28,6 +28,7 @@ BSD terms apply: see the file COPYING in the distribution root for details.
<arg choice='opt'>-t <replaceable>title</replaceable></arg>
<arg choice='opt'>-T <replaceable>terminal</replaceable></arg>
<arg choice='opt'>-d <replaceable>dumpfile</replaceable></arg>
+ <arg choice='opt'>-l <replaceable>logfile</replaceable></arg>
<arg choice='opt'>-D <replaceable>debuglevel</replaceable></arg>
<arg choice='opt'>-h</arg>
</cmdsynopsis>
@@ -158,8 +159,11 @@ title.</para>
Typical usage is "-T png" telling gnuplot to write a PNG file. Without
this option gnuplot will call its X11 display code.</para>
-<para>The -d option dumps the raw plot data to a specified file for
-pos-analysis.</para>
+<para>The -d option dumps the plot data, without attached gnuplot
+code, to a specified file for post-analysis.</para>
+
+<para>The -f option dumps the raw JSON reports collected from the device
+to a specified file.</para>
<para>The -h option makes <application>gpsprof</application> print
a usage message and exit.</para>