Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

DFReader: Create DFMetaData class to handle logger metadata #929

Merged
merged 1 commit into from
Apr 2, 2024

Conversation

shancock884
Copy link
Contributor

This PR adds a DFMetaData class to the DFReader.m file, which is used to handle LogMessage XML meta-data for use by MAVExplorer and potentially other tools. It links to PR ArduPilot/MAVProxy#1337.

The class is set as the metadata attribute of DFReader class, and at present includes methods:

  • reset - clear cached data, in case of new download, or change of vehicle type
  • dot_mavproxy - copy of function in mp_util, to avoid dependency on MavProxy
  • metadata_tree - return metadata map for use by other function, including cached version once loaded.
  • print_help - print the help for specified log message
  • get_description - return the description of the specified log message

Tested using the "logmessage help" command in MAVExplorer (with PR ArduPilot/MAVProxy#1337). For example:

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

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.

Have you checked how much extra RAM this consumes when you load an ArduPlane logfile? Is it simply roughly equal to the size of the metadata file, or does it blow out?

Also, what's the parse-time like on the file? "not noticable" is probably the answer, but a quick check with a pair of time.time() calls would be nice.

DFReader.py Outdated Show resolved Hide resolved
DFReader.py Outdated Show resolved Hide resolved
DFReader.py Outdated Show resolved Hide resolved
DFReader.py Outdated Show resolved Hide resolved
DFReader.py Outdated Show resolved Hide resolved
DFReader.py Outdated Show resolved Hide resolved
DFReader.py Outdated Show resolved Hide resolved
DFReader.py Outdated Show resolved Hide resolved
DFReader.py Outdated Show resolved Hide resolved
DFReader.py Outdated Show resolved Hide resolved
DFReader.py Outdated Show resolved Hide resolved
DFReader.py Outdated Show resolved Hide resolved
DFReader.py Outdated Show resolved Hide resolved
@peterbarker
Copy link
Contributor

peterbarker commented Mar 21, 2024 via email

DFMetaData added as metadata attribute of DFReader class
download static method to download XML into .pymavlink/LogMessages
When needed, reads <vehicle>.xml file from ~/.pymavlink/LogMessages
Method for printing help text for MAVExplorer 'logmessage help' command
Method for returning log message description
Applied code update suggestions and performed flake8 check on new code

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

Have you checked how much extra RAM this consumes when you load an ArduPlane logfile? Is it simply roughly equal to the size of the metadata file, or does it blow out?

Also, what's the parse-time like on the file? "not noticable" is probably the answer, but a quick check with a pair of time.time() calls would be nice.

I still need to do the RAM/CPU time check, but I think all other comments are addressed.

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

@staticmethod
def download_url(url):
'''download a URL and return the content'''
if sys.version_info.major < 3:
Copy link
Contributor

Choose a reason for hiding this comment

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

Probably don't need this compatability code. IIRC the "exists_ok" used below makes this stuff Py3 only anyway...

with gzip.GzipFile(fileobj=io.BytesIO(data)) as gz:
data = gz.read()
try:
open(file, mode='wb').write(data)
Copy link
Contributor

Choose a reason for hiding this comment

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

I've become rather partial to pathlib myself, but I do understand this is just swiped from MAVProxy.

resp = url_open(url)
except url_error as e:
print('Error downloading %s : %s' % (url, e))
return None
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if we really should be doing this rather than making the caller catch the exceptions...

if data is None:
continue
# decompress it...
with gzip.GzipFile(fileobj=io.BytesIO(data)) as gz:
Copy link
Contributor

Choose a reason for hiding this comment

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

We actually also produce .xz for these... they're about 75% the size of the .gz

@peterbarker peterbarker merged commit 2f6e31e into ArduPilot:master Apr 2, 2024
12 checks passed
@peterbarker
Copy link
Contributor

Tested it. Merged,thanks!

@shancock884 shancock884 deleted the logmessage-help branch April 2, 2024 14:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants