diff --git a/examples/rewrite_log.py b/examples/rewrite_log.py new file mode 100755 index 000000000..22e4b1557 --- /dev/null +++ b/examples/rewrite_log.py @@ -0,0 +1,52 @@ +#!/usr/bin/env python +''' +example of rewriting a log with changed values + +this can be useful when wanting to replay a log with different values +''' + +import os +from argparse import ArgumentParser +from progress.bar import Bar +import time +import struct + +parser = ArgumentParser(description=__doc__) + +parser.add_argument("login") +parser.add_argument("logout") + +args = parser.parse_args() + +from pymavlink import mavutil +from pymavlink import DFReader +import struct + +print("Opening %s" % args.login) +login = mavutil.mavlink_connection(args.login) +output = open(args.logout, mode='wb') + +def write_message(m): + mtype = m.get_type() + buf = bytearray(m.get_msgbuf()) + if mtype == 'RRLT' and m.Idx == 2: + # fix beacon location + buf2 = buf[:3] + struct.pack("