mavsigloss.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 
3 '''
4 show times when signal is lost
5 '''
6 from __future__ import print_function
7 
8 import time
9 
10 from argparse import ArgumentParser
11 parser = ArgumentParser(description=__doc__)
12 parser.add_argument("--no-timestamps", dest="notimestamps", action='store_true', help="Log doesn't have timestamps")
13 parser.add_argument("--planner", action='store_true', help="use planner file format")
14 parser.add_argument("--robust", action='store_true', help="Enable robust parsing (skip over bad data)")
15 parser.add_argument("--deltat", type=float, default=1.0, help="loss threshold in seconds")
16 parser.add_argument("--condition", default=None, help="select packets by condition")
17 parser.add_argument("--types", default=None, help="types of messages (comma separated)")
18 parser.add_argument("logs", metavar="LOG", nargs="+")
19 
20 args = parser.parse_args()
21 
22 from pymavlink import mavutil
23 
24 
25 def sigloss(logfile):
26  '''work out signal loss times for a log file'''
27  print("Processing log %s" % filename)
28  mlog = mavutil.mavlink_connection(filename,
29  planner_format=args.planner,
30  notimestamps=args.notimestamps,
31  robust_parsing=args.robust)
32 
33  last_t = 0
34 
35  types = args.types
36  if types is not None:
37  types = types.split(',')
38 
39  while True:
40  m = mlog.recv_match(condition=args.condition)
41  if m is None:
42  return
43  if types is not None and m.get_type() not in types:
44  continue
45  if args.notimestamps:
46  if not 'usec' in m._fieldnames:
47  continue
48  t = m.usec / 1.0e6
49  else:
50  t = m._timestamp
51  if last_t != 0:
52  if t - last_t > args.deltat:
53  print("Sig lost for %.1fs at %s" % (t-last_t, time.asctime(time.localtime(t))))
54  last_t = t
55 
56 total = 0.0
57 for filename in args.logs:
58  sigloss(filename)


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