diff --git a/Tools/scripts/logregdump.py b/Tools/scripts/logregdump.py new file mode 100755 index 00000000000000..1cb2058e1d1a07 --- /dev/null +++ b/Tools/scripts/logregdump.py @@ -0,0 +1,54 @@ +#!/usr/bin/env python +# +# logregdump.py -- does hexdump of the DEVR messages in a log file +# + +from __future__ import print_function + +import fnmatch +import json +import os +import struct +import time + +try: + from pymavlink.mavextra import * +except: + print("WARNING: Numpy missing, mathematical notation will not be supported..") + +from argparse import ArgumentParser +parser = ArgumentParser(description=__doc__) + +parser.add_argument("--dev-id", type=int, default=0x122, help="filter by source system ID") +parser.add_argument("log", metavar="LOG") +args = parser.parse_args() + +import inspect + +from pymavlink import mavutil + +# Track types found +available_types = set() + +filename = args.log +mlog = mavutil.mavlink_connection(filename) +str_hex = "" +while True: + m = mlog.recv_match(type=["DEVR"]) + if m is None: + # FIXME: Make sure to output the last CSV message before dropping out of this loop + break + if m.DevID != args.dev_id: + continue + if m.RS == 0: + if len(str_hex) != 0: + print(str_hex) + str_hex = "" + print("\r\n\r\n############ HEX DUMP OF DEVID: 0x%x Bank: 0x%x ############" % (m.DevID, m.Bank)) + # do a hex dump + if (m.RS % 16) == 0: + str_hex = "%02X: " % m.RS + str_hex += "%02X %02X %02X %02X %02X %02X %02X %02X " % (m.R1, m.R2, m.R3, m.R4, m.R5, m.R6, m.R7, m.R8) + if (m.RS % 16): + print(str_hex) + str_hex = "" \ No newline at end of file