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

Mavdumplog: Handle TLog files saved with .log extension #900

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions DFReader.py
Original file line number Diff line number Diff line change
Expand Up @@ -1208,8 +1208,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
Loading