Did I find the right examples for you? yes no      Crawl my project      Python Jobs

All Samples(23)  |  Call(16)  |  Derive(0)  |  Import(7)
Generate mavlink message formatters and parsers (C and Python ) using options
and args where args are a list of xml files. This function allows python
scripts under Windows to control mavgen using the same interface as
shell scripts under Unix

        def mavgen(opts, args) :
    """Generate mavlink message formatters and parsers (C and Python ) using options
    and args where args are a list of xml files. This function allows python
    scripts under Windows to control mavgen using the same interface as
    shell scripts under Unix"""

    xml = []

    for fname in args:
        if performValidation:
            print("Validating %s" % fname)
            mavgen_validate(fname, schemaFile, opts.error_limit);
        else:
            print("Validation skipped for %s." % fname)

        print("Parsing %s" % fname)
        xml.append(mavparse.MAVXML(fname, opts.wire_protocol))

    # expand includes
    for x in xml[:]:
        for i in x.include:
            fname = os.path.join(os.path.dirname(x.filename), i)

            ## Validate XML file with XSD file if possible.
            if performValidation:
                print("Validating %s" % fname)
                mavgen_validate(fname, schemaFile, opts.error_limit);
            else:
                print("Validation skipped for %s." % fname)

            ## Parsing
            print("Parsing %s" % fname)
            xml.append(mavparse.MAVXML(fname, opts.wire_protocol))

            # include message lengths and CRCs too
            for idx in range(0, 256):
                if x.message_lengths[idx] == 0:
                    x.message_lengths[idx] = xml[-1].message_lengths[idx]
                    x.message_crcs[idx] = xml[-1].message_crcs[idx]
                    x.message_names[idx] = xml[-1].message_names[idx]

    # work out max payload size across all includes
    largest_payload = 0
    for x in xml:
        if x.largest_payload > largest_payload:
            largest_payload = x.largest_payload
    for x in xml:
        x.largest_payload = largest_payload

    if mavparse.check_duplicates(xml):
        sys.exit(1)

    print("Found %u MAVLink message types in %u XML files" % (
        mavparse.total_msgs(xml), len(xml)))

    # Convert language option to lowercase and validate
    opts.language = opts.language.lower()
    if opts.language == 'python':
        import mavgen_python
        mavgen_python.generate(opts.output, xml)
    elif opts.language == 'c':
        try:
            import mavgen_c
        except Exception:
            from pymavlink.generator import mavgen_c
        mavgen_c.generate(opts.output, xml)
    elif opts.language == 'wlua':
        import mavgen_wlua
        mavgen_wlua.generate(opts.output, xml)
    elif opts.language == 'cs':
        import mavgen_cs
        mavgen_cs.generate(opts.output, xml)
    elif opts.language == 'javascript':
        import mavgen_javascript
        mavgen_javascript.generate(opts.output, xml)
    else:
        print("Unsupported language %s" % opts.language)
        


src/m/a/mavlink-HEAD/pymavlink/generator/gen_all.py   mavlink(Download)
 
import os, sys, glob, re
from mavgen import mavgen
 
class options:
        args = []
        args.append(xml_file)
        mavgen(opts, args)
        xml_file_base = os.path.basename(xml_file)
        xml_file_base = re.sub("\.xml","", xml_file_base)
        print "xml_file_base is", xml_file_base
        opts = options(lang = "python", \
                       output="python/mavlink_"+xml_file_base+"_v"+protocol+".py", \
                       wire_protocol=protocol, error_limit=200)
        mavgen(opts,args)
                       output="CS/v" + protocol + "/mavlink_" + xml_file_base + "/mesages", \
                       wire_protocol=protocol, error_limit=200)
        mavgen(opts,args)
 

src/p/y/pymavlink-1.1.29/generator/gen_all.py   pymavlink(Download)
 
import os, sys, glob, re
from mavgen import mavgen
 
class options:
        args = []
        args.append(xml_file)
        mavgen(opts, args)
        xml_file_base = os.path.basename(xml_file)
        xml_file_base = re.sub("\.xml","", xml_file_base)
        print "xml_file_base is", xml_file_base
        opts = options(lang = "python", \
                       output="python/mavlink_"+xml_file_base+"_v"+protocol+".py", \
                       wire_protocol=protocol, error_limit=200)
        mavgen(opts,args)
                       output="CS/v" + protocol + "/mavlink_" + xml_file_base + "/mesages", \
                       wire_protocol=protocol, error_limit=200)
        mavgen(opts,args)
 

src/m/a/mavlink-HEAD/pymavlink/generator/gen_MatrixPilot.py   mavlink(Download)
import os, sys, glob, re
from shutil import copy
from mavgen import mavgen
 
# allow import from the parent directory, where mavutil.py is
    args.append(xml_file)
    print "About to generate C include files"
    mavgen(opts, args)
    opts = options(lang = "python", \
                   output="python/mavlink_"+xml_file_base+"_v"+protocol+".py", \
                   wire_protocol=protocol, error_limit=200)
    print "About to generate python parsers"
    mavgen(opts,args)

src/p/y/pymavlink-1.1.29/generator/gen_MatrixPilot.py   pymavlink(Download)
import os, sys, glob, re
from shutil import copy
from mavgen import mavgen
 
# allow import from the parent directory, where mavutil.py is
    args.append(xml_file)
    print "About to generate C include files"
    mavgen(opts, args)
    opts = options(lang = "python", \
                   output="python/mavlink_"+xml_file_base+"_v"+protocol+".py", \
                   wire_protocol=protocol, error_limit=200)
    print "About to generate python parsers"
    mavgen(opts,args)

src/p/y/pymavlink-HEAD/generator/gen_MatrixPilot.py   pymavlink(Download)
import os, sys, glob, re
from shutil import copy
from mavgen import mavgen
 
# allow import from the parent directory, where mavutil.py is
    args = []
    args.append(xml_file)
    mavgen(opts, args)
    xml_file_base = os.path.basename(xml_file)
    xml_file_base = re.sub("\.xml","", xml_file_base)
    print "xml_file_base is", xml_file_base
    opts = options(lang = "python", \
                   output="python/mavlink_"+xml_file_base+"_v"+protocol+".py", \
                   wire_protocol=protocol)
    mavgen(opts,args)

src/p/y/pymavlink-HEAD/generator/gen_all.py   pymavlink(Download)
 
import os, sys, glob, re
from mavgen import mavgen
 
# allow import from the parent directory, where mavutil.py is
        args = []
        args.append(xml_file)
        mavgen(opts, args)
        xml_file_base = os.path.basename(xml_file)
        xml_file_base = re.sub("\.xml","", xml_file_base)
        print "xml_file_base is", xml_file_base
        opts = options(lang = "python", \
                       output="python/mavlink_"+xml_file_base+"_v"+protocol+".py", \
                       wire_protocol=protocol)
        mavgen(opts,args)

src/m/i/MissionPlanner-HEAD/ExtLibs/Mavlink/gen_all.py   MissionPlanner(Download)
 
import os, sys, glob, re
from mavgen import mavgen
 
# allow import from the parent directory, where mavutil.py is
        args = []
        args.append(xml_file)
        mavgen(opts, args)
        xml_file_base = os.path.basename(xml_file)
        xml_file_base = re.sub("\.xml","", xml_file_base)
        print "xml_file_base is", xml_file_base
        mavgen(opts,args)