diff --git a/DFReader.py b/DFReader.py index 3e20ae367..480650378 100644 --- a/DFReader.py +++ b/DFReader.py @@ -1086,8 +1086,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 diff --git a/tools/mavlogdump.py b/tools/mavlogdump.py index f771790a1..9765b2466 100755 --- a/tools/mavlogdump.py +++ b/tools/mavlogdump.py @@ -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) ''' @@ -69,6 +70,7 @@ import inspect from pymavlink import mavutil +from pymavlink import DFReader if args.profile: @@ -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*']