You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

306 lines
15 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. #pragma once
  2. // MESSAGE PROTOCOL_VERSION PACKING
  3. #define MAVLINK_MSG_ID_PROTOCOL_VERSION 300
  4. MAVPACKED(
  5. typedef struct __mavlink_protocol_version_t {
  6. uint16_t version; /*< Currently active MAVLink version number * 100: v1.0 is 100, v2.0 is 200, etc.*/
  7. uint16_t min_version; /*< Minimum MAVLink version supported*/
  8. uint16_t max_version; /*< Maximum MAVLink version supported (set to the same value as version by default)*/
  9. uint8_t spec_version_hash[8]; /*< The first 8 bytes (not characters printed in hex!) of the git hash.*/
  10. uint8_t library_version_hash[8]; /*< The first 8 bytes (not characters printed in hex!) of the git hash.*/
  11. }) mavlink_protocol_version_t;
  12. #define MAVLINK_MSG_ID_PROTOCOL_VERSION_LEN 22
  13. #define MAVLINK_MSG_ID_PROTOCOL_VERSION_MIN_LEN 22
  14. #define MAVLINK_MSG_ID_300_LEN 22
  15. #define MAVLINK_MSG_ID_300_MIN_LEN 22
  16. #define MAVLINK_MSG_ID_PROTOCOL_VERSION_CRC 217
  17. #define MAVLINK_MSG_ID_300_CRC 217
  18. #define MAVLINK_MSG_PROTOCOL_VERSION_FIELD_SPEC_VERSION_HASH_LEN 8
  19. #define MAVLINK_MSG_PROTOCOL_VERSION_FIELD_LIBRARY_VERSION_HASH_LEN 8
  20. #if MAVLINK_COMMAND_24BIT
  21. #define MAVLINK_MESSAGE_INFO_PROTOCOL_VERSION { \
  22. 300, \
  23. "PROTOCOL_VERSION", \
  24. 5, \
  25. { { "version", NULL, MAVLINK_TYPE_UINT16_T, 0, 0, offsetof(mavlink_protocol_version_t, version) }, \
  26. { "min_version", NULL, MAVLINK_TYPE_UINT16_T, 0, 2, offsetof(mavlink_protocol_version_t, min_version) }, \
  27. { "max_version", NULL, MAVLINK_TYPE_UINT16_T, 0, 4, offsetof(mavlink_protocol_version_t, max_version) }, \
  28. { "spec_version_hash", NULL, MAVLINK_TYPE_UINT8_T, 8, 6, offsetof(mavlink_protocol_version_t, spec_version_hash) }, \
  29. { "library_version_hash", NULL, MAVLINK_TYPE_UINT8_T, 8, 14, offsetof(mavlink_protocol_version_t, library_version_hash) }, \
  30. } \
  31. }
  32. #else
  33. #define MAVLINK_MESSAGE_INFO_PROTOCOL_VERSION { \
  34. "PROTOCOL_VERSION", \
  35. 5, \
  36. { { "version", NULL, MAVLINK_TYPE_UINT16_T, 0, 0, offsetof(mavlink_protocol_version_t, version) }, \
  37. { "min_version", NULL, MAVLINK_TYPE_UINT16_T, 0, 2, offsetof(mavlink_protocol_version_t, min_version) }, \
  38. { "max_version", NULL, MAVLINK_TYPE_UINT16_T, 0, 4, offsetof(mavlink_protocol_version_t, max_version) }, \
  39. { "spec_version_hash", NULL, MAVLINK_TYPE_UINT8_T, 8, 6, offsetof(mavlink_protocol_version_t, spec_version_hash) }, \
  40. { "library_version_hash", NULL, MAVLINK_TYPE_UINT8_T, 8, 14, offsetof(mavlink_protocol_version_t, library_version_hash) }, \
  41. } \
  42. }
  43. #endif
  44. /**
  45. * @brief Pack a protocol_version message
  46. * @param system_id ID of this system
  47. * @param component_id ID of this component (e.g. 200 for IMU)
  48. * @param msg The MAVLink message to compress the data into
  49. *
  50. * @param version Currently active MAVLink version number * 100: v1.0 is 100, v2.0 is 200, etc.
  51. * @param min_version Minimum MAVLink version supported
  52. * @param max_version Maximum MAVLink version supported (set to the same value as version by default)
  53. * @param spec_version_hash The first 8 bytes (not characters printed in hex!) of the git hash.
  54. * @param library_version_hash The first 8 bytes (not characters printed in hex!) of the git hash.
  55. * @return length of the message in bytes (excluding serial stream start sign)
  56. */
  57. static inline uint16_t mavlink_msg_protocol_version_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
  58. uint16_t version, uint16_t min_version, uint16_t max_version, const uint8_t *spec_version_hash, const uint8_t *library_version_hash)
  59. {
  60. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  61. char buf[MAVLINK_MSG_ID_PROTOCOL_VERSION_LEN];
  62. _mav_put_uint16_t(buf, 0, version);
  63. _mav_put_uint16_t(buf, 2, min_version);
  64. _mav_put_uint16_t(buf, 4, max_version);
  65. _mav_put_uint8_t_array(buf, 6, spec_version_hash, 8);
  66. _mav_put_uint8_t_array(buf, 14, library_version_hash, 8);
  67. memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_PROTOCOL_VERSION_LEN);
  68. #else
  69. mavlink_protocol_version_t packet;
  70. packet.version = version;
  71. packet.min_version = min_version;
  72. packet.max_version = max_version;
  73. mav_array_memcpy(packet.spec_version_hash, spec_version_hash, sizeof(uint8_t)*8);
  74. mav_array_memcpy(packet.library_version_hash, library_version_hash, sizeof(uint8_t)*8);
  75. memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_PROTOCOL_VERSION_LEN);
  76. #endif
  77. msg->msgid = MAVLINK_MSG_ID_PROTOCOL_VERSION;
  78. return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_PROTOCOL_VERSION_MIN_LEN, MAVLINK_MSG_ID_PROTOCOL_VERSION_LEN, MAVLINK_MSG_ID_PROTOCOL_VERSION_CRC);
  79. }
  80. /**
  81. * @brief Pack a protocol_version message on a channel
  82. * @param system_id ID of this system
  83. * @param component_id ID of this component (e.g. 200 for IMU)
  84. * @param chan The MAVLink channel this message will be sent over
  85. * @param msg The MAVLink message to compress the data into
  86. * @param version Currently active MAVLink version number * 100: v1.0 is 100, v2.0 is 200, etc.
  87. * @param min_version Minimum MAVLink version supported
  88. * @param max_version Maximum MAVLink version supported (set to the same value as version by default)
  89. * @param spec_version_hash The first 8 bytes (not characters printed in hex!) of the git hash.
  90. * @param library_version_hash The first 8 bytes (not characters printed in hex!) of the git hash.
  91. * @return length of the message in bytes (excluding serial stream start sign)
  92. */
  93. static inline uint16_t mavlink_msg_protocol_version_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
  94. mavlink_message_t* msg,
  95. uint16_t version,uint16_t min_version,uint16_t max_version,const uint8_t *spec_version_hash,const uint8_t *library_version_hash)
  96. {
  97. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  98. char buf[MAVLINK_MSG_ID_PROTOCOL_VERSION_LEN];
  99. _mav_put_uint16_t(buf, 0, version);
  100. _mav_put_uint16_t(buf, 2, min_version);
  101. _mav_put_uint16_t(buf, 4, max_version);
  102. _mav_put_uint8_t_array(buf, 6, spec_version_hash, 8);
  103. _mav_put_uint8_t_array(buf, 14, library_version_hash, 8);
  104. memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_PROTOCOL_VERSION_LEN);
  105. #else
  106. mavlink_protocol_version_t packet;
  107. packet.version = version;
  108. packet.min_version = min_version;
  109. packet.max_version = max_version;
  110. mav_array_memcpy(packet.spec_version_hash, spec_version_hash, sizeof(uint8_t)*8);
  111. mav_array_memcpy(packet.library_version_hash, library_version_hash, sizeof(uint8_t)*8);
  112. memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_PROTOCOL_VERSION_LEN);
  113. #endif
  114. msg->msgid = MAVLINK_MSG_ID_PROTOCOL_VERSION;
  115. return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_PROTOCOL_VERSION_MIN_LEN, MAVLINK_MSG_ID_PROTOCOL_VERSION_LEN, MAVLINK_MSG_ID_PROTOCOL_VERSION_CRC);
  116. }
  117. /**
  118. * @brief Encode a protocol_version struct
  119. *
  120. * @param system_id ID of this system
  121. * @param component_id ID of this component (e.g. 200 for IMU)
  122. * @param msg The MAVLink message to compress the data into
  123. * @param protocol_version C-struct to read the message contents from
  124. */
  125. static inline uint16_t mavlink_msg_protocol_version_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_protocol_version_t* protocol_version)
  126. {
  127. return mavlink_msg_protocol_version_pack(system_id, component_id, msg, protocol_version->version, protocol_version->min_version, protocol_version->max_version, protocol_version->spec_version_hash, protocol_version->library_version_hash);
  128. }
  129. /**
  130. * @brief Encode a protocol_version struct on a channel
  131. *
  132. * @param system_id ID of this system
  133. * @param component_id ID of this component (e.g. 200 for IMU)
  134. * @param chan The MAVLink channel this message will be sent over
  135. * @param msg The MAVLink message to compress the data into
  136. * @param protocol_version C-struct to read the message contents from
  137. */
  138. static inline uint16_t mavlink_msg_protocol_version_encode_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, const mavlink_protocol_version_t* protocol_version)
  139. {
  140. return mavlink_msg_protocol_version_pack_chan(system_id, component_id, chan, msg, protocol_version->version, protocol_version->min_version, protocol_version->max_version, protocol_version->spec_version_hash, protocol_version->library_version_hash);
  141. }
  142. /**
  143. * @brief Send a protocol_version message
  144. * @param chan MAVLink channel to send the message
  145. *
  146. * @param version Currently active MAVLink version number * 100: v1.0 is 100, v2.0 is 200, etc.
  147. * @param min_version Minimum MAVLink version supported
  148. * @param max_version Maximum MAVLink version supported (set to the same value as version by default)
  149. * @param spec_version_hash The first 8 bytes (not characters printed in hex!) of the git hash.
  150. * @param library_version_hash The first 8 bytes (not characters printed in hex!) of the git hash.
  151. */
  152. #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
  153. static inline void mavlink_msg_protocol_version_send(mavlink_channel_t chan, uint16_t version, uint16_t min_version, uint16_t max_version, const uint8_t *spec_version_hash, const uint8_t *library_version_hash)
  154. {
  155. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  156. char buf[MAVLINK_MSG_ID_PROTOCOL_VERSION_LEN];
  157. _mav_put_uint16_t(buf, 0, version);
  158. _mav_put_uint16_t(buf, 2, min_version);
  159. _mav_put_uint16_t(buf, 4, max_version);
  160. _mav_put_uint8_t_array(buf, 6, spec_version_hash, 8);
  161. _mav_put_uint8_t_array(buf, 14, library_version_hash, 8);
  162. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_PROTOCOL_VERSION, buf, MAVLINK_MSG_ID_PROTOCOL_VERSION_MIN_LEN, MAVLINK_MSG_ID_PROTOCOL_VERSION_LEN, MAVLINK_MSG_ID_PROTOCOL_VERSION_CRC);
  163. #else
  164. mavlink_protocol_version_t packet;
  165. packet.version = version;
  166. packet.min_version = min_version;
  167. packet.max_version = max_version;
  168. mav_array_memcpy(packet.spec_version_hash, spec_version_hash, sizeof(uint8_t)*8);
  169. mav_array_memcpy(packet.library_version_hash, library_version_hash, sizeof(uint8_t)*8);
  170. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_PROTOCOL_VERSION, (const char *)&packet, MAVLINK_MSG_ID_PROTOCOL_VERSION_MIN_LEN, MAVLINK_MSG_ID_PROTOCOL_VERSION_LEN, MAVLINK_MSG_ID_PROTOCOL_VERSION_CRC);
  171. #endif
  172. }
  173. /**
  174. * @brief Send a protocol_version message
  175. * @param chan MAVLink channel to send the message
  176. * @param struct The MAVLink struct to serialize
  177. */
  178. static inline void mavlink_msg_protocol_version_send_struct(mavlink_channel_t chan, const mavlink_protocol_version_t* protocol_version)
  179. {
  180. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  181. mavlink_msg_protocol_version_send(chan, protocol_version->version, protocol_version->min_version, protocol_version->max_version, protocol_version->spec_version_hash, protocol_version->library_version_hash);
  182. #else
  183. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_PROTOCOL_VERSION, (const char *)protocol_version, MAVLINK_MSG_ID_PROTOCOL_VERSION_MIN_LEN, MAVLINK_MSG_ID_PROTOCOL_VERSION_LEN, MAVLINK_MSG_ID_PROTOCOL_VERSION_CRC);
  184. #endif
  185. }
  186. #if MAVLINK_MSG_ID_PROTOCOL_VERSION_LEN <= MAVLINK_MAX_PAYLOAD_LEN
  187. /*
  188. This varient of _send() can be used to save stack space by re-using
  189. memory from the receive buffer. The caller provides a
  190. mavlink_message_t which is the size of a full mavlink message. This
  191. is usually the receive buffer for the channel, and allows a reply to an
  192. incoming message with minimum stack space usage.
  193. */
  194. static inline void mavlink_msg_protocol_version_send_buf(mavlink_message_t *msgbuf, mavlink_channel_t chan, uint16_t version, uint16_t min_version, uint16_t max_version, const uint8_t *spec_version_hash, const uint8_t *library_version_hash)
  195. {
  196. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  197. char *buf = (char *)msgbuf;
  198. _mav_put_uint16_t(buf, 0, version);
  199. _mav_put_uint16_t(buf, 2, min_version);
  200. _mav_put_uint16_t(buf, 4, max_version);
  201. _mav_put_uint8_t_array(buf, 6, spec_version_hash, 8);
  202. _mav_put_uint8_t_array(buf, 14, library_version_hash, 8);
  203. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_PROTOCOL_VERSION, buf, MAVLINK_MSG_ID_PROTOCOL_VERSION_MIN_LEN, MAVLINK_MSG_ID_PROTOCOL_VERSION_LEN, MAVLINK_MSG_ID_PROTOCOL_VERSION_CRC);
  204. #else
  205. mavlink_protocol_version_t *packet = (mavlink_protocol_version_t *)msgbuf;
  206. packet->version = version;
  207. packet->min_version = min_version;
  208. packet->max_version = max_version;
  209. mav_array_memcpy(packet->spec_version_hash, spec_version_hash, sizeof(uint8_t)*8);
  210. mav_array_memcpy(packet->library_version_hash, library_version_hash, sizeof(uint8_t)*8);
  211. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_PROTOCOL_VERSION, (const char *)packet, MAVLINK_MSG_ID_PROTOCOL_VERSION_MIN_LEN, MAVLINK_MSG_ID_PROTOCOL_VERSION_LEN, MAVLINK_MSG_ID_PROTOCOL_VERSION_CRC);
  212. #endif
  213. }
  214. #endif
  215. #endif
  216. // MESSAGE PROTOCOL_VERSION UNPACKING
  217. /**
  218. * @brief Get field version from protocol_version message
  219. *
  220. * @return Currently active MAVLink version number * 100: v1.0 is 100, v2.0 is 200, etc.
  221. */
  222. static inline uint16_t mavlink_msg_protocol_version_get_version(const mavlink_message_t* msg)
  223. {
  224. return _MAV_RETURN_uint16_t(msg, 0);
  225. }
  226. /**
  227. * @brief Get field min_version from protocol_version message
  228. *
  229. * @return Minimum MAVLink version supported
  230. */
  231. static inline uint16_t mavlink_msg_protocol_version_get_min_version(const mavlink_message_t* msg)
  232. {
  233. return _MAV_RETURN_uint16_t(msg, 2);
  234. }
  235. /**
  236. * @brief Get field max_version from protocol_version message
  237. *
  238. * @return Maximum MAVLink version supported (set to the same value as version by default)
  239. */
  240. static inline uint16_t mavlink_msg_protocol_version_get_max_version(const mavlink_message_t* msg)
  241. {
  242. return _MAV_RETURN_uint16_t(msg, 4);
  243. }
  244. /**
  245. * @brief Get field spec_version_hash from protocol_version message
  246. *
  247. * @return The first 8 bytes (not characters printed in hex!) of the git hash.
  248. */
  249. static inline uint16_t mavlink_msg_protocol_version_get_spec_version_hash(const mavlink_message_t* msg, uint8_t *spec_version_hash)
  250. {
  251. return _MAV_RETURN_uint8_t_array(msg, spec_version_hash, 8, 6);
  252. }
  253. /**
  254. * @brief Get field library_version_hash from protocol_version message
  255. *
  256. * @return The first 8 bytes (not characters printed in hex!) of the git hash.
  257. */
  258. static inline uint16_t mavlink_msg_protocol_version_get_library_version_hash(const mavlink_message_t* msg, uint8_t *library_version_hash)
  259. {
  260. return _MAV_RETURN_uint8_t_array(msg, library_version_hash, 8, 14);
  261. }
  262. /**
  263. * @brief Decode a protocol_version message into a struct
  264. *
  265. * @param msg The message to decode
  266. * @param protocol_version C-struct to decode the message contents into
  267. */
  268. static inline void mavlink_msg_protocol_version_decode(const mavlink_message_t* msg, mavlink_protocol_version_t* protocol_version)
  269. {
  270. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  271. protocol_version->version = mavlink_msg_protocol_version_get_version(msg);
  272. protocol_version->min_version = mavlink_msg_protocol_version_get_min_version(msg);
  273. protocol_version->max_version = mavlink_msg_protocol_version_get_max_version(msg);
  274. mavlink_msg_protocol_version_get_spec_version_hash(msg, protocol_version->spec_version_hash);
  275. mavlink_msg_protocol_version_get_library_version_hash(msg, protocol_version->library_version_hash);
  276. #else
  277. uint8_t len = msg->len < MAVLINK_MSG_ID_PROTOCOL_VERSION_LEN? msg->len : MAVLINK_MSG_ID_PROTOCOL_VERSION_LEN;
  278. memset(protocol_version, 0, MAVLINK_MSG_ID_PROTOCOL_VERSION_LEN);
  279. memcpy(protocol_version, _MAV_PAYLOAD(msg), len);
  280. #endif
  281. }