mavlink_msg_adsb_vehicle.h 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586
  1. #pragma once
  2. // MESSAGE ADSB_VEHICLE PACKING
  3. #define MAVLINK_MSG_ID_ADSB_VEHICLE 246
  4. typedef struct __mavlink_adsb_vehicle_t {
  5. uint32_t ICAO_address; /*< ICAO address*/
  6. int32_t lat; /*< [degE7] Latitude*/
  7. int32_t lon; /*< [degE7] Longitude*/
  8. int32_t altitude; /*< [mm] Altitude(ASL)*/
  9. uint16_t heading; /*< [cdeg] Course over ground*/
  10. uint16_t hor_velocity; /*< [cm/s] The horizontal velocity*/
  11. int16_t ver_velocity; /*< [cm/s] The vertical velocity. Positive is up*/
  12. uint16_t flags; /*< Bitmap to indicate various statuses including valid data fields*/
  13. uint16_t squawk; /*< Squawk code*/
  14. uint8_t altitude_type; /*< ADSB altitude type.*/
  15. char callsign[9]; /*< The callsign, 8+null*/
  16. uint8_t emitter_type; /*< ADSB emitter type.*/
  17. uint8_t tslc; /*< [s] Time since last communication in seconds*/
  18. } mavlink_adsb_vehicle_t;
  19. #define MAVLINK_MSG_ID_ADSB_VEHICLE_LEN 38
  20. #define MAVLINK_MSG_ID_ADSB_VEHICLE_MIN_LEN 38
  21. #define MAVLINK_MSG_ID_246_LEN 38
  22. #define MAVLINK_MSG_ID_246_MIN_LEN 38
  23. #define MAVLINK_MSG_ID_ADSB_VEHICLE_CRC 184
  24. #define MAVLINK_MSG_ID_246_CRC 184
  25. #define MAVLINK_MSG_ADSB_VEHICLE_FIELD_CALLSIGN_LEN 9
  26. #if MAVLINK_COMMAND_24BIT
  27. #define MAVLINK_MESSAGE_INFO_ADSB_VEHICLE { \
  28. 246, \
  29. "ADSB_VEHICLE", \
  30. 13, \
  31. { { "ICAO_address", NULL, MAVLINK_TYPE_UINT32_T, 0, 0, offsetof(mavlink_adsb_vehicle_t, ICAO_address) }, \
  32. { "lat", NULL, MAVLINK_TYPE_INT32_T, 0, 4, offsetof(mavlink_adsb_vehicle_t, lat) }, \
  33. { "lon", NULL, MAVLINK_TYPE_INT32_T, 0, 8, offsetof(mavlink_adsb_vehicle_t, lon) }, \
  34. { "altitude_type", NULL, MAVLINK_TYPE_UINT8_T, 0, 26, offsetof(mavlink_adsb_vehicle_t, altitude_type) }, \
  35. { "altitude", NULL, MAVLINK_TYPE_INT32_T, 0, 12, offsetof(mavlink_adsb_vehicle_t, altitude) }, \
  36. { "heading", NULL, MAVLINK_TYPE_UINT16_T, 0, 16, offsetof(mavlink_adsb_vehicle_t, heading) }, \
  37. { "hor_velocity", NULL, MAVLINK_TYPE_UINT16_T, 0, 18, offsetof(mavlink_adsb_vehicle_t, hor_velocity) }, \
  38. { "ver_velocity", NULL, MAVLINK_TYPE_INT16_T, 0, 20, offsetof(mavlink_adsb_vehicle_t, ver_velocity) }, \
  39. { "callsign", NULL, MAVLINK_TYPE_CHAR, 9, 27, offsetof(mavlink_adsb_vehicle_t, callsign) }, \
  40. { "emitter_type", NULL, MAVLINK_TYPE_UINT8_T, 0, 36, offsetof(mavlink_adsb_vehicle_t, emitter_type) }, \
  41. { "tslc", NULL, MAVLINK_TYPE_UINT8_T, 0, 37, offsetof(mavlink_adsb_vehicle_t, tslc) }, \
  42. { "flags", NULL, MAVLINK_TYPE_UINT16_T, 0, 22, offsetof(mavlink_adsb_vehicle_t, flags) }, \
  43. { "squawk", NULL, MAVLINK_TYPE_UINT16_T, 0, 24, offsetof(mavlink_adsb_vehicle_t, squawk) }, \
  44. } \
  45. }
  46. #else
  47. #define MAVLINK_MESSAGE_INFO_ADSB_VEHICLE { \
  48. "ADSB_VEHICLE", \
  49. 13, \
  50. { { "ICAO_address", NULL, MAVLINK_TYPE_UINT32_T, 0, 0, offsetof(mavlink_adsb_vehicle_t, ICAO_address) }, \
  51. { "lat", NULL, MAVLINK_TYPE_INT32_T, 0, 4, offsetof(mavlink_adsb_vehicle_t, lat) }, \
  52. { "lon", NULL, MAVLINK_TYPE_INT32_T, 0, 8, offsetof(mavlink_adsb_vehicle_t, lon) }, \
  53. { "altitude_type", NULL, MAVLINK_TYPE_UINT8_T, 0, 26, offsetof(mavlink_adsb_vehicle_t, altitude_type) }, \
  54. { "altitude", NULL, MAVLINK_TYPE_INT32_T, 0, 12, offsetof(mavlink_adsb_vehicle_t, altitude) }, \
  55. { "heading", NULL, MAVLINK_TYPE_UINT16_T, 0, 16, offsetof(mavlink_adsb_vehicle_t, heading) }, \
  56. { "hor_velocity", NULL, MAVLINK_TYPE_UINT16_T, 0, 18, offsetof(mavlink_adsb_vehicle_t, hor_velocity) }, \
  57. { "ver_velocity", NULL, MAVLINK_TYPE_INT16_T, 0, 20, offsetof(mavlink_adsb_vehicle_t, ver_velocity) }, \
  58. { "callsign", NULL, MAVLINK_TYPE_CHAR, 9, 27, offsetof(mavlink_adsb_vehicle_t, callsign) }, \
  59. { "emitter_type", NULL, MAVLINK_TYPE_UINT8_T, 0, 36, offsetof(mavlink_adsb_vehicle_t, emitter_type) }, \
  60. { "tslc", NULL, MAVLINK_TYPE_UINT8_T, 0, 37, offsetof(mavlink_adsb_vehicle_t, tslc) }, \
  61. { "flags", NULL, MAVLINK_TYPE_UINT16_T, 0, 22, offsetof(mavlink_adsb_vehicle_t, flags) }, \
  62. { "squawk", NULL, MAVLINK_TYPE_UINT16_T, 0, 24, offsetof(mavlink_adsb_vehicle_t, squawk) }, \
  63. } \
  64. }
  65. #endif
  66. /**
  67. * @brief Pack a adsb_vehicle message
  68. * @param system_id ID of this system
  69. * @param component_id ID of this component (e.g. 200 for IMU)
  70. * @param msg The MAVLink message to compress the data into
  71. *
  72. * @param ICAO_address ICAO address
  73. * @param lat [degE7] Latitude
  74. * @param lon [degE7] Longitude
  75. * @param altitude_type ADSB altitude type.
  76. * @param altitude [mm] Altitude(ASL)
  77. * @param heading [cdeg] Course over ground
  78. * @param hor_velocity [cm/s] The horizontal velocity
  79. * @param ver_velocity [cm/s] The vertical velocity. Positive is up
  80. * @param callsign The callsign, 8+null
  81. * @param emitter_type ADSB emitter type.
  82. * @param tslc [s] Time since last communication in seconds
  83. * @param flags Bitmap to indicate various statuses including valid data fields
  84. * @param squawk Squawk code
  85. * @return length of the message in bytes (excluding serial stream start sign)
  86. */
  87. static inline uint16_t mavlink_msg_adsb_vehicle_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
  88. uint32_t ICAO_address, int32_t lat, int32_t lon, uint8_t altitude_type, int32_t altitude, uint16_t heading, uint16_t hor_velocity, int16_t ver_velocity, const char *callsign, uint8_t emitter_type, uint8_t tslc, uint16_t flags, uint16_t squawk)
  89. {
  90. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  91. char buf[MAVLINK_MSG_ID_ADSB_VEHICLE_LEN];
  92. _mav_put_uint32_t(buf, 0, ICAO_address);
  93. _mav_put_int32_t(buf, 4, lat);
  94. _mav_put_int32_t(buf, 8, lon);
  95. _mav_put_int32_t(buf, 12, altitude);
  96. _mav_put_uint16_t(buf, 16, heading);
  97. _mav_put_uint16_t(buf, 18, hor_velocity);
  98. _mav_put_int16_t(buf, 20, ver_velocity);
  99. _mav_put_uint16_t(buf, 22, flags);
  100. _mav_put_uint16_t(buf, 24, squawk);
  101. _mav_put_uint8_t(buf, 26, altitude_type);
  102. _mav_put_uint8_t(buf, 36, emitter_type);
  103. _mav_put_uint8_t(buf, 37, tslc);
  104. _mav_put_char_array(buf, 27, callsign, 9);
  105. memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_ADSB_VEHICLE_LEN);
  106. #else
  107. mavlink_adsb_vehicle_t packet;
  108. packet.ICAO_address = ICAO_address;
  109. packet.lat = lat;
  110. packet.lon = lon;
  111. packet.altitude = altitude;
  112. packet.heading = heading;
  113. packet.hor_velocity = hor_velocity;
  114. packet.ver_velocity = ver_velocity;
  115. packet.flags = flags;
  116. packet.squawk = squawk;
  117. packet.altitude_type = altitude_type;
  118. packet.emitter_type = emitter_type;
  119. packet.tslc = tslc;
  120. mav_array_memcpy(packet.callsign, callsign, sizeof(char)*9);
  121. memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_ADSB_VEHICLE_LEN);
  122. #endif
  123. msg->msgid = MAVLINK_MSG_ID_ADSB_VEHICLE;
  124. return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_ADSB_VEHICLE_MIN_LEN, MAVLINK_MSG_ID_ADSB_VEHICLE_LEN, MAVLINK_MSG_ID_ADSB_VEHICLE_CRC);
  125. }
  126. /**
  127. * @brief Pack a adsb_vehicle message
  128. * @param system_id ID of this system
  129. * @param component_id ID of this component (e.g. 200 for IMU)
  130. * @param status MAVLink status structure
  131. * @param msg The MAVLink message to compress the data into
  132. *
  133. * @param ICAO_address ICAO address
  134. * @param lat [degE7] Latitude
  135. * @param lon [degE7] Longitude
  136. * @param altitude_type ADSB altitude type.
  137. * @param altitude [mm] Altitude(ASL)
  138. * @param heading [cdeg] Course over ground
  139. * @param hor_velocity [cm/s] The horizontal velocity
  140. * @param ver_velocity [cm/s] The vertical velocity. Positive is up
  141. * @param callsign The callsign, 8+null
  142. * @param emitter_type ADSB emitter type.
  143. * @param tslc [s] Time since last communication in seconds
  144. * @param flags Bitmap to indicate various statuses including valid data fields
  145. * @param squawk Squawk code
  146. * @return length of the message in bytes (excluding serial stream start sign)
  147. */
  148. static inline uint16_t mavlink_msg_adsb_vehicle_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg,
  149. uint32_t ICAO_address, int32_t lat, int32_t lon, uint8_t altitude_type, int32_t altitude, uint16_t heading, uint16_t hor_velocity, int16_t ver_velocity, const char *callsign, uint8_t emitter_type, uint8_t tslc, uint16_t flags, uint16_t squawk)
  150. {
  151. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  152. char buf[MAVLINK_MSG_ID_ADSB_VEHICLE_LEN];
  153. _mav_put_uint32_t(buf, 0, ICAO_address);
  154. _mav_put_int32_t(buf, 4, lat);
  155. _mav_put_int32_t(buf, 8, lon);
  156. _mav_put_int32_t(buf, 12, altitude);
  157. _mav_put_uint16_t(buf, 16, heading);
  158. _mav_put_uint16_t(buf, 18, hor_velocity);
  159. _mav_put_int16_t(buf, 20, ver_velocity);
  160. _mav_put_uint16_t(buf, 22, flags);
  161. _mav_put_uint16_t(buf, 24, squawk);
  162. _mav_put_uint8_t(buf, 26, altitude_type);
  163. _mav_put_uint8_t(buf, 36, emitter_type);
  164. _mav_put_uint8_t(buf, 37, tslc);
  165. _mav_put_char_array(buf, 27, callsign, 9);
  166. memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_ADSB_VEHICLE_LEN);
  167. #else
  168. mavlink_adsb_vehicle_t packet;
  169. packet.ICAO_address = ICAO_address;
  170. packet.lat = lat;
  171. packet.lon = lon;
  172. packet.altitude = altitude;
  173. packet.heading = heading;
  174. packet.hor_velocity = hor_velocity;
  175. packet.ver_velocity = ver_velocity;
  176. packet.flags = flags;
  177. packet.squawk = squawk;
  178. packet.altitude_type = altitude_type;
  179. packet.emitter_type = emitter_type;
  180. packet.tslc = tslc;
  181. mav_array_memcpy(packet.callsign, callsign, sizeof(char)*9);
  182. memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_ADSB_VEHICLE_LEN);
  183. #endif
  184. msg->msgid = MAVLINK_MSG_ID_ADSB_VEHICLE;
  185. #if MAVLINK_CRC_EXTRA
  186. return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_ADSB_VEHICLE_MIN_LEN, MAVLINK_MSG_ID_ADSB_VEHICLE_LEN, MAVLINK_MSG_ID_ADSB_VEHICLE_CRC);
  187. #else
  188. return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_ADSB_VEHICLE_MIN_LEN, MAVLINK_MSG_ID_ADSB_VEHICLE_LEN);
  189. #endif
  190. }
  191. /**
  192. * @brief Pack a adsb_vehicle message on a channel
  193. * @param system_id ID of this system
  194. * @param component_id ID of this component (e.g. 200 for IMU)
  195. * @param chan The MAVLink channel this message will be sent over
  196. * @param msg The MAVLink message to compress the data into
  197. * @param ICAO_address ICAO address
  198. * @param lat [degE7] Latitude
  199. * @param lon [degE7] Longitude
  200. * @param altitude_type ADSB altitude type.
  201. * @param altitude [mm] Altitude(ASL)
  202. * @param heading [cdeg] Course over ground
  203. * @param hor_velocity [cm/s] The horizontal velocity
  204. * @param ver_velocity [cm/s] The vertical velocity. Positive is up
  205. * @param callsign The callsign, 8+null
  206. * @param emitter_type ADSB emitter type.
  207. * @param tslc [s] Time since last communication in seconds
  208. * @param flags Bitmap to indicate various statuses including valid data fields
  209. * @param squawk Squawk code
  210. * @return length of the message in bytes (excluding serial stream start sign)
  211. */
  212. static inline uint16_t mavlink_msg_adsb_vehicle_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
  213. mavlink_message_t* msg,
  214. uint32_t ICAO_address,int32_t lat,int32_t lon,uint8_t altitude_type,int32_t altitude,uint16_t heading,uint16_t hor_velocity,int16_t ver_velocity,const char *callsign,uint8_t emitter_type,uint8_t tslc,uint16_t flags,uint16_t squawk)
  215. {
  216. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  217. char buf[MAVLINK_MSG_ID_ADSB_VEHICLE_LEN];
  218. _mav_put_uint32_t(buf, 0, ICAO_address);
  219. _mav_put_int32_t(buf, 4, lat);
  220. _mav_put_int32_t(buf, 8, lon);
  221. _mav_put_int32_t(buf, 12, altitude);
  222. _mav_put_uint16_t(buf, 16, heading);
  223. _mav_put_uint16_t(buf, 18, hor_velocity);
  224. _mav_put_int16_t(buf, 20, ver_velocity);
  225. _mav_put_uint16_t(buf, 22, flags);
  226. _mav_put_uint16_t(buf, 24, squawk);
  227. _mav_put_uint8_t(buf, 26, altitude_type);
  228. _mav_put_uint8_t(buf, 36, emitter_type);
  229. _mav_put_uint8_t(buf, 37, tslc);
  230. _mav_put_char_array(buf, 27, callsign, 9);
  231. memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_ADSB_VEHICLE_LEN);
  232. #else
  233. mavlink_adsb_vehicle_t packet;
  234. packet.ICAO_address = ICAO_address;
  235. packet.lat = lat;
  236. packet.lon = lon;
  237. packet.altitude = altitude;
  238. packet.heading = heading;
  239. packet.hor_velocity = hor_velocity;
  240. packet.ver_velocity = ver_velocity;
  241. packet.flags = flags;
  242. packet.squawk = squawk;
  243. packet.altitude_type = altitude_type;
  244. packet.emitter_type = emitter_type;
  245. packet.tslc = tslc;
  246. mav_array_memcpy(packet.callsign, callsign, sizeof(char)*9);
  247. memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_ADSB_VEHICLE_LEN);
  248. #endif
  249. msg->msgid = MAVLINK_MSG_ID_ADSB_VEHICLE;
  250. return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_ADSB_VEHICLE_MIN_LEN, MAVLINK_MSG_ID_ADSB_VEHICLE_LEN, MAVLINK_MSG_ID_ADSB_VEHICLE_CRC);
  251. }
  252. /**
  253. * @brief Encode a adsb_vehicle struct
  254. *
  255. * @param system_id ID of this system
  256. * @param component_id ID of this component (e.g. 200 for IMU)
  257. * @param msg The MAVLink message to compress the data into
  258. * @param adsb_vehicle C-struct to read the message contents from
  259. */
  260. static inline uint16_t mavlink_msg_adsb_vehicle_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_adsb_vehicle_t* adsb_vehicle)
  261. {
  262. return mavlink_msg_adsb_vehicle_pack(system_id, component_id, msg, adsb_vehicle->ICAO_address, adsb_vehicle->lat, adsb_vehicle->lon, adsb_vehicle->altitude_type, adsb_vehicle->altitude, adsb_vehicle->heading, adsb_vehicle->hor_velocity, adsb_vehicle->ver_velocity, adsb_vehicle->callsign, adsb_vehicle->emitter_type, adsb_vehicle->tslc, adsb_vehicle->flags, adsb_vehicle->squawk);
  263. }
  264. /**
  265. * @brief Encode a adsb_vehicle struct on a channel
  266. *
  267. * @param system_id ID of this system
  268. * @param component_id ID of this component (e.g. 200 for IMU)
  269. * @param chan The MAVLink channel this message will be sent over
  270. * @param msg The MAVLink message to compress the data into
  271. * @param adsb_vehicle C-struct to read the message contents from
  272. */
  273. static inline uint16_t mavlink_msg_adsb_vehicle_encode_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, const mavlink_adsb_vehicle_t* adsb_vehicle)
  274. {
  275. return mavlink_msg_adsb_vehicle_pack_chan(system_id, component_id, chan, msg, adsb_vehicle->ICAO_address, adsb_vehicle->lat, adsb_vehicle->lon, adsb_vehicle->altitude_type, adsb_vehicle->altitude, adsb_vehicle->heading, adsb_vehicle->hor_velocity, adsb_vehicle->ver_velocity, adsb_vehicle->callsign, adsb_vehicle->emitter_type, adsb_vehicle->tslc, adsb_vehicle->flags, adsb_vehicle->squawk);
  276. }
  277. /**
  278. * @brief Encode a adsb_vehicle struct with provided status structure
  279. *
  280. * @param system_id ID of this system
  281. * @param component_id ID of this component (e.g. 200 for IMU)
  282. * @param status MAVLink status structure
  283. * @param msg The MAVLink message to compress the data into
  284. * @param adsb_vehicle C-struct to read the message contents from
  285. */
  286. static inline uint16_t mavlink_msg_adsb_vehicle_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_adsb_vehicle_t* adsb_vehicle)
  287. {
  288. return mavlink_msg_adsb_vehicle_pack_status(system_id, component_id, _status, msg, adsb_vehicle->ICAO_address, adsb_vehicle->lat, adsb_vehicle->lon, adsb_vehicle->altitude_type, adsb_vehicle->altitude, adsb_vehicle->heading, adsb_vehicle->hor_velocity, adsb_vehicle->ver_velocity, adsb_vehicle->callsign, adsb_vehicle->emitter_type, adsb_vehicle->tslc, adsb_vehicle->flags, adsb_vehicle->squawk);
  289. }
  290. /**
  291. * @brief Send a adsb_vehicle message
  292. * @param chan MAVLink channel to send the message
  293. *
  294. * @param ICAO_address ICAO address
  295. * @param lat [degE7] Latitude
  296. * @param lon [degE7] Longitude
  297. * @param altitude_type ADSB altitude type.
  298. * @param altitude [mm] Altitude(ASL)
  299. * @param heading [cdeg] Course over ground
  300. * @param hor_velocity [cm/s] The horizontal velocity
  301. * @param ver_velocity [cm/s] The vertical velocity. Positive is up
  302. * @param callsign The callsign, 8+null
  303. * @param emitter_type ADSB emitter type.
  304. * @param tslc [s] Time since last communication in seconds
  305. * @param flags Bitmap to indicate various statuses including valid data fields
  306. * @param squawk Squawk code
  307. */
  308. #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
  309. static inline void mavlink_msg_adsb_vehicle_send(mavlink_channel_t chan, uint32_t ICAO_address, int32_t lat, int32_t lon, uint8_t altitude_type, int32_t altitude, uint16_t heading, uint16_t hor_velocity, int16_t ver_velocity, const char *callsign, uint8_t emitter_type, uint8_t tslc, uint16_t flags, uint16_t squawk)
  310. {
  311. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  312. char buf[MAVLINK_MSG_ID_ADSB_VEHICLE_LEN];
  313. _mav_put_uint32_t(buf, 0, ICAO_address);
  314. _mav_put_int32_t(buf, 4, lat);
  315. _mav_put_int32_t(buf, 8, lon);
  316. _mav_put_int32_t(buf, 12, altitude);
  317. _mav_put_uint16_t(buf, 16, heading);
  318. _mav_put_uint16_t(buf, 18, hor_velocity);
  319. _mav_put_int16_t(buf, 20, ver_velocity);
  320. _mav_put_uint16_t(buf, 22, flags);
  321. _mav_put_uint16_t(buf, 24, squawk);
  322. _mav_put_uint8_t(buf, 26, altitude_type);
  323. _mav_put_uint8_t(buf, 36, emitter_type);
  324. _mav_put_uint8_t(buf, 37, tslc);
  325. _mav_put_char_array(buf, 27, callsign, 9);
  326. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_ADSB_VEHICLE, buf, MAVLINK_MSG_ID_ADSB_VEHICLE_MIN_LEN, MAVLINK_MSG_ID_ADSB_VEHICLE_LEN, MAVLINK_MSG_ID_ADSB_VEHICLE_CRC);
  327. #else
  328. mavlink_adsb_vehicle_t packet;
  329. packet.ICAO_address = ICAO_address;
  330. packet.lat = lat;
  331. packet.lon = lon;
  332. packet.altitude = altitude;
  333. packet.heading = heading;
  334. packet.hor_velocity = hor_velocity;
  335. packet.ver_velocity = ver_velocity;
  336. packet.flags = flags;
  337. packet.squawk = squawk;
  338. packet.altitude_type = altitude_type;
  339. packet.emitter_type = emitter_type;
  340. packet.tslc = tslc;
  341. mav_array_memcpy(packet.callsign, callsign, sizeof(char)*9);
  342. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_ADSB_VEHICLE, (const char *)&packet, MAVLINK_MSG_ID_ADSB_VEHICLE_MIN_LEN, MAVLINK_MSG_ID_ADSB_VEHICLE_LEN, MAVLINK_MSG_ID_ADSB_VEHICLE_CRC);
  343. #endif
  344. }
  345. /**
  346. * @brief Send a adsb_vehicle message
  347. * @param chan MAVLink channel to send the message
  348. * @param struct The MAVLink struct to serialize
  349. */
  350. static inline void mavlink_msg_adsb_vehicle_send_struct(mavlink_channel_t chan, const mavlink_adsb_vehicle_t* adsb_vehicle)
  351. {
  352. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  353. mavlink_msg_adsb_vehicle_send(chan, adsb_vehicle->ICAO_address, adsb_vehicle->lat, adsb_vehicle->lon, adsb_vehicle->altitude_type, adsb_vehicle->altitude, adsb_vehicle->heading, adsb_vehicle->hor_velocity, adsb_vehicle->ver_velocity, adsb_vehicle->callsign, adsb_vehicle->emitter_type, adsb_vehicle->tslc, adsb_vehicle->flags, adsb_vehicle->squawk);
  354. #else
  355. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_ADSB_VEHICLE, (const char *)adsb_vehicle, MAVLINK_MSG_ID_ADSB_VEHICLE_MIN_LEN, MAVLINK_MSG_ID_ADSB_VEHICLE_LEN, MAVLINK_MSG_ID_ADSB_VEHICLE_CRC);
  356. #endif
  357. }
  358. #if MAVLINK_MSG_ID_ADSB_VEHICLE_LEN <= MAVLINK_MAX_PAYLOAD_LEN
  359. /*
  360. This variant of _send() can be used to save stack space by re-using
  361. memory from the receive buffer. The caller provides a
  362. mavlink_message_t which is the size of a full mavlink message. This
  363. is usually the receive buffer for the channel, and allows a reply to an
  364. incoming message with minimum stack space usage.
  365. */
  366. static inline void mavlink_msg_adsb_vehicle_send_buf(mavlink_message_t *msgbuf, mavlink_channel_t chan, uint32_t ICAO_address, int32_t lat, int32_t lon, uint8_t altitude_type, int32_t altitude, uint16_t heading, uint16_t hor_velocity, int16_t ver_velocity, const char *callsign, uint8_t emitter_type, uint8_t tslc, uint16_t flags, uint16_t squawk)
  367. {
  368. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  369. char *buf = (char *)msgbuf;
  370. _mav_put_uint32_t(buf, 0, ICAO_address);
  371. _mav_put_int32_t(buf, 4, lat);
  372. _mav_put_int32_t(buf, 8, lon);
  373. _mav_put_int32_t(buf, 12, altitude);
  374. _mav_put_uint16_t(buf, 16, heading);
  375. _mav_put_uint16_t(buf, 18, hor_velocity);
  376. _mav_put_int16_t(buf, 20, ver_velocity);
  377. _mav_put_uint16_t(buf, 22, flags);
  378. _mav_put_uint16_t(buf, 24, squawk);
  379. _mav_put_uint8_t(buf, 26, altitude_type);
  380. _mav_put_uint8_t(buf, 36, emitter_type);
  381. _mav_put_uint8_t(buf, 37, tslc);
  382. _mav_put_char_array(buf, 27, callsign, 9);
  383. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_ADSB_VEHICLE, buf, MAVLINK_MSG_ID_ADSB_VEHICLE_MIN_LEN, MAVLINK_MSG_ID_ADSB_VEHICLE_LEN, MAVLINK_MSG_ID_ADSB_VEHICLE_CRC);
  384. #else
  385. mavlink_adsb_vehicle_t *packet = (mavlink_adsb_vehicle_t *)msgbuf;
  386. packet->ICAO_address = ICAO_address;
  387. packet->lat = lat;
  388. packet->lon = lon;
  389. packet->altitude = altitude;
  390. packet->heading = heading;
  391. packet->hor_velocity = hor_velocity;
  392. packet->ver_velocity = ver_velocity;
  393. packet->flags = flags;
  394. packet->squawk = squawk;
  395. packet->altitude_type = altitude_type;
  396. packet->emitter_type = emitter_type;
  397. packet->tslc = tslc;
  398. mav_array_memcpy(packet->callsign, callsign, sizeof(char)*9);
  399. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_ADSB_VEHICLE, (const char *)packet, MAVLINK_MSG_ID_ADSB_VEHICLE_MIN_LEN, MAVLINK_MSG_ID_ADSB_VEHICLE_LEN, MAVLINK_MSG_ID_ADSB_VEHICLE_CRC);
  400. #endif
  401. }
  402. #endif
  403. #endif
  404. // MESSAGE ADSB_VEHICLE UNPACKING
  405. /**
  406. * @brief Get field ICAO_address from adsb_vehicle message
  407. *
  408. * @return ICAO address
  409. */
  410. static inline uint32_t mavlink_msg_adsb_vehicle_get_ICAO_address(const mavlink_message_t* msg)
  411. {
  412. return _MAV_RETURN_uint32_t(msg, 0);
  413. }
  414. /**
  415. * @brief Get field lat from adsb_vehicle message
  416. *
  417. * @return [degE7] Latitude
  418. */
  419. static inline int32_t mavlink_msg_adsb_vehicle_get_lat(const mavlink_message_t* msg)
  420. {
  421. return _MAV_RETURN_int32_t(msg, 4);
  422. }
  423. /**
  424. * @brief Get field lon from adsb_vehicle message
  425. *
  426. * @return [degE7] Longitude
  427. */
  428. static inline int32_t mavlink_msg_adsb_vehicle_get_lon(const mavlink_message_t* msg)
  429. {
  430. return _MAV_RETURN_int32_t(msg, 8);
  431. }
  432. /**
  433. * @brief Get field altitude_type from adsb_vehicle message
  434. *
  435. * @return ADSB altitude type.
  436. */
  437. static inline uint8_t mavlink_msg_adsb_vehicle_get_altitude_type(const mavlink_message_t* msg)
  438. {
  439. return _MAV_RETURN_uint8_t(msg, 26);
  440. }
  441. /**
  442. * @brief Get field altitude from adsb_vehicle message
  443. *
  444. * @return [mm] Altitude(ASL)
  445. */
  446. static inline int32_t mavlink_msg_adsb_vehicle_get_altitude(const mavlink_message_t* msg)
  447. {
  448. return _MAV_RETURN_int32_t(msg, 12);
  449. }
  450. /**
  451. * @brief Get field heading from adsb_vehicle message
  452. *
  453. * @return [cdeg] Course over ground
  454. */
  455. static inline uint16_t mavlink_msg_adsb_vehicle_get_heading(const mavlink_message_t* msg)
  456. {
  457. return _MAV_RETURN_uint16_t(msg, 16);
  458. }
  459. /**
  460. * @brief Get field hor_velocity from adsb_vehicle message
  461. *
  462. * @return [cm/s] The horizontal velocity
  463. */
  464. static inline uint16_t mavlink_msg_adsb_vehicle_get_hor_velocity(const mavlink_message_t* msg)
  465. {
  466. return _MAV_RETURN_uint16_t(msg, 18);
  467. }
  468. /**
  469. * @brief Get field ver_velocity from adsb_vehicle message
  470. *
  471. * @return [cm/s] The vertical velocity. Positive is up
  472. */
  473. static inline int16_t mavlink_msg_adsb_vehicle_get_ver_velocity(const mavlink_message_t* msg)
  474. {
  475. return _MAV_RETURN_int16_t(msg, 20);
  476. }
  477. /**
  478. * @brief Get field callsign from adsb_vehicle message
  479. *
  480. * @return The callsign, 8+null
  481. */
  482. static inline uint16_t mavlink_msg_adsb_vehicle_get_callsign(const mavlink_message_t* msg, char *callsign)
  483. {
  484. return _MAV_RETURN_char_array(msg, callsign, 9, 27);
  485. }
  486. /**
  487. * @brief Get field emitter_type from adsb_vehicle message
  488. *
  489. * @return ADSB emitter type.
  490. */
  491. static inline uint8_t mavlink_msg_adsb_vehicle_get_emitter_type(const mavlink_message_t* msg)
  492. {
  493. return _MAV_RETURN_uint8_t(msg, 36);
  494. }
  495. /**
  496. * @brief Get field tslc from adsb_vehicle message
  497. *
  498. * @return [s] Time since last communication in seconds
  499. */
  500. static inline uint8_t mavlink_msg_adsb_vehicle_get_tslc(const mavlink_message_t* msg)
  501. {
  502. return _MAV_RETURN_uint8_t(msg, 37);
  503. }
  504. /**
  505. * @brief Get field flags from adsb_vehicle message
  506. *
  507. * @return Bitmap to indicate various statuses including valid data fields
  508. */
  509. static inline uint16_t mavlink_msg_adsb_vehicle_get_flags(const mavlink_message_t* msg)
  510. {
  511. return _MAV_RETURN_uint16_t(msg, 22);
  512. }
  513. /**
  514. * @brief Get field squawk from adsb_vehicle message
  515. *
  516. * @return Squawk code
  517. */
  518. static inline uint16_t mavlink_msg_adsb_vehicle_get_squawk(const mavlink_message_t* msg)
  519. {
  520. return _MAV_RETURN_uint16_t(msg, 24);
  521. }
  522. /**
  523. * @brief Decode a adsb_vehicle message into a struct
  524. *
  525. * @param msg The message to decode
  526. * @param adsb_vehicle C-struct to decode the message contents into
  527. */
  528. static inline void mavlink_msg_adsb_vehicle_decode(const mavlink_message_t* msg, mavlink_adsb_vehicle_t* adsb_vehicle)
  529. {
  530. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  531. adsb_vehicle->ICAO_address = mavlink_msg_adsb_vehicle_get_ICAO_address(msg);
  532. adsb_vehicle->lat = mavlink_msg_adsb_vehicle_get_lat(msg);
  533. adsb_vehicle->lon = mavlink_msg_adsb_vehicle_get_lon(msg);
  534. adsb_vehicle->altitude = mavlink_msg_adsb_vehicle_get_altitude(msg);
  535. adsb_vehicle->heading = mavlink_msg_adsb_vehicle_get_heading(msg);
  536. adsb_vehicle->hor_velocity = mavlink_msg_adsb_vehicle_get_hor_velocity(msg);
  537. adsb_vehicle->ver_velocity = mavlink_msg_adsb_vehicle_get_ver_velocity(msg);
  538. adsb_vehicle->flags = mavlink_msg_adsb_vehicle_get_flags(msg);
  539. adsb_vehicle->squawk = mavlink_msg_adsb_vehicle_get_squawk(msg);
  540. adsb_vehicle->altitude_type = mavlink_msg_adsb_vehicle_get_altitude_type(msg);
  541. mavlink_msg_adsb_vehicle_get_callsign(msg, adsb_vehicle->callsign);
  542. adsb_vehicle->emitter_type = mavlink_msg_adsb_vehicle_get_emitter_type(msg);
  543. adsb_vehicle->tslc = mavlink_msg_adsb_vehicle_get_tslc(msg);
  544. #else
  545. uint8_t len = msg->len < MAVLINK_MSG_ID_ADSB_VEHICLE_LEN? msg->len : MAVLINK_MSG_ID_ADSB_VEHICLE_LEN;
  546. memset(adsb_vehicle, 0, MAVLINK_MSG_ID_ADSB_VEHICLE_LEN);
  547. memcpy(adsb_vehicle, _MAV_PAYLOAD(msg), len);
  548. #endif
  549. }