forked from ArduPilot/ardupilot
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Tools: add script to hexdump logged SPI Registers
- Loading branch information
1 parent
89e693e
commit f7bfa5d
Showing
1 changed file
with
54 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 = "" |