Skip to content

Commit 471c60b

Browse files
committed
Mavdumplog: Handle TLog files saved with .log extension
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
1 parent 55fcf4d commit 471c60b

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

DFReader.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1208,8 +1208,10 @@ def make_format_msgbuf(self, fmt):
12081208
def DFReader_is_text_log(filename):
12091209
'''return True if a file appears to be a valid text log'''
12101210
with open(filename, 'r') as f:
1211-
ret = (f.read(8000).find('FMT,') != -1)
1212-
1211+
try:
1212+
ret = (f.read(8000).find('FMT,') != -1)
1213+
except UnicodeDecodeError:
1214+
ret = False
12131215
return ret
12141216

12151217

tools/mavlogdump.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
#!/usr/bin/env python
22

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

7172
from pymavlink import mavutil
73+
from pymavlink import DFReader
7274

7375

7476
if args.profile:
@@ -99,10 +101,9 @@
99101
if nottypes is not None:
100102
nottypes = nottypes.split(',')
101103

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

107108
# list of msgs to reduce in rate when --reduce is used
108109
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*']

0 commit comments

Comments
 (0)