NinjaFlight
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
mavlink_types.h
Go to the documentation of this file.
1 #ifndef MAVLINK_TYPES_H_
2 #define MAVLINK_TYPES_H_
3 
4 // Visual Studio versions before 2010 don't have stdint.h, so we just error out.
5 #if (defined _MSC_VER) && (_MSC_VER < 1600)
6 #error "The C-MAVLink implementation requires Visual Studio 2010 or greater"
7 #endif
8 
9 #include <stdint.h>
10 
11 #ifdef __GNUC__
12 # pragma GCC diagnostic push
13 # pragma GCC diagnostic ignored "-Wpedantic"
14 #endif
15 
16 // Macro to define packed structures
17 #ifdef __GNUC__
18  #define MAVPACKED( __Declaration__ ) __Declaration__ __attribute__((packed))
19 #else
20  #define MAVPACKED( __Declaration__ ) __pragma( pack(push, 1) ) __Declaration__ __pragma( pack(pop) )
21 #endif
22 
23 #ifndef MAVLINK_MAX_PAYLOAD_LEN
24 // it is possible to override this, but be careful!
25 #define MAVLINK_MAX_PAYLOAD_LEN 255
26 #endif
27 
28 #define MAVLINK_CORE_HEADER_LEN 5
29 #define MAVLINK_NUM_HEADER_BYTES (MAVLINK_CORE_HEADER_LEN + 1)
30 #define MAVLINK_NUM_CHECKSUM_BYTES 2
31 #define MAVLINK_NUM_NON_PAYLOAD_BYTES (MAVLINK_NUM_HEADER_BYTES + MAVLINK_NUM_CHECKSUM_BYTES)
32 
33 #define MAVLINK_MAX_PACKET_LEN (MAVLINK_MAX_PAYLOAD_LEN + MAVLINK_NUM_NON_PAYLOAD_BYTES)
34 
35 #define MAVLINK_MSG_ID_EXTENDED_MESSAGE 255
36 #define MAVLINK_EXTENDED_HEADER_LEN 14
37 
38 #if (defined _MSC_VER) || ((defined __APPLE__) && (defined __MACH__)) || (defined __linux__)
39  /* full fledged 32bit++ OS */
40  #define MAVLINK_MAX_EXTENDED_PACKET_LEN 65507
41 #else
42  /* small microcontrollers */
43  #define MAVLINK_MAX_EXTENDED_PACKET_LEN 2048
44 #endif
45 
46 #define MAVLINK_MAX_EXTENDED_PAYLOAD_LEN (MAVLINK_MAX_EXTENDED_PACKET_LEN - MAVLINK_EXTENDED_HEADER_LEN - MAVLINK_NUM_NON_PAYLOAD_BYTES)
47 
48 
58 MAVPACKED(
59 typedef struct param_union {
60  union {
61  float param_float;
62  int32_t param_int32;
63  uint32_t param_uint32;
64  int16_t param_int16;
65  uint16_t param_uint16;
66  int8_t param_int8;
67  uint8_t param_uint8;
68  uint8_t bytes[4];
69  };
70  uint8_t type;
71 }) mavlink_param_union_t;
72 
73 
87 MAVPACKED(
88 typedef struct param_union_extended {
89  union {
90  struct {
91  uint8_t is_double:1;
92  uint8_t mavlink_type:7;
93  union {
94  char c;
95  uint8_t uint8;
96  int8_t int8;
97  uint16_t uint16;
98  int16_t int16;
99  uint32_t uint32;
100  int32_t int32;
101  float f;
102  uint8_t align[7];
103  };
104  };
105  uint8_t data[8];
106  };
107 }) mavlink_param_union_double_t;
108 
113 MAVPACKED(
114 typedef struct __mavlink_system {
115  uint8_t sysid;
116  uint8_t compid;
117 }) mavlink_system_t;
118 
119 MAVPACKED(
120 typedef struct __mavlink_message {
121  uint16_t checksum;
122  uint8_t magic;
123  uint8_t len;
124  uint8_t seq;
125  uint8_t sysid;
126  uint8_t compid;
127  uint8_t msgid;
128  uint64_t payload64[(MAVLINK_MAX_PAYLOAD_LEN+MAVLINK_NUM_CHECKSUM_BYTES+7)/8];
129 }) mavlink_message_t;
130 
131 MAVPACKED(
132 typedef struct __mavlink_extended_message {
133  mavlink_message_t base_msg;
134  int32_t extended_payload_len;
135  uint8_t extended_payload[MAVLINK_MAX_EXTENDED_PAYLOAD_LEN];
136 }) mavlink_extended_message_t;
137 
138 typedef enum {
151 
152 #define MAVLINK_MAX_FIELDS 64
153 
154 typedef struct __mavlink_field_info {
155  const char *name; // name of this field
156  const char *print_format; // printing format hint, or NULL
157  mavlink_message_type_t type; // type of this field
158  unsigned int array_length; // if non-zero, field is an array
159  unsigned int wire_offset; // offset of each field in the payload
160  unsigned int structure_offset; // offset in a C structure
162 
163 // note that in this structure the order of fields is the order
164 // in the XML file, not necessary the wire order
165 typedef struct __mavlink_message_info {
166  const char *name; // name of the message
167  unsigned num_fields; // how many fields in this message
170 
171 #define _MAV_PAYLOAD(msg) ((const char *)(&((msg)->payload64[0])))
172 #define _MAV_PAYLOAD_NON_CONST(msg) ((char *)(&((msg)->payload64[0])))
173 
174 // checksum is immediately after the payload bytes
175 #define mavlink_ck_a(msg) *((msg)->len + (uint8_t *)_MAV_PAYLOAD_NON_CONST(msg))
176 #define mavlink_ck_b(msg) *(((msg)->len+(uint16_t)1) + (uint8_t *)_MAV_PAYLOAD_NON_CONST(msg))
177 
178 typedef enum {
184 
185 /*
186  * applications can set MAVLINK_COMM_NUM_BUFFERS to the maximum number
187  * of buffers they will use. If more are used, then the result will be
188  * a stack overrun
189  */
190 #ifndef MAVLINK_COMM_NUM_BUFFERS
191 #if (defined linux) | (defined __linux) | (defined __MACH__) | (defined _WIN32)
192 # define MAVLINK_COMM_NUM_BUFFERS 16
193 #else
194 # define MAVLINK_COMM_NUM_BUFFERS 4
195 #endif
196 #endif
197 
198 typedef enum {
210 
211 typedef struct __mavlink_status {
212  uint8_t msg_received;
213  uint8_t buffer_overrun;
214  uint8_t parse_error;
216  uint8_t packet_idx;
217  uint8_t current_rx_seq;
218  uint8_t current_tx_seq;
222 
223 #define MAVLINK_BIG_ENDIAN 0
224 #define MAVLINK_LITTLE_ENDIAN 1
225 
226 #ifdef __GNUC__
227 # pragma GCC diagnostic pop
228 #endif
229 
230 #endif /* MAVLINK_TYPES_H_ */
uint8_t type
Definition: fat_standard.h:67
uint8_t bytes[UBLOX_BUFFER_SIZE]
Definition: gps.c:833
uint16_t data
Definition: config.c:91
union @14::@15 f