forked from muccc/iridium-toolkit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rx-stats.py
executable file
·57 lines (46 loc) · 1.74 KB
/
rx-stats.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/usr/bin/env python
# vim: set ts=4 sw=4 tw=0 et pm=:
# Parses .bits files and displays how many messages have
# been received over time. Usefull to tune a receiving setup
import sys
import matplotlib.pyplot as plt
import getopt
import bitutils
options, remainder = getopt.getopt(sys.argv[1:], 's:l:eo', [
'span=',
'minimum_length=',
'errors',
'lead_out_required'
])
span = 3600
minimum_length = 0
lead_out_required = False
show_errors = False
for opt, arg in options:
if opt in ('-s', '--span'):
span = int(arg)
elif opt in ('-l', '--minimum_length'):
minimum_length = int(arg)
elif opt in ('-o', '--lead_out_required'):
lead_out_required = True
elif opt in ('-e', '--errors'):
show_errors = True
else:
print opt
raise Exception("unknown argument?")
messages = bitutils.read_file(remainder)
timestamps = [s['timestamp'] for s in messages if s['length'] > minimum_length and (not lead_out_required or s['lead_out']) and (s['error'] == show_errors)]
t0 = min(timestamps)
t = max(timestamps)
bins = (t - t0)/span
filename=["<stdin>",",".join(remainder)][remainder is None]
title = "File: %s : Messages per %d seconds, longer than %d symbols" % (filename, span, minimum_length)
if lead_out_required:
title += ', lead out needs to be present'
else:
title += ', lead out does not need to be present'
if show_errors:
title += " and having decoding errors"
plt.title(title)
plt.hist(timestamps, bins)
plt.show()