Skip to content
Snippets Groups Projects
Commit 2af15b1e authored by Peter Barker's avatar Peter Barker Committed by Peter Barker
Browse files

mavmsgstats.py: add capability to parse tlogs

parent d22e21cf
Branches
Tags
No related merge requests found
......@@ -13,6 +13,8 @@ parser.add_argument("logs", metavar="LOG", nargs="+")
args = parser.parse_args()
os.environ['MAVLINK20'] = '1'
from pymavlink import mavutil
categories = {
......@@ -32,11 +34,33 @@ def show_stats(logfile):
'''show stats on a file'''
print("Processing log %s" % filename)
mlog = mavutil.mavlink_connection(filename)
sizes = {}
total_size = 0
names = mlog.name_to_id.keys()
pairs = []
if filename.endswith("tlog"):
counts = {}
names = []
while True:
m = mlog.recv_match()
if m is None:
break
t = m.get_type()
if t not in counts:
sizes[t] = m._header.mlen
counts[t] = 0
names.append(t)
counts[t] += 1
for (name, size) in sizes.items():
size_for_this_message = size * counts[name]
pairs.append((name, size_for_this_message))
total_size += size_for_this_message
else:
names = mlog.name_to_id.keys()
for name in names:
sizes[name] = 0
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment