code: def mavfmt(field):
      '''work out the struct format for a type'''
      map = {
          'float'    : 'f',
          'double'   : 'd',
          'char'     : 'c',
          'int8_t'   : 'b',
          'uint8_t'  : 'B',
          'uint8_t_mavlink_version'  : 'B',
          'int16_t'  : 'h',
          'uint16_t' : 'H',
          'int32_t'  : 'i',
          'uint32_t' : 'I',
          'int64_t'  : 'q',
          'uint64_t' : 'Q',
          }
  
      if field.array_length:
          if field.type in ['char', 'int8_t', 'uint8_t']:
              return str(field.array_length)+'s'
          return str(field.array_length)+map[field.type]
      return map[field.typef mavfmt(field):
      '''work out the struct format for a type'''
      map = {
          'float'    : 'f',
          'double'   : 'd',
          'char'     : 'c',
          'int8_t'   : 'b',
          'uint8_t'  : 'B',
          'uint8_t_mavlink_version'  : 'B',
          'int16_t'  : 'h',
          'uint16_t' : 'H',
          'int32_t'  : 'i',
          'uint32_t' : 'I',
          'int64_t'  : 'q',
          'uint64_t' : 'Q',
          }
  
      if field.array_length:
          if field.type in ['char', 'int8_t', 'uint8_t']:
              return str(field.array_length)+'s'
          return str(field.array_length)+map[field.type]
      return map[field.type]
docs: work out the struct format for a type