mavlink_msg_component_metadata.h 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317
  1. #pragma once
  2. // MESSAGE COMPONENT_METADATA PACKING
  3. #define MAVLINK_MSG_ID_COMPONENT_METADATA 397
  4. typedef struct __mavlink_component_metadata_t {
  5. uint32_t time_boot_ms; /*< [ms] Timestamp (time since system boot).*/
  6. uint32_t file_crc; /*< CRC32 of the general metadata file.*/
  7. char uri[100]; /*< MAVLink FTP URI for the general metadata file (COMP_METADATA_TYPE_GENERAL), which may be compressed with xz. The file contains general component metadata, and may contain URI links for additional metadata (see COMP_METADATA_TYPE). The information is static from boot, and may be generated at compile time. The string needs to be zero terminated.*/
  8. } mavlink_component_metadata_t;
  9. #define MAVLINK_MSG_ID_COMPONENT_METADATA_LEN 108
  10. #define MAVLINK_MSG_ID_COMPONENT_METADATA_MIN_LEN 108
  11. #define MAVLINK_MSG_ID_397_LEN 108
  12. #define MAVLINK_MSG_ID_397_MIN_LEN 108
  13. #define MAVLINK_MSG_ID_COMPONENT_METADATA_CRC 182
  14. #define MAVLINK_MSG_ID_397_CRC 182
  15. #define MAVLINK_MSG_COMPONENT_METADATA_FIELD_URI_LEN 100
  16. #if MAVLINK_COMMAND_24BIT
  17. #define MAVLINK_MESSAGE_INFO_COMPONENT_METADATA { \
  18. 397, \
  19. "COMPONENT_METADATA", \
  20. 3, \
  21. { { "time_boot_ms", NULL, MAVLINK_TYPE_UINT32_T, 0, 0, offsetof(mavlink_component_metadata_t, time_boot_ms) }, \
  22. { "file_crc", NULL, MAVLINK_TYPE_UINT32_T, 0, 4, offsetof(mavlink_component_metadata_t, file_crc) }, \
  23. { "uri", NULL, MAVLINK_TYPE_CHAR, 100, 8, offsetof(mavlink_component_metadata_t, uri) }, \
  24. } \
  25. }
  26. #else
  27. #define MAVLINK_MESSAGE_INFO_COMPONENT_METADATA { \
  28. "COMPONENT_METADATA", \
  29. 3, \
  30. { { "time_boot_ms", NULL, MAVLINK_TYPE_UINT32_T, 0, 0, offsetof(mavlink_component_metadata_t, time_boot_ms) }, \
  31. { "file_crc", NULL, MAVLINK_TYPE_UINT32_T, 0, 4, offsetof(mavlink_component_metadata_t, file_crc) }, \
  32. { "uri", NULL, MAVLINK_TYPE_CHAR, 100, 8, offsetof(mavlink_component_metadata_t, uri) }, \
  33. } \
  34. }
  35. #endif
  36. /**
  37. * @brief Pack a component_metadata message
  38. * @param system_id ID of this system
  39. * @param component_id ID of this component (e.g. 200 for IMU)
  40. * @param msg The MAVLink message to compress the data into
  41. *
  42. * @param time_boot_ms [ms] Timestamp (time since system boot).
  43. * @param file_crc CRC32 of the general metadata file.
  44. * @param uri MAVLink FTP URI for the general metadata file (COMP_METADATA_TYPE_GENERAL), which may be compressed with xz. The file contains general component metadata, and may contain URI links for additional metadata (see COMP_METADATA_TYPE). The information is static from boot, and may be generated at compile time. The string needs to be zero terminated.
  45. * @return length of the message in bytes (excluding serial stream start sign)
  46. */
  47. MAVLINK_WIP
  48. static inline uint16_t mavlink_msg_component_metadata_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
  49. uint32_t time_boot_ms, uint32_t file_crc, const char *uri)
  50. {
  51. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  52. char buf[MAVLINK_MSG_ID_COMPONENT_METADATA_LEN];
  53. _mav_put_uint32_t(buf, 0, time_boot_ms);
  54. _mav_put_uint32_t(buf, 4, file_crc);
  55. _mav_put_char_array(buf, 8, uri, 100);
  56. memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_COMPONENT_METADATA_LEN);
  57. #else
  58. mavlink_component_metadata_t packet;
  59. packet.time_boot_ms = time_boot_ms;
  60. packet.file_crc = file_crc;
  61. mav_array_assign_char(packet.uri, uri, 100);
  62. memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_COMPONENT_METADATA_LEN);
  63. #endif
  64. msg->msgid = MAVLINK_MSG_ID_COMPONENT_METADATA;
  65. return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_COMPONENT_METADATA_MIN_LEN, MAVLINK_MSG_ID_COMPONENT_METADATA_LEN, MAVLINK_MSG_ID_COMPONENT_METADATA_CRC);
  66. }
  67. /**
  68. * @brief Pack a component_metadata message
  69. * @param system_id ID of this system
  70. * @param component_id ID of this component (e.g. 200 for IMU)
  71. * @param status MAVLink status structure
  72. * @param msg The MAVLink message to compress the data into
  73. *
  74. * @param time_boot_ms [ms] Timestamp (time since system boot).
  75. * @param file_crc CRC32 of the general metadata file.
  76. * @param uri MAVLink FTP URI for the general metadata file (COMP_METADATA_TYPE_GENERAL), which may be compressed with xz. The file contains general component metadata, and may contain URI links for additional metadata (see COMP_METADATA_TYPE). The information is static from boot, and may be generated at compile time. The string needs to be zero terminated.
  77. * @return length of the message in bytes (excluding serial stream start sign)
  78. */
  79. static inline uint16_t mavlink_msg_component_metadata_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg,
  80. uint32_t time_boot_ms, uint32_t file_crc, const char *uri)
  81. {
  82. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  83. char buf[MAVLINK_MSG_ID_COMPONENT_METADATA_LEN];
  84. _mav_put_uint32_t(buf, 0, time_boot_ms);
  85. _mav_put_uint32_t(buf, 4, file_crc);
  86. _mav_put_char_array(buf, 8, uri, 100);
  87. memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_COMPONENT_METADATA_LEN);
  88. #else
  89. mavlink_component_metadata_t packet;
  90. packet.time_boot_ms = time_boot_ms;
  91. packet.file_crc = file_crc;
  92. mav_array_memcpy(packet.uri, uri, sizeof(char)*100);
  93. memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_COMPONENT_METADATA_LEN);
  94. #endif
  95. msg->msgid = MAVLINK_MSG_ID_COMPONENT_METADATA;
  96. #if MAVLINK_CRC_EXTRA
  97. return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_COMPONENT_METADATA_MIN_LEN, MAVLINK_MSG_ID_COMPONENT_METADATA_LEN, MAVLINK_MSG_ID_COMPONENT_METADATA_CRC);
  98. #else
  99. return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_COMPONENT_METADATA_MIN_LEN, MAVLINK_MSG_ID_COMPONENT_METADATA_LEN);
  100. #endif
  101. }
  102. /**
  103. * @brief Pack a component_metadata message on a channel
  104. * @param system_id ID of this system
  105. * @param component_id ID of this component (e.g. 200 for IMU)
  106. * @param chan The MAVLink channel this message will be sent over
  107. * @param msg The MAVLink message to compress the data into
  108. * @param time_boot_ms [ms] Timestamp (time since system boot).
  109. * @param file_crc CRC32 of the general metadata file.
  110. * @param uri MAVLink FTP URI for the general metadata file (COMP_METADATA_TYPE_GENERAL), which may be compressed with xz. The file contains general component metadata, and may contain URI links for additional metadata (see COMP_METADATA_TYPE). The information is static from boot, and may be generated at compile time. The string needs to be zero terminated.
  111. * @return length of the message in bytes (excluding serial stream start sign)
  112. */
  113. MAVLINK_WIP
  114. static inline uint16_t mavlink_msg_component_metadata_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
  115. mavlink_message_t* msg,
  116. uint32_t time_boot_ms,uint32_t file_crc,const char *uri)
  117. {
  118. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  119. char buf[MAVLINK_MSG_ID_COMPONENT_METADATA_LEN];
  120. _mav_put_uint32_t(buf, 0, time_boot_ms);
  121. _mav_put_uint32_t(buf, 4, file_crc);
  122. _mav_put_char_array(buf, 8, uri, 100);
  123. memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_COMPONENT_METADATA_LEN);
  124. #else
  125. mavlink_component_metadata_t packet;
  126. packet.time_boot_ms = time_boot_ms;
  127. packet.file_crc = file_crc;
  128. mav_array_assign_char(packet.uri, uri, 100);
  129. memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_COMPONENT_METADATA_LEN);
  130. #endif
  131. msg->msgid = MAVLINK_MSG_ID_COMPONENT_METADATA;
  132. return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_COMPONENT_METADATA_MIN_LEN, MAVLINK_MSG_ID_COMPONENT_METADATA_LEN, MAVLINK_MSG_ID_COMPONENT_METADATA_CRC);
  133. }
  134. /**
  135. * @brief Encode a component_metadata struct
  136. *
  137. * @param system_id ID of this system
  138. * @param component_id ID of this component (e.g. 200 for IMU)
  139. * @param msg The MAVLink message to compress the data into
  140. * @param component_metadata C-struct to read the message contents from
  141. */
  142. MAVLINK_WIP
  143. static inline uint16_t mavlink_msg_component_metadata_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_component_metadata_t* component_metadata)
  144. {
  145. return mavlink_msg_component_metadata_pack(system_id, component_id, msg, component_metadata->time_boot_ms, component_metadata->file_crc, component_metadata->uri);
  146. }
  147. /**
  148. * @brief Encode a component_metadata struct on a channel
  149. *
  150. * @param system_id ID of this system
  151. * @param component_id ID of this component (e.g. 200 for IMU)
  152. * @param chan The MAVLink channel this message will be sent over
  153. * @param msg The MAVLink message to compress the data into
  154. * @param component_metadata C-struct to read the message contents from
  155. */
  156. MAVLINK_WIP
  157. static inline uint16_t mavlink_msg_component_metadata_encode_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, const mavlink_component_metadata_t* component_metadata)
  158. {
  159. return mavlink_msg_component_metadata_pack_chan(system_id, component_id, chan, msg, component_metadata->time_boot_ms, component_metadata->file_crc, component_metadata->uri);
  160. }
  161. /**
  162. * @brief Encode a component_metadata struct with provided status structure
  163. *
  164. * @param system_id ID of this system
  165. * @param component_id ID of this component (e.g. 200 for IMU)
  166. * @param status MAVLink status structure
  167. * @param msg The MAVLink message to compress the data into
  168. * @param component_metadata C-struct to read the message contents from
  169. */
  170. static inline uint16_t mavlink_msg_component_metadata_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_component_metadata_t* component_metadata)
  171. {
  172. return mavlink_msg_component_metadata_pack_status(system_id, component_id, _status, msg, component_metadata->time_boot_ms, component_metadata->file_crc, component_metadata->uri);
  173. }
  174. /**
  175. * @brief Send a component_metadata message
  176. * @param chan MAVLink channel to send the message
  177. *
  178. * @param time_boot_ms [ms] Timestamp (time since system boot).
  179. * @param file_crc CRC32 of the general metadata file.
  180. * @param uri MAVLink FTP URI for the general metadata file (COMP_METADATA_TYPE_GENERAL), which may be compressed with xz. The file contains general component metadata, and may contain URI links for additional metadata (see COMP_METADATA_TYPE). The information is static from boot, and may be generated at compile time. The string needs to be zero terminated.
  181. */
  182. #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
  183. MAVLINK_WIP
  184. static inline void mavlink_msg_component_metadata_send(mavlink_channel_t chan, uint32_t time_boot_ms, uint32_t file_crc, const char *uri)
  185. {
  186. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  187. char buf[MAVLINK_MSG_ID_COMPONENT_METADATA_LEN];
  188. _mav_put_uint32_t(buf, 0, time_boot_ms);
  189. _mav_put_uint32_t(buf, 4, file_crc);
  190. _mav_put_char_array(buf, 8, uri, 100);
  191. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_COMPONENT_METADATA, buf, MAVLINK_MSG_ID_COMPONENT_METADATA_MIN_LEN, MAVLINK_MSG_ID_COMPONENT_METADATA_LEN, MAVLINK_MSG_ID_COMPONENT_METADATA_CRC);
  192. #else
  193. mavlink_component_metadata_t packet;
  194. packet.time_boot_ms = time_boot_ms;
  195. packet.file_crc = file_crc;
  196. mav_array_assign_char(packet.uri, uri, 100);
  197. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_COMPONENT_METADATA, (const char *)&packet, MAVLINK_MSG_ID_COMPONENT_METADATA_MIN_LEN, MAVLINK_MSG_ID_COMPONENT_METADATA_LEN, MAVLINK_MSG_ID_COMPONENT_METADATA_CRC);
  198. #endif
  199. }
  200. /**
  201. * @brief Send a component_metadata message
  202. * @param chan MAVLink channel to send the message
  203. * @param struct The MAVLink struct to serialize
  204. */
  205. MAVLINK_WIP
  206. static inline void mavlink_msg_component_metadata_send_struct(mavlink_channel_t chan, const mavlink_component_metadata_t* component_metadata)
  207. {
  208. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  209. mavlink_msg_component_metadata_send(chan, component_metadata->time_boot_ms, component_metadata->file_crc, component_metadata->uri);
  210. #else
  211. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_COMPONENT_METADATA, (const char *)component_metadata, MAVLINK_MSG_ID_COMPONENT_METADATA_MIN_LEN, MAVLINK_MSG_ID_COMPONENT_METADATA_LEN, MAVLINK_MSG_ID_COMPONENT_METADATA_CRC);
  212. #endif
  213. }
  214. #if MAVLINK_MSG_ID_COMPONENT_METADATA_LEN <= MAVLINK_MAX_PAYLOAD_LEN
  215. /*
  216. This variant of _send() can be used to save stack space by reusing
  217. memory from the receive buffer. The caller provides a
  218. mavlink_message_t which is the size of a full mavlink message. This
  219. is usually the receive buffer for the channel, and allows a reply to an
  220. incoming message with minimum stack space usage.
  221. */
  222. MAVLINK_WIP
  223. static inline void mavlink_msg_component_metadata_send_buf(mavlink_message_t *msgbuf, mavlink_channel_t chan, uint32_t time_boot_ms, uint32_t file_crc, const char *uri)
  224. {
  225. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  226. char *buf = (char *)msgbuf;
  227. _mav_put_uint32_t(buf, 0, time_boot_ms);
  228. _mav_put_uint32_t(buf, 4, file_crc);
  229. _mav_put_char_array(buf, 8, uri, 100);
  230. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_COMPONENT_METADATA, buf, MAVLINK_MSG_ID_COMPONENT_METADATA_MIN_LEN, MAVLINK_MSG_ID_COMPONENT_METADATA_LEN, MAVLINK_MSG_ID_COMPONENT_METADATA_CRC);
  231. #else
  232. mavlink_component_metadata_t *packet = (mavlink_component_metadata_t *)msgbuf;
  233. packet->time_boot_ms = time_boot_ms;
  234. packet->file_crc = file_crc;
  235. mav_array_assign_char(packet->uri, uri, 100);
  236. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_COMPONENT_METADATA, (const char *)packet, MAVLINK_MSG_ID_COMPONENT_METADATA_MIN_LEN, MAVLINK_MSG_ID_COMPONENT_METADATA_LEN, MAVLINK_MSG_ID_COMPONENT_METADATA_CRC);
  237. #endif
  238. }
  239. #endif
  240. #endif
  241. // MESSAGE COMPONENT_METADATA UNPACKING
  242. /**
  243. * @brief Get field time_boot_ms from component_metadata message
  244. *
  245. * @return [ms] Timestamp (time since system boot).
  246. */
  247. MAVLINK_WIP
  248. static inline uint32_t mavlink_msg_component_metadata_get_time_boot_ms(const mavlink_message_t* msg)
  249. {
  250. return _MAV_RETURN_uint32_t(msg, 0);
  251. }
  252. /**
  253. * @brief Get field file_crc from component_metadata message
  254. *
  255. * @return CRC32 of the general metadata file.
  256. */
  257. MAVLINK_WIP
  258. static inline uint32_t mavlink_msg_component_metadata_get_file_crc(const mavlink_message_t* msg)
  259. {
  260. return _MAV_RETURN_uint32_t(msg, 4);
  261. }
  262. /**
  263. * @brief Get field uri from component_metadata message
  264. *
  265. * @return MAVLink FTP URI for the general metadata file (COMP_METADATA_TYPE_GENERAL), which may be compressed with xz. The file contains general component metadata, and may contain URI links for additional metadata (see COMP_METADATA_TYPE). The information is static from boot, and may be generated at compile time. The string needs to be zero terminated.
  266. */
  267. MAVLINK_WIP
  268. static inline uint16_t mavlink_msg_component_metadata_get_uri(const mavlink_message_t* msg, char *uri)
  269. {
  270. return _MAV_RETURN_char_array(msg, uri, 100, 8);
  271. }
  272. /**
  273. * @brief Decode a component_metadata message into a struct
  274. *
  275. * @param msg The message to decode
  276. * @param component_metadata C-struct to decode the message contents into
  277. */
  278. MAVLINK_WIP
  279. static inline void mavlink_msg_component_metadata_decode(const mavlink_message_t* msg, mavlink_component_metadata_t* component_metadata)
  280. {
  281. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  282. component_metadata->time_boot_ms = mavlink_msg_component_metadata_get_time_boot_ms(msg);
  283. component_metadata->file_crc = mavlink_msg_component_metadata_get_file_crc(msg);
  284. mavlink_msg_component_metadata_get_uri(msg, component_metadata->uri);
  285. #else
  286. uint8_t len = msg->len < MAVLINK_MSG_ID_COMPONENT_METADATA_LEN? msg->len : MAVLINK_MSG_ID_COMPONENT_METADATA_LEN;
  287. memset(component_metadata, 0, MAVLINK_MSG_ID_COMPONENT_METADATA_LEN);
  288. memcpy(component_metadata, _MAV_PAYLOAD(msg), len);
  289. #endif
  290. }