Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

MAVExplorer: Add logmessage download and help commands, using meta-data from autotest web site #1337

Merged
merged 1 commit into from
Apr 2, 2024

Conversation

shancock884
Copy link
Contributor

@shancock884 shancock884 commented Mar 10, 2024

The aim of this PR is to start making use of the LogMessage xml files in MAVExplorer.

This PR adds the commands "logmessage download" and "logmessage help " to MAVExplorer.
The download command will download all LogMessage XMLs to the user's .mavproxy folder.
The help command calls mlog.metadata.print_help(msg) method on the new DFMetaData class (links to PR ArduPilot/pymavlink#929).

The DFMetaData class is implemented in DFReader.py file, within pymavlink, so that other tools, such as mavlogdump can access the meta data on a loaded DF file without a dependency on MAVProxy. For example, to provide the enum strings and bitmask information when doing "mavlogdump --verbose".
Any call to mlog.metadata is protected with hasattr(mlog,'metadata') in case mlog is a TLOG or if the the pymavlink in use is older, and does not yet have the attribute.
I also updated load_graphs function to avoid XML warnings when it tries to load *.xml from .mavproxy folder.

An example of the output is as follows:

MAV> logmessage help ORGN
Log Message: ORGN
Vehicle navigation origin or other notable position

TimeUS [μs] : Time since system startup
Type [instance] : Position type
Lat [deglatitude] : Position latitude
Lng [deglongitude] : Position longitude
Alt [m] : Position altitude

@peterbarker
Copy link
Contributor

peterbarker commented Mar 13, 2024 via email

@shancock884 shancock884 force-pushed the logmessage-help branch 2 times, most recently from a3c44be to 1b07864 Compare March 14, 2024 11:56
Copy link
Contributor

@peterbarker peterbarker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very cool.

MAVProxy/tools/MAVExplorer.py Outdated Show resolved Hide resolved
'''show log message information'''
mlog = mestate.mlog
usage = "Usage: logmessage <help|download>"
if len(args) > 0:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if len(args) > 0:
if len(args) <= 0:
print(usage)
return

... save indenting / context complication

.... logmessage list to show fields which are understood, perhaps? Or are in the intersection of what help can provide and what's in the log? ("future enhancement" :-) )

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logmessage list is probably a quick enough thing for me to add now.
The tab completion gives only the messages that exist in the log file, but you can actually ask for help on any message in the XML for the current vehicle type.

MAVProxy/tools/MAVExplorer.py Outdated Show resolved Hide resolved
mlog.metadata.print_help(args[1])
return
if args[0] == 'download':
# download XML files for log messages
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Length-wise, this is on the border of making a new separate cmd_logmessage_download a good idea.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now that download is now implemented on pymavlink side, this code is shorter, so I maybe length is now OK to keep here?

Use DFMetaData.download to download XML files to .pymavlink/LogMessages
Use DFMetaData.print_help to print logmessage help
Apply suggestions, and perform flake8 check on new code

Co-authored-by: Peter Barker <pb-gh@barker.dropbear.id.au>
Copy link
Contributor

@peterbarker peterbarker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

Tested it.

Merging, thanks!

Comment on lines +337 to +339
# Skip XML files in the LogMessages subfolder
if os.path.basename(dirname) == "LogMessages":
continue
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't need this bit any more.

@peterbarker peterbarker merged commit ee73e97 into ArduPilot:master Apr 2, 2024
2 checks passed
@shancock884 shancock884 deleted the logmessage-help branch April 2, 2024 14:45
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants