mavsearch.py
Go to the documentation of this file.
00001 #!/usr/bin/env python
00002 
00003 '''
00004 search a set of log files for a condition
00005 '''
00006 
00007 import sys, time, os
00008 
00009 from pymavlink import mavutil
00010 
00011 from argparse import ArgumentParser
00012 parser = ArgumentParser(description=__doc__)
00013 parser.add_argument("--condition", default=None, help="conditional check on log")
00014 parser.add_argument("--types", default=None, help="message types to look for (comma separated)")
00015 parser.add_argument("--stop", action='store_true', help="stop when message type found")
00016 parser.add_argument("--stopcondition", action='store_true', help="stop when condition met")
00017 parser.add_argument("logs", metavar="LOG", nargs="+")
00018 
00019 args = parser.parse_args()
00020 
00021 def mavsearch(filename):
00022     print("Loading %s ..." % filename)
00023     mlog = mavutil.mavlink_connection(filename)
00024     if args.types is not None:
00025         types = args.types.split(',')
00026     else:
00027         types = None
00028     while True:
00029         m = mlog.recv_match(type=types)
00030         if m is None:
00031             break
00032         if mlog.check_condition(args.condition):
00033             print(m)
00034             if args.stopcondition:
00035                 break
00036         if args.stop:
00037             break
00038 
00039 
00040 for f in args.logs:
00041     mavsearch(f)


mavlink
Author(s): Lorenz Meier
autogenerated on Wed Sep 9 2015 18:06:17