mavlink_msg_storage_information.h 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495
  1. #pragma once
  2. // MESSAGE STORAGE_INFORMATION PACKING
  3. #define MAVLINK_MSG_ID_STORAGE_INFORMATION 261
  4. typedef struct __mavlink_storage_information_t {
  5. uint32_t time_boot_ms; /*< [ms] Timestamp (time since system boot).*/
  6. float total_capacity; /*< [MiB] Total capacity. If storage is not ready (STORAGE_STATUS_READY) value will be ignored.*/
  7. float used_capacity; /*< [MiB] Used capacity. If storage is not ready (STORAGE_STATUS_READY) value will be ignored.*/
  8. float available_capacity; /*< [MiB] Available storage capacity. If storage is not ready (STORAGE_STATUS_READY) value will be ignored.*/
  9. float read_speed; /*< [MiB/s] Read speed.*/
  10. float write_speed; /*< [MiB/s] Write speed.*/
  11. uint8_t storage_id; /*< Storage ID (1 for first, 2 for second, etc.)*/
  12. uint8_t storage_count; /*< Number of storage devices*/
  13. uint8_t status; /*< Status of storage*/
  14. uint8_t type; /*< Type of storage*/
  15. char name[32]; /*< Textual storage name to be used in UI (microSD 1, Internal Memory, etc.) This is a NULL terminated string. If it is exactly 32 characters long, add a terminating NULL. If this string is empty, the generic type is shown to the user.*/
  16. uint8_t storage_usage; /*< Flags indicating whether this instance is preferred storage for photos, videos, etc.
  17. Note: Implementations should initially set the flags on the system-default storage id used for saving media (if possible/supported).
  18. This setting can then be overridden using MAV_CMD_SET_STORAGE_USAGE.
  19. If the media usage flags are not set, a GCS may assume storage ID 1 is the default storage for all media types.*/
  20. } mavlink_storage_information_t;
  21. #define MAVLINK_MSG_ID_STORAGE_INFORMATION_LEN 61
  22. #define MAVLINK_MSG_ID_STORAGE_INFORMATION_MIN_LEN 27
  23. #define MAVLINK_MSG_ID_261_LEN 61
  24. #define MAVLINK_MSG_ID_261_MIN_LEN 27
  25. #define MAVLINK_MSG_ID_STORAGE_INFORMATION_CRC 179
  26. #define MAVLINK_MSG_ID_261_CRC 179
  27. #define MAVLINK_MSG_STORAGE_INFORMATION_FIELD_NAME_LEN 32
  28. #if MAVLINK_COMMAND_24BIT
  29. #define MAVLINK_MESSAGE_INFO_STORAGE_INFORMATION { \
  30. 261, \
  31. "STORAGE_INFORMATION", \
  32. 12, \
  33. { { "time_boot_ms", NULL, MAVLINK_TYPE_UINT32_T, 0, 0, offsetof(mavlink_storage_information_t, time_boot_ms) }, \
  34. { "storage_id", NULL, MAVLINK_TYPE_UINT8_T, 0, 24, offsetof(mavlink_storage_information_t, storage_id) }, \
  35. { "storage_count", NULL, MAVLINK_TYPE_UINT8_T, 0, 25, offsetof(mavlink_storage_information_t, storage_count) }, \
  36. { "status", NULL, MAVLINK_TYPE_UINT8_T, 0, 26, offsetof(mavlink_storage_information_t, status) }, \
  37. { "total_capacity", NULL, MAVLINK_TYPE_FLOAT, 0, 4, offsetof(mavlink_storage_information_t, total_capacity) }, \
  38. { "used_capacity", NULL, MAVLINK_TYPE_FLOAT, 0, 8, offsetof(mavlink_storage_information_t, used_capacity) }, \
  39. { "available_capacity", NULL, MAVLINK_TYPE_FLOAT, 0, 12, offsetof(mavlink_storage_information_t, available_capacity) }, \
  40. { "read_speed", NULL, MAVLINK_TYPE_FLOAT, 0, 16, offsetof(mavlink_storage_information_t, read_speed) }, \
  41. { "write_speed", NULL, MAVLINK_TYPE_FLOAT, 0, 20, offsetof(mavlink_storage_information_t, write_speed) }, \
  42. { "type", NULL, MAVLINK_TYPE_UINT8_T, 0, 27, offsetof(mavlink_storage_information_t, type) }, \
  43. { "name", NULL, MAVLINK_TYPE_CHAR, 32, 28, offsetof(mavlink_storage_information_t, name) }, \
  44. { "storage_usage", NULL, MAVLINK_TYPE_UINT8_T, 0, 60, offsetof(mavlink_storage_information_t, storage_usage) }, \
  45. } \
  46. }
  47. #else
  48. #define MAVLINK_MESSAGE_INFO_STORAGE_INFORMATION { \
  49. "STORAGE_INFORMATION", \
  50. 12, \
  51. { { "time_boot_ms", NULL, MAVLINK_TYPE_UINT32_T, 0, 0, offsetof(mavlink_storage_information_t, time_boot_ms) }, \
  52. { "storage_id", NULL, MAVLINK_TYPE_UINT8_T, 0, 24, offsetof(mavlink_storage_information_t, storage_id) }, \
  53. { "storage_count", NULL, MAVLINK_TYPE_UINT8_T, 0, 25, offsetof(mavlink_storage_information_t, storage_count) }, \
  54. { "status", NULL, MAVLINK_TYPE_UINT8_T, 0, 26, offsetof(mavlink_storage_information_t, status) }, \
  55. { "total_capacity", NULL, MAVLINK_TYPE_FLOAT, 0, 4, offsetof(mavlink_storage_information_t, total_capacity) }, \
  56. { "used_capacity", NULL, MAVLINK_TYPE_FLOAT, 0, 8, offsetof(mavlink_storage_information_t, used_capacity) }, \
  57. { "available_capacity", NULL, MAVLINK_TYPE_FLOAT, 0, 12, offsetof(mavlink_storage_information_t, available_capacity) }, \
  58. { "read_speed", NULL, MAVLINK_TYPE_FLOAT, 0, 16, offsetof(mavlink_storage_information_t, read_speed) }, \
  59. { "write_speed", NULL, MAVLINK_TYPE_FLOAT, 0, 20, offsetof(mavlink_storage_information_t, write_speed) }, \
  60. { "type", NULL, MAVLINK_TYPE_UINT8_T, 0, 27, offsetof(mavlink_storage_information_t, type) }, \
  61. { "name", NULL, MAVLINK_TYPE_CHAR, 32, 28, offsetof(mavlink_storage_information_t, name) }, \
  62. { "storage_usage", NULL, MAVLINK_TYPE_UINT8_T, 0, 60, offsetof(mavlink_storage_information_t, storage_usage) }, \
  63. } \
  64. }
  65. #endif
  66. /**
  67. * @brief Pack a storage_information 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 time_boot_ms [ms] Timestamp (time since system boot).
  73. * @param storage_id Storage ID (1 for first, 2 for second, etc.)
  74. * @param storage_count Number of storage devices
  75. * @param status Status of storage
  76. * @param total_capacity [MiB] Total capacity. If storage is not ready (STORAGE_STATUS_READY) value will be ignored.
  77. * @param used_capacity [MiB] Used capacity. If storage is not ready (STORAGE_STATUS_READY) value will be ignored.
  78. * @param available_capacity [MiB] Available storage capacity. If storage is not ready (STORAGE_STATUS_READY) value will be ignored.
  79. * @param read_speed [MiB/s] Read speed.
  80. * @param write_speed [MiB/s] Write speed.
  81. * @param type Type of storage
  82. * @param name Textual storage name to be used in UI (microSD 1, Internal Memory, etc.) This is a NULL terminated string. If it is exactly 32 characters long, add a terminating NULL. If this string is empty, the generic type is shown to the user.
  83. * @param storage_usage Flags indicating whether this instance is preferred storage for photos, videos, etc.
  84. Note: Implementations should initially set the flags on the system-default storage id used for saving media (if possible/supported).
  85. This setting can then be overridden using MAV_CMD_SET_STORAGE_USAGE.
  86. If the media usage flags are not set, a GCS may assume storage ID 1 is the default storage for all media types.
  87. * @return length of the message in bytes (excluding serial stream start sign)
  88. */
  89. static inline uint16_t mavlink_msg_storage_information_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
  90. uint32_t time_boot_ms, uint8_t storage_id, uint8_t storage_count, uint8_t status, float total_capacity, float used_capacity, float available_capacity, float read_speed, float write_speed, uint8_t type, const char *name, uint8_t storage_usage)
  91. {
  92. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  93. char buf[MAVLINK_MSG_ID_STORAGE_INFORMATION_LEN];
  94. _mav_put_uint32_t(buf, 0, time_boot_ms);
  95. _mav_put_float(buf, 4, total_capacity);
  96. _mav_put_float(buf, 8, used_capacity);
  97. _mav_put_float(buf, 12, available_capacity);
  98. _mav_put_float(buf, 16, read_speed);
  99. _mav_put_float(buf, 20, write_speed);
  100. _mav_put_uint8_t(buf, 24, storage_id);
  101. _mav_put_uint8_t(buf, 25, storage_count);
  102. _mav_put_uint8_t(buf, 26, status);
  103. _mav_put_uint8_t(buf, 27, type);
  104. _mav_put_uint8_t(buf, 60, storage_usage);
  105. _mav_put_char_array(buf, 28, name, 32);
  106. memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_STORAGE_INFORMATION_LEN);
  107. #else
  108. mavlink_storage_information_t packet;
  109. packet.time_boot_ms = time_boot_ms;
  110. packet.total_capacity = total_capacity;
  111. packet.used_capacity = used_capacity;
  112. packet.available_capacity = available_capacity;
  113. packet.read_speed = read_speed;
  114. packet.write_speed = write_speed;
  115. packet.storage_id = storage_id;
  116. packet.storage_count = storage_count;
  117. packet.status = status;
  118. packet.type = type;
  119. packet.storage_usage = storage_usage;
  120. mav_array_memcpy(packet.name, name, sizeof(char)*32);
  121. memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_STORAGE_INFORMATION_LEN);
  122. #endif
  123. msg->msgid = MAVLINK_MSG_ID_STORAGE_INFORMATION;
  124. return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_STORAGE_INFORMATION_MIN_LEN, MAVLINK_MSG_ID_STORAGE_INFORMATION_LEN, MAVLINK_MSG_ID_STORAGE_INFORMATION_CRC);
  125. }
  126. /**
  127. * @brief Pack a storage_information message on a channel
  128. * @param system_id ID of this system
  129. * @param component_id ID of this component (e.g. 200 for IMU)
  130. * @param chan The MAVLink channel this message will be sent over
  131. * @param msg The MAVLink message to compress the data into
  132. * @param time_boot_ms [ms] Timestamp (time since system boot).
  133. * @param storage_id Storage ID (1 for first, 2 for second, etc.)
  134. * @param storage_count Number of storage devices
  135. * @param status Status of storage
  136. * @param total_capacity [MiB] Total capacity. If storage is not ready (STORAGE_STATUS_READY) value will be ignored.
  137. * @param used_capacity [MiB] Used capacity. If storage is not ready (STORAGE_STATUS_READY) value will be ignored.
  138. * @param available_capacity [MiB] Available storage capacity. If storage is not ready (STORAGE_STATUS_READY) value will be ignored.
  139. * @param read_speed [MiB/s] Read speed.
  140. * @param write_speed [MiB/s] Write speed.
  141. * @param type Type of storage
  142. * @param name Textual storage name to be used in UI (microSD 1, Internal Memory, etc.) This is a NULL terminated string. If it is exactly 32 characters long, add a terminating NULL. If this string is empty, the generic type is shown to the user.
  143. * @param storage_usage Flags indicating whether this instance is preferred storage for photos, videos, etc.
  144. Note: Implementations should initially set the flags on the system-default storage id used for saving media (if possible/supported).
  145. This setting can then be overridden using MAV_CMD_SET_STORAGE_USAGE.
  146. If the media usage flags are not set, a GCS may assume storage ID 1 is the default storage for all media types.
  147. * @return length of the message in bytes (excluding serial stream start sign)
  148. */
  149. static inline uint16_t mavlink_msg_storage_information_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
  150. mavlink_message_t* msg,
  151. uint32_t time_boot_ms,uint8_t storage_id,uint8_t storage_count,uint8_t status,float total_capacity,float used_capacity,float available_capacity,float read_speed,float write_speed,uint8_t type,const char *name,uint8_t storage_usage)
  152. {
  153. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  154. char buf[MAVLINK_MSG_ID_STORAGE_INFORMATION_LEN];
  155. _mav_put_uint32_t(buf, 0, time_boot_ms);
  156. _mav_put_float(buf, 4, total_capacity);
  157. _mav_put_float(buf, 8, used_capacity);
  158. _mav_put_float(buf, 12, available_capacity);
  159. _mav_put_float(buf, 16, read_speed);
  160. _mav_put_float(buf, 20, write_speed);
  161. _mav_put_uint8_t(buf, 24, storage_id);
  162. _mav_put_uint8_t(buf, 25, storage_count);
  163. _mav_put_uint8_t(buf, 26, status);
  164. _mav_put_uint8_t(buf, 27, type);
  165. _mav_put_uint8_t(buf, 60, storage_usage);
  166. _mav_put_char_array(buf, 28, name, 32);
  167. memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_STORAGE_INFORMATION_LEN);
  168. #else
  169. mavlink_storage_information_t packet;
  170. packet.time_boot_ms = time_boot_ms;
  171. packet.total_capacity = total_capacity;
  172. packet.used_capacity = used_capacity;
  173. packet.available_capacity = available_capacity;
  174. packet.read_speed = read_speed;
  175. packet.write_speed = write_speed;
  176. packet.storage_id = storage_id;
  177. packet.storage_count = storage_count;
  178. packet.status = status;
  179. packet.type = type;
  180. packet.storage_usage = storage_usage;
  181. mav_array_memcpy(packet.name, name, sizeof(char)*32);
  182. memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_STORAGE_INFORMATION_LEN);
  183. #endif
  184. msg->msgid = MAVLINK_MSG_ID_STORAGE_INFORMATION;
  185. return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_STORAGE_INFORMATION_MIN_LEN, MAVLINK_MSG_ID_STORAGE_INFORMATION_LEN, MAVLINK_MSG_ID_STORAGE_INFORMATION_CRC);
  186. }
  187. /**
  188. * @brief Encode a storage_information struct
  189. *
  190. * @param system_id ID of this system
  191. * @param component_id ID of this component (e.g. 200 for IMU)
  192. * @param msg The MAVLink message to compress the data into
  193. * @param storage_information C-struct to read the message contents from
  194. */
  195. static inline uint16_t mavlink_msg_storage_information_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_storage_information_t* storage_information)
  196. {
  197. return mavlink_msg_storage_information_pack(system_id, component_id, msg, storage_information->time_boot_ms, storage_information->storage_id, storage_information->storage_count, storage_information->status, storage_information->total_capacity, storage_information->used_capacity, storage_information->available_capacity, storage_information->read_speed, storage_information->write_speed, storage_information->type, storage_information->name, storage_information->storage_usage);
  198. }
  199. /**
  200. * @brief Encode a storage_information struct on a channel
  201. *
  202. * @param system_id ID of this system
  203. * @param component_id ID of this component (e.g. 200 for IMU)
  204. * @param chan The MAVLink channel this message will be sent over
  205. * @param msg The MAVLink message to compress the data into
  206. * @param storage_information C-struct to read the message contents from
  207. */
  208. static inline uint16_t mavlink_msg_storage_information_encode_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, const mavlink_storage_information_t* storage_information)
  209. {
  210. return mavlink_msg_storage_information_pack_chan(system_id, component_id, chan, msg, storage_information->time_boot_ms, storage_information->storage_id, storage_information->storage_count, storage_information->status, storage_information->total_capacity, storage_information->used_capacity, storage_information->available_capacity, storage_information->read_speed, storage_information->write_speed, storage_information->type, storage_information->name, storage_information->storage_usage);
  211. }
  212. /**
  213. * @brief Send a storage_information message
  214. * @param chan MAVLink channel to send the message
  215. *
  216. * @param time_boot_ms [ms] Timestamp (time since system boot).
  217. * @param storage_id Storage ID (1 for first, 2 for second, etc.)
  218. * @param storage_count Number of storage devices
  219. * @param status Status of storage
  220. * @param total_capacity [MiB] Total capacity. If storage is not ready (STORAGE_STATUS_READY) value will be ignored.
  221. * @param used_capacity [MiB] Used capacity. If storage is not ready (STORAGE_STATUS_READY) value will be ignored.
  222. * @param available_capacity [MiB] Available storage capacity. If storage is not ready (STORAGE_STATUS_READY) value will be ignored.
  223. * @param read_speed [MiB/s] Read speed.
  224. * @param write_speed [MiB/s] Write speed.
  225. * @param type Type of storage
  226. * @param name Textual storage name to be used in UI (microSD 1, Internal Memory, etc.) This is a NULL terminated string. If it is exactly 32 characters long, add a terminating NULL. If this string is empty, the generic type is shown to the user.
  227. * @param storage_usage Flags indicating whether this instance is preferred storage for photos, videos, etc.
  228. Note: Implementations should initially set the flags on the system-default storage id used for saving media (if possible/supported).
  229. This setting can then be overridden using MAV_CMD_SET_STORAGE_USAGE.
  230. If the media usage flags are not set, a GCS may assume storage ID 1 is the default storage for all media types.
  231. */
  232. #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
  233. static inline void mavlink_msg_storage_information_send(mavlink_channel_t chan, uint32_t time_boot_ms, uint8_t storage_id, uint8_t storage_count, uint8_t status, float total_capacity, float used_capacity, float available_capacity, float read_speed, float write_speed, uint8_t type, const char *name, uint8_t storage_usage)
  234. {
  235. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  236. char buf[MAVLINK_MSG_ID_STORAGE_INFORMATION_LEN];
  237. _mav_put_uint32_t(buf, 0, time_boot_ms);
  238. _mav_put_float(buf, 4, total_capacity);
  239. _mav_put_float(buf, 8, used_capacity);
  240. _mav_put_float(buf, 12, available_capacity);
  241. _mav_put_float(buf, 16, read_speed);
  242. _mav_put_float(buf, 20, write_speed);
  243. _mav_put_uint8_t(buf, 24, storage_id);
  244. _mav_put_uint8_t(buf, 25, storage_count);
  245. _mav_put_uint8_t(buf, 26, status);
  246. _mav_put_uint8_t(buf, 27, type);
  247. _mav_put_uint8_t(buf, 60, storage_usage);
  248. _mav_put_char_array(buf, 28, name, 32);
  249. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_STORAGE_INFORMATION, buf, MAVLINK_MSG_ID_STORAGE_INFORMATION_MIN_LEN, MAVLINK_MSG_ID_STORAGE_INFORMATION_LEN, MAVLINK_MSG_ID_STORAGE_INFORMATION_CRC);
  250. #else
  251. mavlink_storage_information_t packet;
  252. packet.time_boot_ms = time_boot_ms;
  253. packet.total_capacity = total_capacity;
  254. packet.used_capacity = used_capacity;
  255. packet.available_capacity = available_capacity;
  256. packet.read_speed = read_speed;
  257. packet.write_speed = write_speed;
  258. packet.storage_id = storage_id;
  259. packet.storage_count = storage_count;
  260. packet.status = status;
  261. packet.type = type;
  262. packet.storage_usage = storage_usage;
  263. mav_array_memcpy(packet.name, name, sizeof(char)*32);
  264. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_STORAGE_INFORMATION, (const char *)&packet, MAVLINK_MSG_ID_STORAGE_INFORMATION_MIN_LEN, MAVLINK_MSG_ID_STORAGE_INFORMATION_LEN, MAVLINK_MSG_ID_STORAGE_INFORMATION_CRC);
  265. #endif
  266. }
  267. /**
  268. * @brief Send a storage_information message
  269. * @param chan MAVLink channel to send the message
  270. * @param struct The MAVLink struct to serialize
  271. */
  272. static inline void mavlink_msg_storage_information_send_struct(mavlink_channel_t chan, const mavlink_storage_information_t* storage_information)
  273. {
  274. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  275. mavlink_msg_storage_information_send(chan, storage_information->time_boot_ms, storage_information->storage_id, storage_information->storage_count, storage_information->status, storage_information->total_capacity, storage_information->used_capacity, storage_information->available_capacity, storage_information->read_speed, storage_information->write_speed, storage_information->type, storage_information->name, storage_information->storage_usage);
  276. #else
  277. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_STORAGE_INFORMATION, (const char *)storage_information, MAVLINK_MSG_ID_STORAGE_INFORMATION_MIN_LEN, MAVLINK_MSG_ID_STORAGE_INFORMATION_LEN, MAVLINK_MSG_ID_STORAGE_INFORMATION_CRC);
  278. #endif
  279. }
  280. #if MAVLINK_MSG_ID_STORAGE_INFORMATION_LEN <= MAVLINK_MAX_PAYLOAD_LEN
  281. /*
  282. This variant of _send() can be used to save stack space by re-using
  283. memory from the receive buffer. The caller provides a
  284. mavlink_message_t which is the size of a full mavlink message. This
  285. is usually the receive buffer for the channel, and allows a reply to an
  286. incoming message with minimum stack space usage.
  287. */
  288. static inline void mavlink_msg_storage_information_send_buf(mavlink_message_t *msgbuf, mavlink_channel_t chan, uint32_t time_boot_ms, uint8_t storage_id, uint8_t storage_count, uint8_t status, float total_capacity, float used_capacity, float available_capacity, float read_speed, float write_speed, uint8_t type, const char *name, uint8_t storage_usage)
  289. {
  290. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  291. char *buf = (char *)msgbuf;
  292. _mav_put_uint32_t(buf, 0, time_boot_ms);
  293. _mav_put_float(buf, 4, total_capacity);
  294. _mav_put_float(buf, 8, used_capacity);
  295. _mav_put_float(buf, 12, available_capacity);
  296. _mav_put_float(buf, 16, read_speed);
  297. _mav_put_float(buf, 20, write_speed);
  298. _mav_put_uint8_t(buf, 24, storage_id);
  299. _mav_put_uint8_t(buf, 25, storage_count);
  300. _mav_put_uint8_t(buf, 26, status);
  301. _mav_put_uint8_t(buf, 27, type);
  302. _mav_put_uint8_t(buf, 60, storage_usage);
  303. _mav_put_char_array(buf, 28, name, 32);
  304. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_STORAGE_INFORMATION, buf, MAVLINK_MSG_ID_STORAGE_INFORMATION_MIN_LEN, MAVLINK_MSG_ID_STORAGE_INFORMATION_LEN, MAVLINK_MSG_ID_STORAGE_INFORMATION_CRC);
  305. #else
  306. mavlink_storage_information_t *packet = (mavlink_storage_information_t *)msgbuf;
  307. packet->time_boot_ms = time_boot_ms;
  308. packet->total_capacity = total_capacity;
  309. packet->used_capacity = used_capacity;
  310. packet->available_capacity = available_capacity;
  311. packet->read_speed = read_speed;
  312. packet->write_speed = write_speed;
  313. packet->storage_id = storage_id;
  314. packet->storage_count = storage_count;
  315. packet->status = status;
  316. packet->type = type;
  317. packet->storage_usage = storage_usage;
  318. mav_array_memcpy(packet->name, name, sizeof(char)*32);
  319. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_STORAGE_INFORMATION, (const char *)packet, MAVLINK_MSG_ID_STORAGE_INFORMATION_MIN_LEN, MAVLINK_MSG_ID_STORAGE_INFORMATION_LEN, MAVLINK_MSG_ID_STORAGE_INFORMATION_CRC);
  320. #endif
  321. }
  322. #endif
  323. #endif
  324. // MESSAGE STORAGE_INFORMATION UNPACKING
  325. /**
  326. * @brief Get field time_boot_ms from storage_information message
  327. *
  328. * @return [ms] Timestamp (time since system boot).
  329. */
  330. static inline uint32_t mavlink_msg_storage_information_get_time_boot_ms(const mavlink_message_t* msg)
  331. {
  332. return _MAV_RETURN_uint32_t(msg, 0);
  333. }
  334. /**
  335. * @brief Get field storage_id from storage_information message
  336. *
  337. * @return Storage ID (1 for first, 2 for second, etc.)
  338. */
  339. static inline uint8_t mavlink_msg_storage_information_get_storage_id(const mavlink_message_t* msg)
  340. {
  341. return _MAV_RETURN_uint8_t(msg, 24);
  342. }
  343. /**
  344. * @brief Get field storage_count from storage_information message
  345. *
  346. * @return Number of storage devices
  347. */
  348. static inline uint8_t mavlink_msg_storage_information_get_storage_count(const mavlink_message_t* msg)
  349. {
  350. return _MAV_RETURN_uint8_t(msg, 25);
  351. }
  352. /**
  353. * @brief Get field status from storage_information message
  354. *
  355. * @return Status of storage
  356. */
  357. static inline uint8_t mavlink_msg_storage_information_get_status(const mavlink_message_t* msg)
  358. {
  359. return _MAV_RETURN_uint8_t(msg, 26);
  360. }
  361. /**
  362. * @brief Get field total_capacity from storage_information message
  363. *
  364. * @return [MiB] Total capacity. If storage is not ready (STORAGE_STATUS_READY) value will be ignored.
  365. */
  366. static inline float mavlink_msg_storage_information_get_total_capacity(const mavlink_message_t* msg)
  367. {
  368. return _MAV_RETURN_float(msg, 4);
  369. }
  370. /**
  371. * @brief Get field used_capacity from storage_information message
  372. *
  373. * @return [MiB] Used capacity. If storage is not ready (STORAGE_STATUS_READY) value will be ignored.
  374. */
  375. static inline float mavlink_msg_storage_information_get_used_capacity(const mavlink_message_t* msg)
  376. {
  377. return _MAV_RETURN_float(msg, 8);
  378. }
  379. /**
  380. * @brief Get field available_capacity from storage_information message
  381. *
  382. * @return [MiB] Available storage capacity. If storage is not ready (STORAGE_STATUS_READY) value will be ignored.
  383. */
  384. static inline float mavlink_msg_storage_information_get_available_capacity(const mavlink_message_t* msg)
  385. {
  386. return _MAV_RETURN_float(msg, 12);
  387. }
  388. /**
  389. * @brief Get field read_speed from storage_information message
  390. *
  391. * @return [MiB/s] Read speed.
  392. */
  393. static inline float mavlink_msg_storage_information_get_read_speed(const mavlink_message_t* msg)
  394. {
  395. return _MAV_RETURN_float(msg, 16);
  396. }
  397. /**
  398. * @brief Get field write_speed from storage_information message
  399. *
  400. * @return [MiB/s] Write speed.
  401. */
  402. static inline float mavlink_msg_storage_information_get_write_speed(const mavlink_message_t* msg)
  403. {
  404. return _MAV_RETURN_float(msg, 20);
  405. }
  406. /**
  407. * @brief Get field type from storage_information message
  408. *
  409. * @return Type of storage
  410. */
  411. static inline uint8_t mavlink_msg_storage_information_get_type(const mavlink_message_t* msg)
  412. {
  413. return _MAV_RETURN_uint8_t(msg, 27);
  414. }
  415. /**
  416. * @brief Get field name from storage_information message
  417. *
  418. * @return Textual storage name to be used in UI (microSD 1, Internal Memory, etc.) This is a NULL terminated string. If it is exactly 32 characters long, add a terminating NULL. If this string is empty, the generic type is shown to the user.
  419. */
  420. static inline uint16_t mavlink_msg_storage_information_get_name(const mavlink_message_t* msg, char *name)
  421. {
  422. return _MAV_RETURN_char_array(msg, name, 32, 28);
  423. }
  424. /**
  425. * @brief Get field storage_usage from storage_information message
  426. *
  427. * @return Flags indicating whether this instance is preferred storage for photos, videos, etc.
  428. Note: Implementations should initially set the flags on the system-default storage id used for saving media (if possible/supported).
  429. This setting can then be overridden using MAV_CMD_SET_STORAGE_USAGE.
  430. If the media usage flags are not set, a GCS may assume storage ID 1 is the default storage for all media types.
  431. */
  432. static inline uint8_t mavlink_msg_storage_information_get_storage_usage(const mavlink_message_t* msg)
  433. {
  434. return _MAV_RETURN_uint8_t(msg, 60);
  435. }
  436. /**
  437. * @brief Decode a storage_information message into a struct
  438. *
  439. * @param msg The message to decode
  440. * @param storage_information C-struct to decode the message contents into
  441. */
  442. static inline void mavlink_msg_storage_information_decode(const mavlink_message_t* msg, mavlink_storage_information_t* storage_information)
  443. {
  444. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  445. storage_information->time_boot_ms = mavlink_msg_storage_information_get_time_boot_ms(msg);
  446. storage_information->total_capacity = mavlink_msg_storage_information_get_total_capacity(msg);
  447. storage_information->used_capacity = mavlink_msg_storage_information_get_used_capacity(msg);
  448. storage_information->available_capacity = mavlink_msg_storage_information_get_available_capacity(msg);
  449. storage_information->read_speed = mavlink_msg_storage_information_get_read_speed(msg);
  450. storage_information->write_speed = mavlink_msg_storage_information_get_write_speed(msg);
  451. storage_information->storage_id = mavlink_msg_storage_information_get_storage_id(msg);
  452. storage_information->storage_count = mavlink_msg_storage_information_get_storage_count(msg);
  453. storage_information->status = mavlink_msg_storage_information_get_status(msg);
  454. storage_information->type = mavlink_msg_storage_information_get_type(msg);
  455. mavlink_msg_storage_information_get_name(msg, storage_information->name);
  456. storage_information->storage_usage = mavlink_msg_storage_information_get_storage_usage(msg);
  457. #else
  458. uint8_t len = msg->len < MAVLINK_MSG_ID_STORAGE_INFORMATION_LEN? msg->len : MAVLINK_MSG_ID_STORAGE_INFORMATION_LEN;
  459. memset(storage_information, 0, MAVLINK_MSG_ID_STORAGE_INFORMATION_LEN);
  460. memcpy(storage_information, _MAV_PAYLOAD(msg), len);
  461. #endif
  462. }