Skip to content

Commit

Permalink
Mavdumplog: Handle TLog files saved with .log extension
Browse files Browse the repository at this point in the history
DFReader: is_text_log should return false if binary

Mavlogdump: use class type not file ext to determine input format, to allow .log to be either text or tlog
Update description text in mavlogdump file header
  • Loading branch information
shancock884 committed Jan 11, 2024
1 parent 0a6dbf3 commit 413415e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
6 changes: 4 additions & 2 deletions DFReader.py
Original file line number Diff line number Diff line change
Expand Up @@ -1085,8 +1085,10 @@ def make_format_msgbuf(self, fmt):
def DFReader_is_text_log(filename):
'''return True if a file appears to be a valid text log'''
with open(filename, 'r') as f:
ret = (f.read(8000).find('FMT,') != -1)

try:
ret = (f.read(8000).find('FMT,') != -1)
except UnicodeDecodeError:
ret = False
return ret


Expand Down
13 changes: 7 additions & 6 deletions tools/mavlogdump.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
#!/usr/bin/env python

'''
example program that dumps a Mavlink log file. The log file is
assumed to be in the format that qgroundcontrol uses, which consists
Dumps out the contents a log file in the requsted format.
The input log file may by a dataflash file in binary (.bin, .px4log)
or text (.log) format, or a telemetry log (.tlog, .log) consisting of
of a series of MAVLink packets, each with a 64 bit timestamp
header. The timestamp is in microseconds since 1970 (unix epoch)
'''
Expand Down Expand Up @@ -69,6 +70,7 @@
import inspect

from pymavlink import mavutil
from pymavlink import DFReader


if args.profile:
Expand Down Expand Up @@ -99,10 +101,9 @@
if nottypes is not None:
nottypes = nottypes.split(',')

ext = os.path.splitext(filename)[1]
isbin = ext in ['.bin', '.BIN', '.px4log']
islog = ext in ['.log', '.LOG'] # NOTE: "islog" does not mean a tlog
istlog = ext in ['.tlog', '.TLOG']
isbin = isinstance(mlog,DFReader.DFReader_binary)
islog = isinstance(mlog,DFReader.DFReader_text) # NOTE: "islog" does not mean a tlog
istlog = isinstance(mlog,mavutil.mavmmaplog)

# list of msgs to reduce in rate when --reduce is used
reduction_msgs = ['NKF*', 'XKF*', 'IMU*', 'AHR2', 'BAR*', 'ATT', 'BAT*', 'CTUN', 'NTUN', 'GP*', 'IMT*', 'MAG*', 'PL', 'POS', 'POW*', 'RATE', 'RC*', 'RFND', 'UBX*', 'VIBE', 'NKQ*', 'MOT*', 'CTRL', 'FTS*', 'DSF', 'CST*', 'LOS*', 'UWB*']
Expand Down

0 comments on commit 413415e

Please sign in to comment.