summaryrefslogtreecommitdiff
path: root/devtools/cycle_analyzer
diff options
context:
space:
mode:
authorEric S. Raymond <esr@thyrsus.com>2009-09-08 13:07:19 +0000
committerEric S. Raymond <esr@thyrsus.com>2009-09-08 13:07:19 +0000
commit66f21dc266e2e6ef73bc1a0e3ec84a69256444b1 (patch)
treea9b4070fec75dced3df4d0a0725ad89eb11e66ae /devtools/cycle_analyzer
parent448d59770b5ffe1bcb5e3427b08526b718659786 (diff)
downloadgpsd-66f21dc266e2e6ef73bc1a0e3ec84a69256444b1.tar.gz
Another analysis step.
Diffstat (limited to 'devtools/cycle_analyzer')
-rwxr-xr-xdevtools/cycle_analyzer23
1 files changed, 16 insertions, 7 deletions
diff --git a/devtools/cycle_analyzer b/devtools/cycle_analyzer
index a205f602..2e2bc7d9 100755
--- a/devtools/cycle_analyzer
+++ b/devtools/cycle_analyzer
@@ -76,11 +76,12 @@ def extract_timestamped_sentences(fp):
return []
return sequence
-def analyze(fp, stage):
+def analyze(fp, stages):
"Analyze the cycle sequence of a device from its output logs."
# First, extract tags and timestamps
sequence = extract_timestamped_sentences(fp)
- if stage == "extract":
+ if "sequence" in stages:
+ print "Raw tag/timestamp sequence"
for (tag, timestamp) in sequence:
print "%s: %s" % (tag, timestamp)
# Then, do cycle detection
@@ -103,7 +104,8 @@ def analyze(fp, stage):
# split-cycle devices like old Garmins.
if events.count("-") < 6:
sys.stderr.write("cycle_analyzer: fewer than 5 cycles in\n" % fp.name)
- if stage == "events":
+ if "events" in stages:
+ print "Event list:"
for event in events:
print event
# Now group events into bursts
@@ -115,18 +117,25 @@ def analyze(fp, stage):
current = []
else:
current.append(event)
- if stage == "bursts":
+ if "bursts" in stages:
+ "Burst list:"
+ for burst in bursts:
+ print burst
+ # Trim off first and last bursts, which are likely incomplete.
+ bursts = bursts[1:-1]
+ if "trim" in stages:
+ "After trimming:"
for burst in bursts:
print burst
# FIXME: more analysis goes here
if __name__ == "__main__":
- stage = None
+ stages = ""
try:
(options, arguments) = getopt.getopt(sys.argv[1:], "s:v")
for (switch, val) in options:
if (switch == '-s'):
- stage = val # Stop at specicified stage
+ stages = val # Stop at specicified stage
elif (switch == '-v'):
verbose += 1
except getopt.GetoptError, msg:
@@ -137,7 +146,7 @@ if __name__ == "__main__":
if arguments:
for filename in arguments:
fp = open(filename)
- analyze(fp, stage)
+ analyze(fp, stages)
fp.close()
else:
analyze(sys.stdin)