mavparms.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 
3 '''
4 extract mavlink parameter values
5 '''
6 from __future__ import print_function
7 
8 
9 import time
10 
11 from argparse import ArgumentParser
12 parser = ArgumentParser(description=__doc__)
13 parser.add_argument("-c", "--changes", dest="changesOnly", default=False, action="store_true", help="Show only changes to parameters.")
14 parser.add_argument("logs", metavar="LOG", nargs="+")
15 
16 args = parser.parse_args()
17 
18 from pymavlink import mavutil
19 
20 parms = {}
21 
22 def mavparms(logfile):
23  '''extract mavlink parameters'''
24  mlog = mavutil.mavlink_connection(filename)
25 
26  while True:
27  try:
28  m = mlog.recv_match(type=['PARAM_VALUE', 'PARM'])
29  if m is None:
30  return
31  except Exception:
32  return
33  if m.get_type() == 'PARAM_VALUE':
34  pname = str(m.param_id).strip()
35  value = m.param_value
36  else:
37  pname = m.Name
38  value = m.Value
39  if len(pname) > 0:
40  if args.changesOnly is True and pname in parms and parms[pname] != value:
41  print("%s %-15s %.6f -> %.6f" % (time.asctime(time.localtime(m._timestamp)), pname, parms[pname], value))
42 
43  parms[pname] = value
44 
45 total = 0.0
46 for filename in args.logs:
47  mavparms(filename)
48 
49 if (args.changesOnly is False):
50  keys = list(parms.keys())
51  keys.sort()
52  for p in keys:
53  print("%-15s %.6f" % (p, parms[p]))


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