diff options
author | Thomas Gubler <thomasgubler@gmail.com> | 2014-12-01 17:45:10 +0100 |
---|---|---|
committer | Thomas Gubler <thomasgubler@gmail.com> | 2014-12-01 17:45:10 +0100 |
commit | 2eeeab8ecd04cdbf4ef80161a1708c140a9d8ba6 (patch) | |
tree | 6ab7cecbe8709966d852431a5bc5d39e9e49911d /msg | |
parent | 6a2fcb8874ba996fb7f5914376197a38b7e73459 (diff) | |
download | px4-firmware-2eeeab8ecd04cdbf4ef80161a1708c140a9d8ba6.tar.gz px4-firmware-2eeeab8ecd04cdbf4ef80161a1708c140a9d8ba6.tar.bz2 px4-firmware-2eeeab8ecd04cdbf4ef80161a1708c140a9d8ba6.zip |
improve msg template file
Diffstat (limited to 'msg')
-rw-r--r-- | msg/templates/msg.h.template | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/msg/templates/msg.h.template b/msg/templates/msg.h.template index d05282c88..f60001b55 100644 --- a/msg/templates/msg.h.template +++ b/msg/templates/msg.h.template @@ -95,7 +95,16 @@ for field in spec.parsed_fields(): @############################## @{ -inttypes = ['int8', 'int16', 'int32', 'int64', 'uint8', 'uint16', 'uint32', 'uint64'] +type_map = {'int8': 'int8_t', + 'int16': 'int16_t', + 'int32': 'int32_t', + 'int64': 'int64_t', + 'uint8': 'uint8_t', + 'uint16': 'uint16_t', + 'uint32': 'uint32_t', + 'uint64': 'uint64_t', + 'float32': 'float', + 'bool': 'bool'} # Function to print a standard ros type def print_field_def(field): @@ -117,21 +126,23 @@ def print_field_def(field): array_size = type[a_pos:] type = type[:a_pos] - if type in inttypes: + if type in type_map: # need to add _t: int8 --> int8_t - type_appendix = '_t' + type_px4 = type_map[type] + else: + raise Exception("Type {0} not supported, add to to template file!".format(type)) - print('\t%s%s%s%s %s;'%(type_prefix, type, type_appendix, array_size, field.name)) + print('\t%s%s%s %s%s;'%(type_prefix, type_px4, type_appendix, field.name, array_size)) } -struct @(spec.short_name)_s +struct @(spec.short_name)_s { @{ # loop over all fields and print the type and name for field in spec.parsed_fields(): if (not field.is_header): print_field_def(field) }@ -} +}; /** * @@} |