Skip to content

Commit

Permalink
Tools: add script to hexdump logged SPI Registers
Browse files Browse the repository at this point in the history
  • Loading branch information
bugobliterator committed Mar 5, 2024
1 parent 89e693e commit f7bfa5d
Showing 1 changed file with 54 additions and 0 deletions.
54 changes: 54 additions & 0 deletions Tools/scripts/logregdump.py
Original file line number Diff line number Diff line change
@@ -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 = ""

0 comments on commit f7bfa5d

Please sign in to comment.