tools: Allow LogAnalyzer to read from stdin rather than just files
Use - intead of the filename
This commit is contained in:
parent
4c22aa20ad
commit
a756e4f3ef
@ -8,6 +8,7 @@ import collections
|
||||
import os
|
||||
import numpy
|
||||
import bisect
|
||||
import sys
|
||||
|
||||
|
||||
class Format:
|
||||
@ -280,7 +281,10 @@ class DataflashLog:
|
||||
'''returns on successful log read (including bad lines if ignoreBadlines==True), will throw an Exception otherwise'''
|
||||
# TODO: dataflash log parsing code is pretty hacky, should re-write more methodically
|
||||
self.filename = logfile
|
||||
f = open(self.filename, 'r')
|
||||
if self.filename == '<stdin>':
|
||||
f = sys.stdin
|
||||
else:
|
||||
f = open(self.filename, 'r')
|
||||
if f.read(4) == '\xa3\x95\x80\x80':
|
||||
raise Exception("Unable to parse binary log files at this time, will be added soon")
|
||||
f.seek(0)
|
||||
@ -385,7 +389,7 @@ class DataflashLog:
|
||||
|
||||
# gather some general stats about the log
|
||||
self.lineCount = lineNumber
|
||||
self.filesizeKB = os.path.getsize(self.filename) / 1024.0
|
||||
self.filesizeKB = f.tell() / 1024.0
|
||||
# TODO: switch duration calculation to use TimeMS values rather than GPS timestemp
|
||||
if "GPS" in self.channels:
|
||||
# the GPS time label changed at some point, need to handle both
|
||||
|
@ -206,7 +206,7 @@ def main():
|
||||
|
||||
# deal with command line arguments
|
||||
parser = argparse.ArgumentParser(description='Analyze an APM Dataflash log for known issues')
|
||||
parser.add_argument('logfile', type=argparse.FileType('r'), help='path to Dataflash log file')
|
||||
parser.add_argument('logfile', type=argparse.FileType('r'), help='path to Dataflash log file (or - for stdin)')
|
||||
parser.add_argument('-q', '--quiet', metavar='', action='store_const', const=True, help='quiet mode, do not print results')
|
||||
parser.add_argument('-p', '--profile', metavar='', action='store_const', const=True, help='output performance profiling data')
|
||||
parser.add_argument('-s', '--skip_bad', metavar='', action='store_const', const=True, help='skip over corrupt dataflash lines')
|
||||
|
Loading…
Reference in New Issue
Block a user