Beispiel #1
0
    def write(self):
        gentools.print_header("BUILD_H")
        if self.ok:
            gentools.define_string("BUILD_REV", self.rev, maxwidth=self.STRING_LEN)
            gentools.define_string("BUILD_BRANCH", self.branch.split("/")[-1], maxwidth=self.STRING_LEN)
            gentools.define_int("BUILD_DIRTY", self.dirty)
        else:
            gentools.define_string("BUILD_REV", "UNKNOWN")
            gentools.define_string("BUILD_BRANCH", "UNKNOWN")
            gentools.define_int("BUILD_DIRTY", 0)
        gentools.define_int("BUILD_TIME", int(time.mktime(time.localtime())))
        gentools.define_string("BUILD_TARGET", self.target, maxwidth=self.STRING_LEN)

        print
        gentools.define_int("BUILD_STRING_LEN", self.STRING_LEN)

        gentools.print_footer("BUILD_H")
Beispiel #2
0
    nrmchans = [c for c in channels if c.average == "0"]
except:
    print "Invalid or missing xml\n  %s" % USAGE
    sys.exit(1)


def norm_chan(c):
    if c.neutral == c.min:
        return "tmp_radio * (MAX_PPRZ / (float)(SIGNED_SYS_TICS_OF_USEC(%s-%s)))" % (
            c.max, c.min), "0"
    else:
        return "tmp_radio * (tmp_radio >=0 ? (MAX_PPRZ/(float)(SIGNED_SYS_TICS_OF_USEC(%s-%s))) : (MIN_PPRZ/(float)(SIGNED_SYS_TICS_OF_USEC(%s-%s))))" % (
            c.max, c.neutral, c.min, c.neutral), "MIN_PPRZ"


gentools.print_header(H, generatedfrom=os.path.abspath(sys.argv[1]))

#include the complete contents of the XML file for the simulator
print
lines = open(sys.argv[1]).readlines()
print '#define RADIO_XML "\\\n%s"' % "\\\n".join(
    [l.strip().replace('"', "'") for l in lines])
print
print '#define RADIO_NAME "%s"' % radio.name
print
print '#define RADIO_CTL_NB', len(channels)
print

for p in PULSE_TYPES:
    print "#define PPM_PULSE_TYPE_%s %s" % (p, PULSE_TYPES[p])
print "#define PPM_PULSE_TYPE PPM_PULSE_TYPE_%s" % radio.pulse_type
Beispiel #3
0
 def preamble(self, outfile):
     gentools.print_header(
         self._get_include_guard(),
         generatedfrom=self.messages_path,
         outfile=outfile)
     print >> outfile
Beispiel #4
0
 def preamble(self, outfile):
     gentools.print_header(self.H, generatedfrom=self.generated_from, outfile=outfile)
     print >> outfile, '#include "std.h"\n'
Beispiel #5
0
    radio = x.root
    channels = radio.channel
    pulse_type = PULSE_TYPES[radio.pulse_type]
    avgchans = [c for c in channels if c.average == "1"]
    nrmchans = [c for c in channels if c.average == "0"]
except:
    print "Invalid or missing xml\n  %s" % USAGE
    sys.exit(1)

def norm_chan(c):
    if c.neutral == c.min:
        return "tmp_radio * (MAX_PPRZ / (float)(SIGNED_SYS_TICS_OF_USEC(%s-%s)))" % (c.max, c.min), "0"
    else:
        return "tmp_radio * (tmp_radio >=0 ? (MAX_PPRZ/(float)(SIGNED_SYS_TICS_OF_USEC(%s-%s))) : (MIN_PPRZ/(float)(SIGNED_SYS_TICS_OF_USEC(%s-%s))))" % (c.max, c.neutral, c.min, c.neutral), "MIN_PPRZ"

gentools.print_header(H, generatedfrom=os.path.abspath(sys.argv[1]))

print '#define RADIO_NAME "%s"' % radio.name
print
print '#define RADIO_CTL_NB', len(channels)
print

for p in PULSE_TYPES:
    print "#define PPM_PULSE_TYPE_%s %s" % (p, PULSE_TYPES[p])
print "#define PPM_PULSE_TYPE PPM_PULSE_TYPE_%s" % radio.pulse_type
print

i = 0
for c in channels:
    print "#define RADIO_CTL_%s %s" % (c.ctl, i)
    print "#define RADIO_%s RADIO_CTL_%s" % (c.function.upper(), c.ctl)
Beispiel #6
0
                s.print_value()
            print
        print

if __name__ == "__main__":
    H = "SETTINGS_GENERATED_H"

    parser = optparse.OptionParser()
    parser.add_option("-s", "--settings",
                    default="settings.xml",
                    help="settings xml file", metavar="FILE")
    options, args = parser.parse_args()

    if not os.path.exists(options.settings):
        parser.error("could not find settings.xml")

    try:
        settings_path = os.path.abspath(options.settings)
        settings = SettingsWriter(path=settings_path)

    except:
        import traceback
        parser.error("invalid xml\n%s" % traceback.format_exc())

    gentools.print_header(H, generatedfrom=settings_path)
    print '#include "std.h"\n'
    settings.print_typedefs()
    settings.print_defines()
    settings.print_values()
    gentools.print_footer(H)
Beispiel #7
0
 def preamble(self, outfile):
     gentools.print_header(self._get_include_guard(),
                           generatedfrom=self.messages_path,
                           outfile=outfile)
     print >> outfile