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 print logmessage help
  • Loading branch information
shancock884 committed Feb 25, 2024
1 parent c70bf1b commit bba5dd4
Showing 1 changed file with 39 additions and 3 deletions.
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)'],
"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 bba5dd4

Please sign in to comment.