mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-02-05 23:43:58 -04:00
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 os
|
||||||
import numpy
|
import numpy
|
||||||
import bisect
|
import bisect
|
||||||
|
import sys
|
||||||
|
|
||||||
|
|
||||||
class Format:
|
class Format:
|
||||||
@ -280,7 +281,10 @@ class DataflashLog:
|
|||||||
'''returns on successful log read (including bad lines if ignoreBadlines==True), will throw an Exception otherwise'''
|
'''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
|
# TODO: dataflash log parsing code is pretty hacky, should re-write more methodically
|
||||||
self.filename = logfile
|
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':
|
if f.read(4) == '\xa3\x95\x80\x80':
|
||||||
raise Exception("Unable to parse binary log files at this time, will be added soon")
|
raise Exception("Unable to parse binary log files at this time, will be added soon")
|
||||||
f.seek(0)
|
f.seek(0)
|
||||||
@ -385,7 +389,7 @@ class DataflashLog:
|
|||||||
|
|
||||||
# gather some general stats about the log
|
# gather some general stats about the log
|
||||||
self.lineCount = lineNumber
|
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
|
# TODO: switch duration calculation to use TimeMS values rather than GPS timestemp
|
||||||
if "GPS" in self.channels:
|
if "GPS" in self.channels:
|
||||||
# the GPS time label changed at some point, need to handle both
|
# the GPS time label changed at some point, need to handle both
|
||||||
|
@ -206,7 +206,7 @@ def main():
|
|||||||
|
|
||||||
# deal with command line arguments
|
# deal with command line arguments
|
||||||
parser = argparse.ArgumentParser(description='Analyze an APM Dataflash log for known issues')
|
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('-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('-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')
|
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