/Modules/MAVLink/common/mavlink_msg_param_request_read.h

https://gitlab.com/krucios/Astraeus_FW · C Header · 279 lines · 165 code · 24 blank · 90 comment · 6 complexity · afc7c1bcb8f1b8d49e6f05707b3f940c MD5 · raw file

  1. // MESSAGE PARAM_REQUEST_READ PACKING
  2. #define MAVLINK_MSG_ID_PARAM_REQUEST_READ 20
  3. MAVPACKED(
  4. typedef struct __mavlink_param_request_read_t {
  5. int16_t param_index; /*< Parameter index. Send -1 to use the param ID field as identifier (else the param id will be ignored)*/
  6. uint8_t target_system; /*< System ID*/
  7. uint8_t target_component; /*< Component ID*/
  8. char param_id[16]; /*< Onboard 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*/
  9. }) mavlink_param_request_read_t;
  10. #define MAVLINK_MSG_ID_PARAM_REQUEST_READ_LEN 20
  11. #define MAVLINK_MSG_ID_PARAM_REQUEST_READ_MIN_LEN 20
  12. #define MAVLINK_MSG_ID_20_LEN 20
  13. #define MAVLINK_MSG_ID_20_MIN_LEN 20
  14. #define MAVLINK_MSG_ID_PARAM_REQUEST_READ_CRC 214
  15. #define MAVLINK_MSG_ID_20_CRC 214
  16. #define MAVLINK_MSG_PARAM_REQUEST_READ_FIELD_PARAM_ID_LEN 16
  17. #if MAVLINK_COMMAND_24BIT
  18. #define MAVLINK_MESSAGE_INFO_PARAM_REQUEST_READ { \
  19. 20, \
  20. "PARAM_REQUEST_READ", \
  21. 4, \
  22. { { "param_index", NULL, MAVLINK_TYPE_INT16_T, 0, 0, offsetof(mavlink_param_request_read_t, param_index) }, \
  23. { "target_system", NULL, MAVLINK_TYPE_UINT8_T, 0, 2, offsetof(mavlink_param_request_read_t, target_system) }, \
  24. { "target_component", NULL, MAVLINK_TYPE_UINT8_T, 0, 3, offsetof(mavlink_param_request_read_t, target_component) }, \
  25. { "param_id", NULL, MAVLINK_TYPE_CHAR, 16, 4, offsetof(mavlink_param_request_read_t, param_id) }, \
  26. } \
  27. }
  28. #else
  29. #define MAVLINK_MESSAGE_INFO_PARAM_REQUEST_READ { \
  30. "PARAM_REQUEST_READ", \
  31. 4, \
  32. { { "param_index", NULL, MAVLINK_TYPE_INT16_T, 0, 0, offsetof(mavlink_param_request_read_t, param_index) }, \
  33. { "target_system", NULL, MAVLINK_TYPE_UINT8_T, 0, 2, offsetof(mavlink_param_request_read_t, target_system) }, \
  34. { "target_component", NULL, MAVLINK_TYPE_UINT8_T, 0, 3, offsetof(mavlink_param_request_read_t, target_component) }, \
  35. { "param_id", NULL, MAVLINK_TYPE_CHAR, 16, 4, offsetof(mavlink_param_request_read_t, param_id) }, \
  36. } \
  37. }
  38. #endif
  39. /**
  40. * @brief Pack a param_request_read message
  41. * @param system_id ID of this system
  42. * @param component_id ID of this component (e.g. 200 for IMU)
  43. * @param msg The MAVLink message to compress the data into
  44. *
  45. * @param target_system System ID
  46. * @param target_component Component ID
  47. * @param param_id Onboard 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
  48. * @param param_index Parameter index. Send -1 to use the param ID field as identifier (else the param id will be ignored)
  49. * @return length of the message in bytes (excluding serial stream start sign)
  50. */
  51. static inline uint16_t mavlink_msg_param_request_read_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
  52. uint8_t target_system, uint8_t target_component, const char *param_id, int16_t param_index)
  53. {
  54. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  55. char buf[MAVLINK_MSG_ID_PARAM_REQUEST_READ_LEN];
  56. _mav_put_int16_t(buf, 0, param_index);
  57. _mav_put_uint8_t(buf, 2, target_system);
  58. _mav_put_uint8_t(buf, 3, target_component);
  59. _mav_put_char_array(buf, 4, param_id, 16);
  60. memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_PARAM_REQUEST_READ_LEN);
  61. #else
  62. mavlink_param_request_read_t packet;
  63. packet.param_index = param_index;
  64. packet.target_system = target_system;
  65. packet.target_component = target_component;
  66. mav_array_memcpy(packet.param_id, param_id, sizeof(char)*16);
  67. memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_PARAM_REQUEST_READ_LEN);
  68. #endif
  69. msg->msgid = MAVLINK_MSG_ID_PARAM_REQUEST_READ;
  70. return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_PARAM_REQUEST_READ_MIN_LEN, MAVLINK_MSG_ID_PARAM_REQUEST_READ_LEN, MAVLINK_MSG_ID_PARAM_REQUEST_READ_CRC);
  71. }
  72. /**
  73. * @brief Pack a param_request_read message on a channel
  74. * @param system_id ID of this system
  75. * @param component_id ID of this component (e.g. 200 for IMU)
  76. * @param chan The MAVLink channel this message will be sent over
  77. * @param msg The MAVLink message to compress the data into
  78. * @param target_system System ID
  79. * @param target_component Component ID
  80. * @param param_id Onboard 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
  81. * @param param_index Parameter index. Send -1 to use the param ID field as identifier (else the param id will be ignored)
  82. * @return length of the message in bytes (excluding serial stream start sign)
  83. */
  84. static inline uint16_t mavlink_msg_param_request_read_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
  85. mavlink_message_t* msg,
  86. uint8_t target_system,uint8_t target_component,const char *param_id,int16_t param_index)
  87. {
  88. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  89. char buf[MAVLINK_MSG_ID_PARAM_REQUEST_READ_LEN];
  90. _mav_put_int16_t(buf, 0, param_index);
  91. _mav_put_uint8_t(buf, 2, target_system);
  92. _mav_put_uint8_t(buf, 3, target_component);
  93. _mav_put_char_array(buf, 4, param_id, 16);
  94. memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_PARAM_REQUEST_READ_LEN);
  95. #else
  96. mavlink_param_request_read_t packet;
  97. packet.param_index = param_index;
  98. packet.target_system = target_system;
  99. packet.target_component = target_component;
  100. mav_array_memcpy(packet.param_id, param_id, sizeof(char)*16);
  101. memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_PARAM_REQUEST_READ_LEN);
  102. #endif
  103. msg->msgid = MAVLINK_MSG_ID_PARAM_REQUEST_READ;
  104. return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_PARAM_REQUEST_READ_MIN_LEN, MAVLINK_MSG_ID_PARAM_REQUEST_READ_LEN, MAVLINK_MSG_ID_PARAM_REQUEST_READ_CRC);
  105. }
  106. /**
  107. * @brief Encode a param_request_read struct
  108. *
  109. * @param system_id ID of this system
  110. * @param component_id ID of this component (e.g. 200 for IMU)
  111. * @param msg The MAVLink message to compress the data into
  112. * @param param_request_read C-struct to read the message contents from
  113. */
  114. static inline uint16_t mavlink_msg_param_request_read_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_param_request_read_t* param_request_read)
  115. {
  116. return mavlink_msg_param_request_read_pack(system_id, component_id, msg, param_request_read->target_system, param_request_read->target_component, param_request_read->param_id, param_request_read->param_index);
  117. }
  118. /**
  119. * @brief Encode a param_request_read struct on a channel
  120. *
  121. * @param system_id ID of this system
  122. * @param component_id ID of this component (e.g. 200 for IMU)
  123. * @param chan The MAVLink channel this message will be sent over
  124. * @param msg The MAVLink message to compress the data into
  125. * @param param_request_read C-struct to read the message contents from
  126. */
  127. static inline uint16_t mavlink_msg_param_request_read_encode_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, const mavlink_param_request_read_t* param_request_read)
  128. {
  129. return mavlink_msg_param_request_read_pack_chan(system_id, component_id, chan, msg, param_request_read->target_system, param_request_read->target_component, param_request_read->param_id, param_request_read->param_index);
  130. }
  131. /**
  132. * @brief Send a param_request_read message
  133. * @param chan MAVLink channel to send the message
  134. *
  135. * @param target_system System ID
  136. * @param target_component Component ID
  137. * @param param_id Onboard 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
  138. * @param param_index Parameter index. Send -1 to use the param ID field as identifier (else the param id will be ignored)
  139. */
  140. #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
  141. static inline void mavlink_msg_param_request_read_send(mavlink_channel_t chan, uint8_t target_system, uint8_t target_component, const char *param_id, int16_t param_index)
  142. {
  143. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  144. char buf[MAVLINK_MSG_ID_PARAM_REQUEST_READ_LEN];
  145. _mav_put_int16_t(buf, 0, param_index);
  146. _mav_put_uint8_t(buf, 2, target_system);
  147. _mav_put_uint8_t(buf, 3, target_component);
  148. _mav_put_char_array(buf, 4, param_id, 16);
  149. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_PARAM_REQUEST_READ, buf, MAVLINK_MSG_ID_PARAM_REQUEST_READ_MIN_LEN, MAVLINK_MSG_ID_PARAM_REQUEST_READ_LEN, MAVLINK_MSG_ID_PARAM_REQUEST_READ_CRC);
  150. #else
  151. mavlink_param_request_read_t packet;
  152. packet.param_index = param_index;
  153. packet.target_system = target_system;
  154. packet.target_component = target_component;
  155. mav_array_memcpy(packet.param_id, param_id, sizeof(char)*16);
  156. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_PARAM_REQUEST_READ, (const char *)&packet, MAVLINK_MSG_ID_PARAM_REQUEST_READ_MIN_LEN, MAVLINK_MSG_ID_PARAM_REQUEST_READ_LEN, MAVLINK_MSG_ID_PARAM_REQUEST_READ_CRC);
  157. #endif
  158. }
  159. /**
  160. * @brief Send a param_request_read message
  161. * @param chan MAVLink channel to send the message
  162. * @param struct The MAVLink struct to serialize
  163. */
  164. static inline void mavlink_msg_param_request_read_send_struct(mavlink_channel_t chan, const mavlink_param_request_read_t* param_request_read)
  165. {
  166. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  167. mavlink_msg_param_request_read_send(chan, param_request_read->target_system, param_request_read->target_component, param_request_read->param_id, param_request_read->param_index);
  168. #else
  169. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_PARAM_REQUEST_READ, (const char *)param_request_read, MAVLINK_MSG_ID_PARAM_REQUEST_READ_MIN_LEN, MAVLINK_MSG_ID_PARAM_REQUEST_READ_LEN, MAVLINK_MSG_ID_PARAM_REQUEST_READ_CRC);
  170. #endif
  171. }
  172. #if MAVLINK_MSG_ID_PARAM_REQUEST_READ_LEN <= MAVLINK_MAX_PAYLOAD_LEN
  173. /*
  174. This varient of _send() can be used to save stack space by re-using
  175. memory from the receive buffer. The caller provides a
  176. mavlink_message_t which is the size of a full mavlink message. This
  177. is usually the receive buffer for the channel, and allows a reply to an
  178. incoming message with minimum stack space usage.
  179. */
  180. static inline void mavlink_msg_param_request_read_send_buf(mavlink_message_t *msgbuf, mavlink_channel_t chan, uint8_t target_system, uint8_t target_component, const char *param_id, int16_t param_index)
  181. {
  182. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  183. char *buf = (char *)msgbuf;
  184. _mav_put_int16_t(buf, 0, param_index);
  185. _mav_put_uint8_t(buf, 2, target_system);
  186. _mav_put_uint8_t(buf, 3, target_component);
  187. _mav_put_char_array(buf, 4, param_id, 16);
  188. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_PARAM_REQUEST_READ, buf, MAVLINK_MSG_ID_PARAM_REQUEST_READ_MIN_LEN, MAVLINK_MSG_ID_PARAM_REQUEST_READ_LEN, MAVLINK_MSG_ID_PARAM_REQUEST_READ_CRC);
  189. #else
  190. mavlink_param_request_read_t *packet = (mavlink_param_request_read_t *)msgbuf;
  191. packet->param_index = param_index;
  192. packet->target_system = target_system;
  193. packet->target_component = target_component;
  194. mav_array_memcpy(packet->param_id, param_id, sizeof(char)*16);
  195. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_PARAM_REQUEST_READ, (const char *)packet, MAVLINK_MSG_ID_PARAM_REQUEST_READ_MIN_LEN, MAVLINK_MSG_ID_PARAM_REQUEST_READ_LEN, MAVLINK_MSG_ID_PARAM_REQUEST_READ_CRC);
  196. #endif
  197. }
  198. #endif
  199. #endif
  200. // MESSAGE PARAM_REQUEST_READ UNPACKING
  201. /**
  202. * @brief Get field target_system from param_request_read message
  203. *
  204. * @return System ID
  205. */
  206. static inline uint8_t mavlink_msg_param_request_read_get_target_system(const mavlink_message_t* msg)
  207. {
  208. return _MAV_RETURN_uint8_t(msg, 2);
  209. }
  210. /**
  211. * @brief Get field target_component from param_request_read message
  212. *
  213. * @return Component ID
  214. */
  215. static inline uint8_t mavlink_msg_param_request_read_get_target_component(const mavlink_message_t* msg)
  216. {
  217. return _MAV_RETURN_uint8_t(msg, 3);
  218. }
  219. /**
  220. * @brief Get field param_id from param_request_read message
  221. *
  222. * @return Onboard 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
  223. */
  224. static inline uint16_t mavlink_msg_param_request_read_get_param_id(const mavlink_message_t* msg, char *param_id)
  225. {
  226. return _MAV_RETURN_char_array(msg, param_id, 16, 4);
  227. }
  228. /**
  229. * @brief Get field param_index from param_request_read message
  230. *
  231. * @return Parameter index. Send -1 to use the param ID field as identifier (else the param id will be ignored)
  232. */
  233. static inline int16_t mavlink_msg_param_request_read_get_param_index(const mavlink_message_t* msg)
  234. {
  235. return _MAV_RETURN_int16_t(msg, 0);
  236. }
  237. /**
  238. * @brief Decode a param_request_read message into a struct
  239. *
  240. * @param msg The message to decode
  241. * @param param_request_read C-struct to decode the message contents into
  242. */
  243. static inline void mavlink_msg_param_request_read_decode(const mavlink_message_t* msg, mavlink_param_request_read_t* param_request_read)
  244. {
  245. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  246. param_request_read->param_index = mavlink_msg_param_request_read_get_param_index(msg);
  247. param_request_read->target_system = mavlink_msg_param_request_read_get_target_system(msg);
  248. param_request_read->target_component = mavlink_msg_param_request_read_get_target_component(msg);
  249. mavlink_msg_param_request_read_get_param_id(msg, param_request_read->param_id);
  250. #else
  251. uint8_t len = msg->len < MAVLINK_MSG_ID_PARAM_REQUEST_READ_LEN? msg->len : MAVLINK_MSG_ID_PARAM_REQUEST_READ_LEN;
  252. memset(param_request_read, 0, MAVLINK_MSG_ID_PARAM_REQUEST_READ_LEN);
  253. memcpy(param_request_read, _MAV_PAYLOAD(msg), len);
  254. #endif
  255. }