mavlink_msg_storage_information.h 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576
  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
  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 time_boot_ms [ms] Timestamp (time since system boot).
  134. * @param storage_id Storage ID (1 for first, 2 for second, etc.)
  135. * @param storage_count Number of storage devices
  136. * @param status Status of storage
  137. * @param total_capacity [MiB] Total capacity. If storage is not ready (STORAGE_STATUS_READY) value will be ignored.
  138. * @param used_capacity [MiB] Used capacity. If storage is not ready (STORAGE_STATUS_READY) value will be ignored.
  139. * @param available_capacity [MiB] Available storage capacity. If storage is not ready (STORAGE_STATUS_READY) value will be ignored.
  140. * @param read_speed [MiB/s] Read speed.
  141. * @param write_speed [MiB/s] Write speed.
  142. * @param type Type of storage
  143. * @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.
  144. * @param storage_usage Flags indicating whether this instance is preferred storage for photos, videos, etc.
  145. Note: Implementations should initially set the flags on the system-default storage id used for saving media (if possible/supported).
  146. This setting can then be overridden using MAV_CMD_SET_STORAGE_USAGE.
  147. If the media usage flags are not set, a GCS may assume storage ID 1 is the default storage for all media types.
  148. * @return length of the message in bytes (excluding serial stream start sign)
  149. */
  150. static inline uint16_t mavlink_msg_storage_information_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, 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. #if MAVLINK_CRC_EXTRA
  186. return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_STORAGE_INFORMATION_MIN_LEN, MAVLINK_MSG_ID_STORAGE_INFORMATION_LEN, MAVLINK_MSG_ID_STORAGE_INFORMATION_CRC);
  187. #else
  188. return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_STORAGE_INFORMATION_MIN_LEN, MAVLINK_MSG_ID_STORAGE_INFORMATION_LEN);
  189. #endif
  190. }
  191. /**
  192. * @brief Pack a storage_information 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 time_boot_ms [ms] Timestamp (time since system boot).
  198. * @param storage_id Storage ID (1 for first, 2 for second, etc.)
  199. * @param storage_count Number of storage devices
  200. * @param status Status of storage
  201. * @param total_capacity [MiB] Total capacity. If storage is not ready (STORAGE_STATUS_READY) value will be ignored.
  202. * @param used_capacity [MiB] Used capacity. If storage is not ready (STORAGE_STATUS_READY) value will be ignored.
  203. * @param available_capacity [MiB] Available storage capacity. If storage is not ready (STORAGE_STATUS_READY) value will be ignored.
  204. * @param read_speed [MiB/s] Read speed.
  205. * @param write_speed [MiB/s] Write speed.
  206. * @param type Type of storage
  207. * @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.
  208. * @param storage_usage Flags indicating whether this instance is preferred storage for photos, videos, etc.
  209. Note: Implementations should initially set the flags on the system-default storage id used for saving media (if possible/supported).
  210. This setting can then be overridden using MAV_CMD_SET_STORAGE_USAGE.
  211. If the media usage flags are not set, a GCS may assume storage ID 1 is the default storage for all media types.
  212. * @return length of the message in bytes (excluding serial stream start sign)
  213. */
  214. static inline uint16_t mavlink_msg_storage_information_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
  215. mavlink_message_t* msg,
  216. 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)
  217. {
  218. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  219. char buf[MAVLINK_MSG_ID_STORAGE_INFORMATION_LEN];
  220. _mav_put_uint32_t(buf, 0, time_boot_ms);
  221. _mav_put_float(buf, 4, total_capacity);
  222. _mav_put_float(buf, 8, used_capacity);
  223. _mav_put_float(buf, 12, available_capacity);
  224. _mav_put_float(buf, 16, read_speed);
  225. _mav_put_float(buf, 20, write_speed);
  226. _mav_put_uint8_t(buf, 24, storage_id);
  227. _mav_put_uint8_t(buf, 25, storage_count);
  228. _mav_put_uint8_t(buf, 26, status);
  229. _mav_put_uint8_t(buf, 27, type);
  230. _mav_put_uint8_t(buf, 60, storage_usage);
  231. _mav_put_char_array(buf, 28, name, 32);
  232. memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_STORAGE_INFORMATION_LEN);
  233. #else
  234. mavlink_storage_information_t packet;
  235. packet.time_boot_ms = time_boot_ms;
  236. packet.total_capacity = total_capacity;
  237. packet.used_capacity = used_capacity;
  238. packet.available_capacity = available_capacity;
  239. packet.read_speed = read_speed;
  240. packet.write_speed = write_speed;
  241. packet.storage_id = storage_id;
  242. packet.storage_count = storage_count;
  243. packet.status = status;
  244. packet.type = type;
  245. packet.storage_usage = storage_usage;
  246. mav_array_memcpy(packet.name, name, sizeof(char)*32);
  247. memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_STORAGE_INFORMATION_LEN);
  248. #endif
  249. msg->msgid = MAVLINK_MSG_ID_STORAGE_INFORMATION;
  250. 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);
  251. }
  252. /**
  253. * @brief Encode a storage_information 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 storage_information C-struct to read the message contents from
  259. */
  260. 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)
  261. {
  262. 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);
  263. }
  264. /**
  265. * @brief Encode a storage_information 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 storage_information C-struct to read the message contents from
  272. */
  273. 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)
  274. {
  275. 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);
  276. }
  277. /**
  278. * @brief Encode a storage_information 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 storage_information C-struct to read the message contents from
  285. */
  286. static inline uint16_t mavlink_msg_storage_information_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_storage_information_t* storage_information)
  287. {
  288. return mavlink_msg_storage_information_pack_status(system_id, component_id, _status, 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);
  289. }
  290. /**
  291. * @brief Send a storage_information message
  292. * @param chan MAVLink channel to send the message
  293. *
  294. * @param time_boot_ms [ms] Timestamp (time since system boot).
  295. * @param storage_id Storage ID (1 for first, 2 for second, etc.)
  296. * @param storage_count Number of storage devices
  297. * @param status Status of storage
  298. * @param total_capacity [MiB] Total capacity. If storage is not ready (STORAGE_STATUS_READY) value will be ignored.
  299. * @param used_capacity [MiB] Used capacity. If storage is not ready (STORAGE_STATUS_READY) value will be ignored.
  300. * @param available_capacity [MiB] Available storage capacity. If storage is not ready (STORAGE_STATUS_READY) value will be ignored.
  301. * @param read_speed [MiB/s] Read speed.
  302. * @param write_speed [MiB/s] Write speed.
  303. * @param type Type of storage
  304. * @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.
  305. * @param storage_usage Flags indicating whether this instance is preferred storage for photos, videos, etc.
  306. Note: Implementations should initially set the flags on the system-default storage id used for saving media (if possible/supported).
  307. This setting can then be overridden using MAV_CMD_SET_STORAGE_USAGE.
  308. If the media usage flags are not set, a GCS may assume storage ID 1 is the default storage for all media types.
  309. */
  310. #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
  311. 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)
  312. {
  313. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  314. char buf[MAVLINK_MSG_ID_STORAGE_INFORMATION_LEN];
  315. _mav_put_uint32_t(buf, 0, time_boot_ms);
  316. _mav_put_float(buf, 4, total_capacity);
  317. _mav_put_float(buf, 8, used_capacity);
  318. _mav_put_float(buf, 12, available_capacity);
  319. _mav_put_float(buf, 16, read_speed);
  320. _mav_put_float(buf, 20, write_speed);
  321. _mav_put_uint8_t(buf, 24, storage_id);
  322. _mav_put_uint8_t(buf, 25, storage_count);
  323. _mav_put_uint8_t(buf, 26, status);
  324. _mav_put_uint8_t(buf, 27, type);
  325. _mav_put_uint8_t(buf, 60, storage_usage);
  326. _mav_put_char_array(buf, 28, name, 32);
  327. _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);
  328. #else
  329. mavlink_storage_information_t packet;
  330. packet.time_boot_ms = time_boot_ms;
  331. packet.total_capacity = total_capacity;
  332. packet.used_capacity = used_capacity;
  333. packet.available_capacity = available_capacity;
  334. packet.read_speed = read_speed;
  335. packet.write_speed = write_speed;
  336. packet.storage_id = storage_id;
  337. packet.storage_count = storage_count;
  338. packet.status = status;
  339. packet.type = type;
  340. packet.storage_usage = storage_usage;
  341. mav_array_memcpy(packet.name, name, sizeof(char)*32);
  342. _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);
  343. #endif
  344. }
  345. /**
  346. * @brief Send a storage_information 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_storage_information_send_struct(mavlink_channel_t chan, const mavlink_storage_information_t* storage_information)
  351. {
  352. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  353. 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);
  354. #else
  355. _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);
  356. #endif
  357. }
  358. #if MAVLINK_MSG_ID_STORAGE_INFORMATION_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_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)
  367. {
  368. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  369. char *buf = (char *)msgbuf;
  370. _mav_put_uint32_t(buf, 0, time_boot_ms);
  371. _mav_put_float(buf, 4, total_capacity);
  372. _mav_put_float(buf, 8, used_capacity);
  373. _mav_put_float(buf, 12, available_capacity);
  374. _mav_put_float(buf, 16, read_speed);
  375. _mav_put_float(buf, 20, write_speed);
  376. _mav_put_uint8_t(buf, 24, storage_id);
  377. _mav_put_uint8_t(buf, 25, storage_count);
  378. _mav_put_uint8_t(buf, 26, status);
  379. _mav_put_uint8_t(buf, 27, type);
  380. _mav_put_uint8_t(buf, 60, storage_usage);
  381. _mav_put_char_array(buf, 28, name, 32);
  382. _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);
  383. #else
  384. mavlink_storage_information_t *packet = (mavlink_storage_information_t *)msgbuf;
  385. packet->time_boot_ms = time_boot_ms;
  386. packet->total_capacity = total_capacity;
  387. packet->used_capacity = used_capacity;
  388. packet->available_capacity = available_capacity;
  389. packet->read_speed = read_speed;
  390. packet->write_speed = write_speed;
  391. packet->storage_id = storage_id;
  392. packet->storage_count = storage_count;
  393. packet->status = status;
  394. packet->type = type;
  395. packet->storage_usage = storage_usage;
  396. mav_array_memcpy(packet->name, name, sizeof(char)*32);
  397. _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);
  398. #endif
  399. }
  400. #endif
  401. #endif
  402. // MESSAGE STORAGE_INFORMATION UNPACKING
  403. /**
  404. * @brief Get field time_boot_ms from storage_information message
  405. *
  406. * @return [ms] Timestamp (time since system boot).
  407. */
  408. static inline uint32_t mavlink_msg_storage_information_get_time_boot_ms(const mavlink_message_t* msg)
  409. {
  410. return _MAV_RETURN_uint32_t(msg, 0);
  411. }
  412. /**
  413. * @brief Get field storage_id from storage_information message
  414. *
  415. * @return Storage ID (1 for first, 2 for second, etc.)
  416. */
  417. static inline uint8_t mavlink_msg_storage_information_get_storage_id(const mavlink_message_t* msg)
  418. {
  419. return _MAV_RETURN_uint8_t(msg, 24);
  420. }
  421. /**
  422. * @brief Get field storage_count from storage_information message
  423. *
  424. * @return Number of storage devices
  425. */
  426. static inline uint8_t mavlink_msg_storage_information_get_storage_count(const mavlink_message_t* msg)
  427. {
  428. return _MAV_RETURN_uint8_t(msg, 25);
  429. }
  430. /**
  431. * @brief Get field status from storage_information message
  432. *
  433. * @return Status of storage
  434. */
  435. static inline uint8_t mavlink_msg_storage_information_get_status(const mavlink_message_t* msg)
  436. {
  437. return _MAV_RETURN_uint8_t(msg, 26);
  438. }
  439. /**
  440. * @brief Get field total_capacity from storage_information message
  441. *
  442. * @return [MiB] Total capacity. If storage is not ready (STORAGE_STATUS_READY) value will be ignored.
  443. */
  444. static inline float mavlink_msg_storage_information_get_total_capacity(const mavlink_message_t* msg)
  445. {
  446. return _MAV_RETURN_float(msg, 4);
  447. }
  448. /**
  449. * @brief Get field used_capacity from storage_information message
  450. *
  451. * @return [MiB] Used capacity. If storage is not ready (STORAGE_STATUS_READY) value will be ignored.
  452. */
  453. static inline float mavlink_msg_storage_information_get_used_capacity(const mavlink_message_t* msg)
  454. {
  455. return _MAV_RETURN_float(msg, 8);
  456. }
  457. /**
  458. * @brief Get field available_capacity from storage_information message
  459. *
  460. * @return [MiB] Available storage capacity. If storage is not ready (STORAGE_STATUS_READY) value will be ignored.
  461. */
  462. static inline float mavlink_msg_storage_information_get_available_capacity(const mavlink_message_t* msg)
  463. {
  464. return _MAV_RETURN_float(msg, 12);
  465. }
  466. /**
  467. * @brief Get field read_speed from storage_information message
  468. *
  469. * @return [MiB/s] Read speed.
  470. */
  471. static inline float mavlink_msg_storage_information_get_read_speed(const mavlink_message_t* msg)
  472. {
  473. return _MAV_RETURN_float(msg, 16);
  474. }
  475. /**
  476. * @brief Get field write_speed from storage_information message
  477. *
  478. * @return [MiB/s] Write speed.
  479. */
  480. static inline float mavlink_msg_storage_information_get_write_speed(const mavlink_message_t* msg)
  481. {
  482. return _MAV_RETURN_float(msg, 20);
  483. }
  484. /**
  485. * @brief Get field type from storage_information message
  486. *
  487. * @return Type of storage
  488. */
  489. static inline uint8_t mavlink_msg_storage_information_get_type(const mavlink_message_t* msg)
  490. {
  491. return _MAV_RETURN_uint8_t(msg, 27);
  492. }
  493. /**
  494. * @brief Get field name from storage_information message
  495. *
  496. * @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.
  497. */
  498. static inline uint16_t mavlink_msg_storage_information_get_name(const mavlink_message_t* msg, char *name)
  499. {
  500. return _MAV_RETURN_char_array(msg, name, 32, 28);
  501. }
  502. /**
  503. * @brief Get field storage_usage from storage_information message
  504. *
  505. * @return Flags indicating whether this instance is preferred storage for photos, videos, etc.
  506. Note: Implementations should initially set the flags on the system-default storage id used for saving media (if possible/supported).
  507. This setting can then be overridden using MAV_CMD_SET_STORAGE_USAGE.
  508. If the media usage flags are not set, a GCS may assume storage ID 1 is the default storage for all media types.
  509. */
  510. static inline uint8_t mavlink_msg_storage_information_get_storage_usage(const mavlink_message_t* msg)
  511. {
  512. return _MAV_RETURN_uint8_t(msg, 60);
  513. }
  514. /**
  515. * @brief Decode a storage_information message into a struct
  516. *
  517. * @param msg The message to decode
  518. * @param storage_information C-struct to decode the message contents into
  519. */
  520. static inline void mavlink_msg_storage_information_decode(const mavlink_message_t* msg, mavlink_storage_information_t* storage_information)
  521. {
  522. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  523. storage_information->time_boot_ms = mavlink_msg_storage_information_get_time_boot_ms(msg);
  524. storage_information->total_capacity = mavlink_msg_storage_information_get_total_capacity(msg);
  525. storage_information->used_capacity = mavlink_msg_storage_information_get_used_capacity(msg);
  526. storage_information->available_capacity = mavlink_msg_storage_information_get_available_capacity(msg);
  527. storage_information->read_speed = mavlink_msg_storage_information_get_read_speed(msg);
  528. storage_information->write_speed = mavlink_msg_storage_information_get_write_speed(msg);
  529. storage_information->storage_id = mavlink_msg_storage_information_get_storage_id(msg);
  530. storage_information->storage_count = mavlink_msg_storage_information_get_storage_count(msg);
  531. storage_information->status = mavlink_msg_storage_information_get_status(msg);
  532. storage_information->type = mavlink_msg_storage_information_get_type(msg);
  533. mavlink_msg_storage_information_get_name(msg, storage_information->name);
  534. storage_information->storage_usage = mavlink_msg_storage_information_get_storage_usage(msg);
  535. #else
  536. uint8_t len = msg->len < MAVLINK_MSG_ID_STORAGE_INFORMATION_LEN? msg->len : MAVLINK_MSG_ID_STORAGE_INFORMATION_LEN;
  537. memset(storage_information, 0, MAVLINK_MSG_ID_STORAGE_INFORMATION_LEN);
  538. memcpy(storage_information, _MAV_PAYLOAD(msg), len);
  539. #endif
  540. }