Skip to content

Commit

Permalink
MAVExplorer: Add logmessage download/help commands
Browse files Browse the repository at this point in the history
Download LogMessage XML to .mavproxy folder
Use DFMetaData class to pring logmessage help
Add message description to stats command
  • Loading branch information
shancock884 committed Feb 25, 2024
1 parent 13a2244 commit 35e94b9
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 4 deletions.
10 changes: 9 additions & 1 deletion MAVProxy/modules/lib/msgstats.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,15 @@ def show_stats(mlog):
pairs = sorted(pairs, key = lambda p : p[1])
for (name,size) in pairs:
if size > 0:
print("%-*s %.2f%%" % (maxnamelen, name, 100.0 * size / total_size))
descstr = ''
if hasattr(mlog,'metadata'):
desc = mlog.metadata.get_description(name)
if desc:
if len(desc) > 65:
descstr = " [%s...]" % desc[:62]
else:
descstr = " [%s]" % desc
print("%-*s %.2f%%%s" % (maxnamelen, name, 100.0 * size / total_size, descstr))

print("")
category_total = 0
Expand Down
42 changes: 39 additions & 3 deletions MAVProxy/tools/MAVExplorer.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ def __init__(self):
"dump" : ['(MESSAGETYPE)', '--verbose (MESSAGETYPE)'],
"map" : ['(VARIABLE) (VARIABLE) (VARIABLE) (VARIABLE) (VARIABLE)'],
"param" : ['download', 'check', 'help (PARAMETER)'],
"logmessage": ['download', 'help (MESSAGETYPE)'],
}
self.aliases = {}
self.graphs = []
Expand Down Expand Up @@ -336,12 +337,16 @@ def load_graphs():
if filename.lower().endswith('.xml'):
gfiles.append(os.path.join(dirname, filename))

# list of parameter files to be skipped when loading graph XML
paramfiles = ["ArduSub.xml", "ArduPlane.xml", "APMrover2.xml", "ArduCopter.xml", "AntennaTracker.xml", "Blimp.xml", "Rover.xml"]
# loop though files
for file in gfiles:
if not os.path.exists(file):
continue
# skip parameter files. They specify an encoding, and under
# Python3 this leads to a warning from etree
if os.path.basename(file) in ["ArduSub.xml", "ArduPlane.xml", "APMrover2.xml", "ArduCopter.xml", "AntennaTracker.xml", "Blimp.xml", "Rover.xml"]:
# skip parameter and log message files. They specify an encoding,
# and under Python3 this leads to a warning from etree
basename = os.path.basename(file)
if (basename in paramfiles) or basename.startswith("LogMessages_"):
continue
graphs = load_graph_xml(open(file).read(), file)
if graphs:
Expand Down Expand Up @@ -1176,6 +1181,36 @@ def cmd_paramchange(args):
vmap[pname] = pvalue
mestate.mlog.rewind()

def cmd_logmessage(args):
'''show log message information'''
mlog = mestate.mlog
usage = "Usage: logmessage <help|download>"
if len(args) > 0:
if args[0] == 'help':
if len(args) < 2:
print(usage)
return
if hasattr(mlog,'metadata'):
mlog.metadata.print_help(args[1])
return
if args[0] == 'download':
# download XML files for log messages
files = []
for vehicle in ['Rover', 'Copter', 'Plane', 'Tracker', 'Blimp', 'Sub']:
url = 'http://autotest.ardupilot.org/LogMessages/%s/LogMessages.xml.gz' % vehicle
path = mp_util.dot_mavproxy("LogMessages_%s.xml" % vehicle)
files.append((url, path))
try:
child = multiproc.Process(target=mp_util.download_files, args=(files,))
child.start()
except Exception as e:
print(e)
if hasattr(mlog,'metadata'):
mlog.metadata.reset()
return
# Print usage if we've dropped through the ifs
print(usage)

def cmd_mission(args):
'''show mission'''
if (len(args) == 1):
Expand Down Expand Up @@ -1463,6 +1498,7 @@ def main_loop():
'dump' : (cmd_dump, 'dump messages from log'),
'file' : (cmd_file, 'show files'),
'mission' : (cmd_mission, 'show mission'),
'logmessage' : (cmd_logmessage, 'show log message information'),
}

def progress_bar(pct):
Expand Down

0 comments on commit 35e94b9

Please sign in to comment.