mavlink_msg_param_ext_value.h 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363
  1. #pragma once
  2. // MESSAGE PARAM_EXT_VALUE PACKING
  3. #define MAVLINK_MSG_ID_PARAM_EXT_VALUE 322
  4. typedef struct __mavlink_param_ext_value_t {
  5. uint16_t param_count; /*< Total number of parameters*/
  6. uint16_t param_index; /*< Index of this parameter*/
  7. char param_id[16]; /*< Parameter id, terminated by NULL if the length is less than 16 human-readable chars and WITHOUT null termination (NULL) byte if the length is exactly 16 chars - applications have to provide 16+1 bytes storage if the ID is stored as string*/
  8. char param_value[128]; /*< Parameter value*/
  9. uint8_t param_type; /*< Parameter type.*/
  10. } mavlink_param_ext_value_t;
  11. #define MAVLINK_MSG_ID_PARAM_EXT_VALUE_LEN 149
  12. #define MAVLINK_MSG_ID_PARAM_EXT_VALUE_MIN_LEN 149
  13. #define MAVLINK_MSG_ID_322_LEN 149
  14. #define MAVLINK_MSG_ID_322_MIN_LEN 149
  15. #define MAVLINK_MSG_ID_PARAM_EXT_VALUE_CRC 243
  16. #define MAVLINK_MSG_ID_322_CRC 243
  17. #define MAVLINK_MSG_PARAM_EXT_VALUE_FIELD_PARAM_ID_LEN 16
  18. #define MAVLINK_MSG_PARAM_EXT_VALUE_FIELD_PARAM_VALUE_LEN 128
  19. #if MAVLINK_COMMAND_24BIT
  20. #define MAVLINK_MESSAGE_INFO_PARAM_EXT_VALUE { \
  21. 322, \
  22. "PARAM_EXT_VALUE", \
  23. 5, \
  24. { { "param_id", NULL, MAVLINK_TYPE_CHAR, 16, 4, offsetof(mavlink_param_ext_value_t, param_id) }, \
  25. { "param_value", NULL, MAVLINK_TYPE_CHAR, 128, 20, offsetof(mavlink_param_ext_value_t, param_value) }, \
  26. { "param_type", NULL, MAVLINK_TYPE_UINT8_T, 0, 148, offsetof(mavlink_param_ext_value_t, param_type) }, \
  27. { "param_count", NULL, MAVLINK_TYPE_UINT16_T, 0, 0, offsetof(mavlink_param_ext_value_t, param_count) }, \
  28. { "param_index", NULL, MAVLINK_TYPE_UINT16_T, 0, 2, offsetof(mavlink_param_ext_value_t, param_index) }, \
  29. } \
  30. }
  31. #else
  32. #define MAVLINK_MESSAGE_INFO_PARAM_EXT_VALUE { \
  33. "PARAM_EXT_VALUE", \
  34. 5, \
  35. { { "param_id", NULL, MAVLINK_TYPE_CHAR, 16, 4, offsetof(mavlink_param_ext_value_t, param_id) }, \
  36. { "param_value", NULL, MAVLINK_TYPE_CHAR, 128, 20, offsetof(mavlink_param_ext_value_t, param_value) }, \
  37. { "param_type", NULL, MAVLINK_TYPE_UINT8_T, 0, 148, offsetof(mavlink_param_ext_value_t, param_type) }, \
  38. { "param_count", NULL, MAVLINK_TYPE_UINT16_T, 0, 0, offsetof(mavlink_param_ext_value_t, param_count) }, \
  39. { "param_index", NULL, MAVLINK_TYPE_UINT16_T, 0, 2, offsetof(mavlink_param_ext_value_t, param_index) }, \
  40. } \
  41. }
  42. #endif
  43. /**
  44. * @brief Pack a param_ext_value message
  45. * @param system_id ID of this system
  46. * @param component_id ID of this component (e.g. 200 for IMU)
  47. * @param msg The MAVLink message to compress the data into
  48. *
  49. * @param param_id Parameter id, terminated by NULL if the length is less than 16 human-readable chars and WITHOUT null termination (NULL) byte if the length is exactly 16 chars - applications have to provide 16+1 bytes storage if the ID is stored as string
  50. * @param param_value Parameter value
  51. * @param param_type Parameter type.
  52. * @param param_count Total number of parameters
  53. * @param param_index Index of this parameter
  54. * @return length of the message in bytes (excluding serial stream start sign)
  55. */
  56. static inline uint16_t mavlink_msg_param_ext_value_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
  57. const char *param_id, const char *param_value, uint8_t param_type, uint16_t param_count, uint16_t param_index)
  58. {
  59. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  60. char buf[MAVLINK_MSG_ID_PARAM_EXT_VALUE_LEN];
  61. _mav_put_uint16_t(buf, 0, param_count);
  62. _mav_put_uint16_t(buf, 2, param_index);
  63. _mav_put_uint8_t(buf, 148, param_type);
  64. _mav_put_char_array(buf, 4, param_id, 16);
  65. _mav_put_char_array(buf, 20, param_value, 128);
  66. memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_PARAM_EXT_VALUE_LEN);
  67. #else
  68. mavlink_param_ext_value_t packet;
  69. packet.param_count = param_count;
  70. packet.param_index = param_index;
  71. packet.param_type = param_type;
  72. mav_array_memcpy(packet.param_id, param_id, sizeof(char)*16);
  73. mav_array_memcpy(packet.param_value, param_value, sizeof(char)*128);
  74. memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_PARAM_EXT_VALUE_LEN);
  75. #endif
  76. msg->msgid = MAVLINK_MSG_ID_PARAM_EXT_VALUE;
  77. return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_PARAM_EXT_VALUE_MIN_LEN, MAVLINK_MSG_ID_PARAM_EXT_VALUE_LEN, MAVLINK_MSG_ID_PARAM_EXT_VALUE_CRC);
  78. }
  79. /**
  80. * @brief Pack a param_ext_value message
  81. * @param system_id ID of this system
  82. * @param component_id ID of this component (e.g. 200 for IMU)
  83. * @param status MAVLink status structure
  84. * @param msg The MAVLink message to compress the data into
  85. *
  86. * @param param_id Parameter id, terminated by NULL if the length is less than 16 human-readable chars and WITHOUT null termination (NULL) byte if the length is exactly 16 chars - applications have to provide 16+1 bytes storage if the ID is stored as string
  87. * @param param_value Parameter value
  88. * @param param_type Parameter type.
  89. * @param param_count Total number of parameters
  90. * @param param_index Index of this parameter
  91. * @return length of the message in bytes (excluding serial stream start sign)
  92. */
  93. static inline uint16_t mavlink_msg_param_ext_value_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg,
  94. const char *param_id, const char *param_value, uint8_t param_type, uint16_t param_count, uint16_t param_index)
  95. {
  96. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  97. char buf[MAVLINK_MSG_ID_PARAM_EXT_VALUE_LEN];
  98. _mav_put_uint16_t(buf, 0, param_count);
  99. _mav_put_uint16_t(buf, 2, param_index);
  100. _mav_put_uint8_t(buf, 148, param_type);
  101. _mav_put_char_array(buf, 4, param_id, 16);
  102. _mav_put_char_array(buf, 20, param_value, 128);
  103. memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_PARAM_EXT_VALUE_LEN);
  104. #else
  105. mavlink_param_ext_value_t packet;
  106. packet.param_count = param_count;
  107. packet.param_index = param_index;
  108. packet.param_type = param_type;
  109. mav_array_memcpy(packet.param_id, param_id, sizeof(char)*16);
  110. mav_array_memcpy(packet.param_value, param_value, sizeof(char)*128);
  111. memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_PARAM_EXT_VALUE_LEN);
  112. #endif
  113. msg->msgid = MAVLINK_MSG_ID_PARAM_EXT_VALUE;
  114. #if MAVLINK_CRC_EXTRA
  115. return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_PARAM_EXT_VALUE_MIN_LEN, MAVLINK_MSG_ID_PARAM_EXT_VALUE_LEN, MAVLINK_MSG_ID_PARAM_EXT_VALUE_CRC);
  116. #else
  117. return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_PARAM_EXT_VALUE_MIN_LEN, MAVLINK_MSG_ID_PARAM_EXT_VALUE_LEN);
  118. #endif
  119. }
  120. /**
  121. * @brief Pack a param_ext_value message on a channel
  122. * @param system_id ID of this system
  123. * @param component_id ID of this component (e.g. 200 for IMU)
  124. * @param chan The MAVLink channel this message will be sent over
  125. * @param msg The MAVLink message to compress the data into
  126. * @param param_id Parameter id, terminated by NULL if the length is less than 16 human-readable chars and WITHOUT null termination (NULL) byte if the length is exactly 16 chars - applications have to provide 16+1 bytes storage if the ID is stored as string
  127. * @param param_value Parameter value
  128. * @param param_type Parameter type.
  129. * @param param_count Total number of parameters
  130. * @param param_index Index of this parameter
  131. * @return length of the message in bytes (excluding serial stream start sign)
  132. */
  133. static inline uint16_t mavlink_msg_param_ext_value_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
  134. mavlink_message_t* msg,
  135. const char *param_id,const char *param_value,uint8_t param_type,uint16_t param_count,uint16_t param_index)
  136. {
  137. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  138. char buf[MAVLINK_MSG_ID_PARAM_EXT_VALUE_LEN];
  139. _mav_put_uint16_t(buf, 0, param_count);
  140. _mav_put_uint16_t(buf, 2, param_index);
  141. _mav_put_uint8_t(buf, 148, param_type);
  142. _mav_put_char_array(buf, 4, param_id, 16);
  143. _mav_put_char_array(buf, 20, param_value, 128);
  144. memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_PARAM_EXT_VALUE_LEN);
  145. #else
  146. mavlink_param_ext_value_t packet;
  147. packet.param_count = param_count;
  148. packet.param_index = param_index;
  149. packet.param_type = param_type;
  150. mav_array_memcpy(packet.param_id, param_id, sizeof(char)*16);
  151. mav_array_memcpy(packet.param_value, param_value, sizeof(char)*128);
  152. memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_PARAM_EXT_VALUE_LEN);
  153. #endif
  154. msg->msgid = MAVLINK_MSG_ID_PARAM_EXT_VALUE;
  155. return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_PARAM_EXT_VALUE_MIN_LEN, MAVLINK_MSG_ID_PARAM_EXT_VALUE_LEN, MAVLINK_MSG_ID_PARAM_EXT_VALUE_CRC);
  156. }
  157. /**
  158. * @brief Encode a param_ext_value struct
  159. *
  160. * @param system_id ID of this system
  161. * @param component_id ID of this component (e.g. 200 for IMU)
  162. * @param msg The MAVLink message to compress the data into
  163. * @param param_ext_value C-struct to read the message contents from
  164. */
  165. static inline uint16_t mavlink_msg_param_ext_value_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_param_ext_value_t* param_ext_value)
  166. {
  167. return mavlink_msg_param_ext_value_pack(system_id, component_id, msg, param_ext_value->param_id, param_ext_value->param_value, param_ext_value->param_type, param_ext_value->param_count, param_ext_value->param_index);
  168. }
  169. /**
  170. * @brief Encode a param_ext_value struct on a channel
  171. *
  172. * @param system_id ID of this system
  173. * @param component_id ID of this component (e.g. 200 for IMU)
  174. * @param chan The MAVLink channel this message will be sent over
  175. * @param msg The MAVLink message to compress the data into
  176. * @param param_ext_value C-struct to read the message contents from
  177. */
  178. static inline uint16_t mavlink_msg_param_ext_value_encode_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, const mavlink_param_ext_value_t* param_ext_value)
  179. {
  180. return mavlink_msg_param_ext_value_pack_chan(system_id, component_id, chan, msg, param_ext_value->param_id, param_ext_value->param_value, param_ext_value->param_type, param_ext_value->param_count, param_ext_value->param_index);
  181. }
  182. /**
  183. * @brief Encode a param_ext_value struct with provided status structure
  184. *
  185. * @param system_id ID of this system
  186. * @param component_id ID of this component (e.g. 200 for IMU)
  187. * @param status MAVLink status structure
  188. * @param msg The MAVLink message to compress the data into
  189. * @param param_ext_value C-struct to read the message contents from
  190. */
  191. static inline uint16_t mavlink_msg_param_ext_value_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_param_ext_value_t* param_ext_value)
  192. {
  193. return mavlink_msg_param_ext_value_pack_status(system_id, component_id, _status, msg, param_ext_value->param_id, param_ext_value->param_value, param_ext_value->param_type, param_ext_value->param_count, param_ext_value->param_index);
  194. }
  195. /**
  196. * @brief Send a param_ext_value message
  197. * @param chan MAVLink channel to send the message
  198. *
  199. * @param param_id Parameter id, terminated by NULL if the length is less than 16 human-readable chars and WITHOUT null termination (NULL) byte if the length is exactly 16 chars - applications have to provide 16+1 bytes storage if the ID is stored as string
  200. * @param param_value Parameter value
  201. * @param param_type Parameter type.
  202. * @param param_count Total number of parameters
  203. * @param param_index Index of this parameter
  204. */
  205. #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
  206. static inline void mavlink_msg_param_ext_value_send(mavlink_channel_t chan, const char *param_id, const char *param_value, uint8_t param_type, uint16_t param_count, uint16_t param_index)
  207. {
  208. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  209. char buf[MAVLINK_MSG_ID_PARAM_EXT_VALUE_LEN];
  210. _mav_put_uint16_t(buf, 0, param_count);
  211. _mav_put_uint16_t(buf, 2, param_index);
  212. _mav_put_uint8_t(buf, 148, param_type);
  213. _mav_put_char_array(buf, 4, param_id, 16);
  214. _mav_put_char_array(buf, 20, param_value, 128);
  215. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_PARAM_EXT_VALUE, buf, MAVLINK_MSG_ID_PARAM_EXT_VALUE_MIN_LEN, MAVLINK_MSG_ID_PARAM_EXT_VALUE_LEN, MAVLINK_MSG_ID_PARAM_EXT_VALUE_CRC);
  216. #else
  217. mavlink_param_ext_value_t packet;
  218. packet.param_count = param_count;
  219. packet.param_index = param_index;
  220. packet.param_type = param_type;
  221. mav_array_memcpy(packet.param_id, param_id, sizeof(char)*16);
  222. mav_array_memcpy(packet.param_value, param_value, sizeof(char)*128);
  223. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_PARAM_EXT_VALUE, (const char *)&packet, MAVLINK_MSG_ID_PARAM_EXT_VALUE_MIN_LEN, MAVLINK_MSG_ID_PARAM_EXT_VALUE_LEN, MAVLINK_MSG_ID_PARAM_EXT_VALUE_CRC);
  224. #endif
  225. }
  226. /**
  227. * @brief Send a param_ext_value message
  228. * @param chan MAVLink channel to send the message
  229. * @param struct The MAVLink struct to serialize
  230. */
  231. static inline void mavlink_msg_param_ext_value_send_struct(mavlink_channel_t chan, const mavlink_param_ext_value_t* param_ext_value)
  232. {
  233. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  234. mavlink_msg_param_ext_value_send(chan, param_ext_value->param_id, param_ext_value->param_value, param_ext_value->param_type, param_ext_value->param_count, param_ext_value->param_index);
  235. #else
  236. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_PARAM_EXT_VALUE, (const char *)param_ext_value, MAVLINK_MSG_ID_PARAM_EXT_VALUE_MIN_LEN, MAVLINK_MSG_ID_PARAM_EXT_VALUE_LEN, MAVLINK_MSG_ID_PARAM_EXT_VALUE_CRC);
  237. #endif
  238. }
  239. #if MAVLINK_MSG_ID_PARAM_EXT_VALUE_LEN <= MAVLINK_MAX_PAYLOAD_LEN
  240. /*
  241. This variant of _send() can be used to save stack space by re-using
  242. memory from the receive buffer. The caller provides a
  243. mavlink_message_t which is the size of a full mavlink message. This
  244. is usually the receive buffer for the channel, and allows a reply to an
  245. incoming message with minimum stack space usage.
  246. */
  247. static inline void mavlink_msg_param_ext_value_send_buf(mavlink_message_t *msgbuf, mavlink_channel_t chan, const char *param_id, const char *param_value, uint8_t param_type, uint16_t param_count, uint16_t param_index)
  248. {
  249. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  250. char *buf = (char *)msgbuf;
  251. _mav_put_uint16_t(buf, 0, param_count);
  252. _mav_put_uint16_t(buf, 2, param_index);
  253. _mav_put_uint8_t(buf, 148, param_type);
  254. _mav_put_char_array(buf, 4, param_id, 16);
  255. _mav_put_char_array(buf, 20, param_value, 128);
  256. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_PARAM_EXT_VALUE, buf, MAVLINK_MSG_ID_PARAM_EXT_VALUE_MIN_LEN, MAVLINK_MSG_ID_PARAM_EXT_VALUE_LEN, MAVLINK_MSG_ID_PARAM_EXT_VALUE_CRC);
  257. #else
  258. mavlink_param_ext_value_t *packet = (mavlink_param_ext_value_t *)msgbuf;
  259. packet->param_count = param_count;
  260. packet->param_index = param_index;
  261. packet->param_type = param_type;
  262. mav_array_memcpy(packet->param_id, param_id, sizeof(char)*16);
  263. mav_array_memcpy(packet->param_value, param_value, sizeof(char)*128);
  264. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_PARAM_EXT_VALUE, (const char *)packet, MAVLINK_MSG_ID_PARAM_EXT_VALUE_MIN_LEN, MAVLINK_MSG_ID_PARAM_EXT_VALUE_LEN, MAVLINK_MSG_ID_PARAM_EXT_VALUE_CRC);
  265. #endif
  266. }
  267. #endif
  268. #endif
  269. // MESSAGE PARAM_EXT_VALUE UNPACKING
  270. /**
  271. * @brief Get field param_id from param_ext_value message
  272. *
  273. * @return Parameter id, terminated by NULL if the length is less than 16 human-readable chars and WITHOUT null termination (NULL) byte if the length is exactly 16 chars - applications have to provide 16+1 bytes storage if the ID is stored as string
  274. */
  275. static inline uint16_t mavlink_msg_param_ext_value_get_param_id(const mavlink_message_t* msg, char *param_id)
  276. {
  277. return _MAV_RETURN_char_array(msg, param_id, 16, 4);
  278. }
  279. /**
  280. * @brief Get field param_value from param_ext_value message
  281. *
  282. * @return Parameter value
  283. */
  284. static inline uint16_t mavlink_msg_param_ext_value_get_param_value(const mavlink_message_t* msg, char *param_value)
  285. {
  286. return _MAV_RETURN_char_array(msg, param_value, 128, 20);
  287. }
  288. /**
  289. * @brief Get field param_type from param_ext_value message
  290. *
  291. * @return Parameter type.
  292. */
  293. static inline uint8_t mavlink_msg_param_ext_value_get_param_type(const mavlink_message_t* msg)
  294. {
  295. return _MAV_RETURN_uint8_t(msg, 148);
  296. }
  297. /**
  298. * @brief Get field param_count from param_ext_value message
  299. *
  300. * @return Total number of parameters
  301. */
  302. static inline uint16_t mavlink_msg_param_ext_value_get_param_count(const mavlink_message_t* msg)
  303. {
  304. return _MAV_RETURN_uint16_t(msg, 0);
  305. }
  306. /**
  307. * @brief Get field param_index from param_ext_value message
  308. *
  309. * @return Index of this parameter
  310. */
  311. static inline uint16_t mavlink_msg_param_ext_value_get_param_index(const mavlink_message_t* msg)
  312. {
  313. return _MAV_RETURN_uint16_t(msg, 2);
  314. }
  315. /**
  316. * @brief Decode a param_ext_value message into a struct
  317. *
  318. * @param msg The message to decode
  319. * @param param_ext_value C-struct to decode the message contents into
  320. */
  321. static inline void mavlink_msg_param_ext_value_decode(const mavlink_message_t* msg, mavlink_param_ext_value_t* param_ext_value)
  322. {
  323. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  324. param_ext_value->param_count = mavlink_msg_param_ext_value_get_param_count(msg);
  325. param_ext_value->param_index = mavlink_msg_param_ext_value_get_param_index(msg);
  326. mavlink_msg_param_ext_value_get_param_id(msg, param_ext_value->param_id);
  327. mavlink_msg_param_ext_value_get_param_value(msg, param_ext_value->param_value);
  328. param_ext_value->param_type = mavlink_msg_param_ext_value_get_param_type(msg);
  329. #else
  330. uint8_t len = msg->len < MAVLINK_MSG_ID_PARAM_EXT_VALUE_LEN? msg->len : MAVLINK_MSG_ID_PARAM_EXT_VALUE_LEN;
  331. memset(param_ext_value, 0, MAVLINK_MSG_ID_PARAM_EXT_VALUE_LEN);
  332. memcpy(param_ext_value, _MAV_PAYLOAD(msg), len);
  333. #endif
  334. }