mavsearch.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 
3 '''
4 search a set of log files for a condition
5 '''
6 from __future__ import print_function
7 
8 from pymavlink import mavutil
9 
10 from argparse import ArgumentParser
11 parser = ArgumentParser(description=__doc__)
12 parser.add_argument("--condition", default=None, help="conditional check on log")
13 parser.add_argument("--types", default=None, help="message types to look for (comma separated)")
14 parser.add_argument("--stop", action='store_true', help="stop when message type found")
15 parser.add_argument("--stopcondition", action='store_true', help="stop when condition met")
16 parser.add_argument("logs", metavar="LOG", nargs="+")
17 
18 args = parser.parse_args()
19 
20 def mavsearch(filename):
21  print("Loading %s ..." % filename)
22  mlog = mavutil.mavlink_connection(filename)
23  if args.types is not None:
24  types = args.types.split(',')
25  else:
26  types = None
27  while True:
28  m = mlog.recv_match(type=types)
29  if m is None:
30  break
31  if mlog.check_condition(args.condition):
32  print(m)
33  if args.stopcondition:
34  break
35  if args.stop:
36  break
37 
38 
39 for f in args.logs:
40  mavsearch(f)


mavlink
Author(s): Lorenz Meier
autogenerated on Sun Jul 7 2019 03:22:07