4 parse a MAVLink protocol XML file and generate a python implementation 6 Copyright Andrew Tridgell 2011 7 Released under GNU GPL version 3 or later 12 if __name__ ==
"__main__" and __package__
is None:
13 from os
import sys, path
14 sys.path.insert(0, path.dirname(path.dirname(path.dirname(path.abspath(__file__)))))
19 from argparse
import ArgumentParser
21 parser = ArgumentParser(description=
"This tool generate implementations from MAVLink message definitions")
22 parser.add_argument(
"-o",
"--output", default=
"mavlink", help=
"output directory.")
23 parser.add_argument(
"--lang", dest=
"language", choices=mavgen.supportedLanguages, default=mavgen.DEFAULT_LANGUAGE, help=
"language of generated code [default: %(default)s]")
24 parser.add_argument(
"--wire-protocol", choices=[mavparse.PROTOCOL_0_9, mavparse.PROTOCOL_1_0, mavparse.PROTOCOL_2_0], default=mavgen.DEFAULT_WIRE_PROTOCOL, help=
"MAVLink protocol version. [default: %(default)s]")
25 parser.add_argument(
"--no-validate", action=
"store_false", dest=
"validate", default=mavgen.DEFAULT_VALIDATE, help=
"Do not perform XML validation. Can speed up code generation if XML files are known to be correct.")
26 parser.add_argument(
"--error-limit", default=mavgen.DEFAULT_ERROR_LIMIT, help=
"maximum number of validation errors to display")
27 parser.add_argument(
"--strict-units", action=
"store_true", dest=
"strict_units", default=mavgen.DEFAULT_STRICT_UNITS, help=
"Perform validation of units attributes.")
28 parser.add_argument(
"definitions", metavar=
"XML", nargs=
"+", help=
"MAVLink definitions")
29 args = parser.parse_args()
31 mavgen.mavgen(args, args.definitions)