You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

238 lines
10 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. #pragma once
  2. // MESSAGE MESSAGE_INTERVAL PACKING
  3. #define MAVLINK_MSG_ID_MESSAGE_INTERVAL 244
  4. MAVPACKED(
  5. typedef struct __mavlink_message_interval_t {
  6. int32_t interval_us; /*< [us] The interval between two messages. A value of -1 indicates this stream is disabled, 0 indicates it is not available, > 0 indicates the interval at which it is sent.*/
  7. uint16_t message_id; /*< The ID of the requested MAVLink message. v1.0 is limited to 254 messages.*/
  8. }) mavlink_message_interval_t;
  9. #define MAVLINK_MSG_ID_MESSAGE_INTERVAL_LEN 6
  10. #define MAVLINK_MSG_ID_MESSAGE_INTERVAL_MIN_LEN 6
  11. #define MAVLINK_MSG_ID_244_LEN 6
  12. #define MAVLINK_MSG_ID_244_MIN_LEN 6
  13. #define MAVLINK_MSG_ID_MESSAGE_INTERVAL_CRC 95
  14. #define MAVLINK_MSG_ID_244_CRC 95
  15. #if MAVLINK_COMMAND_24BIT
  16. #define MAVLINK_MESSAGE_INFO_MESSAGE_INTERVAL { \
  17. 244, \
  18. "MESSAGE_INTERVAL", \
  19. 2, \
  20. { { "message_id", NULL, MAVLINK_TYPE_UINT16_T, 0, 4, offsetof(mavlink_message_interval_t, message_id) }, \
  21. { "interval_us", NULL, MAVLINK_TYPE_INT32_T, 0, 0, offsetof(mavlink_message_interval_t, interval_us) }, \
  22. } \
  23. }
  24. #else
  25. #define MAVLINK_MESSAGE_INFO_MESSAGE_INTERVAL { \
  26. "MESSAGE_INTERVAL", \
  27. 2, \
  28. { { "message_id", NULL, MAVLINK_TYPE_UINT16_T, 0, 4, offsetof(mavlink_message_interval_t, message_id) }, \
  29. { "interval_us", NULL, MAVLINK_TYPE_INT32_T, 0, 0, offsetof(mavlink_message_interval_t, interval_us) }, \
  30. } \
  31. }
  32. #endif
  33. /**
  34. * @brief Pack a message_interval message
  35. * @param system_id ID of this system
  36. * @param component_id ID of this component (e.g. 200 for IMU)
  37. * @param msg The MAVLink message to compress the data into
  38. *
  39. * @param message_id The ID of the requested MAVLink message. v1.0 is limited to 254 messages.
  40. * @param interval_us [us] The interval between two messages. A value of -1 indicates this stream is disabled, 0 indicates it is not available, > 0 indicates the interval at which it is sent.
  41. * @return length of the message in bytes (excluding serial stream start sign)
  42. */
  43. static inline uint16_t mavlink_msg_message_interval_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
  44. uint16_t message_id, int32_t interval_us)
  45. {
  46. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  47. char buf[MAVLINK_MSG_ID_MESSAGE_INTERVAL_LEN];
  48. _mav_put_int32_t(buf, 0, interval_us);
  49. _mav_put_uint16_t(buf, 4, message_id);
  50. memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_MESSAGE_INTERVAL_LEN);
  51. #else
  52. mavlink_message_interval_t packet;
  53. packet.interval_us = interval_us;
  54. packet.message_id = message_id;
  55. memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_MESSAGE_INTERVAL_LEN);
  56. #endif
  57. msg->msgid = MAVLINK_MSG_ID_MESSAGE_INTERVAL;
  58. return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_MESSAGE_INTERVAL_MIN_LEN, MAVLINK_MSG_ID_MESSAGE_INTERVAL_LEN, MAVLINK_MSG_ID_MESSAGE_INTERVAL_CRC);
  59. }
  60. /**
  61. * @brief Pack a message_interval message on a channel
  62. * @param system_id ID of this system
  63. * @param component_id ID of this component (e.g. 200 for IMU)
  64. * @param chan The MAVLink channel this message will be sent over
  65. * @param msg The MAVLink message to compress the data into
  66. * @param message_id The ID of the requested MAVLink message. v1.0 is limited to 254 messages.
  67. * @param interval_us [us] The interval between two messages. A value of -1 indicates this stream is disabled, 0 indicates it is not available, > 0 indicates the interval at which it is sent.
  68. * @return length of the message in bytes (excluding serial stream start sign)
  69. */
  70. static inline uint16_t mavlink_msg_message_interval_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
  71. mavlink_message_t* msg,
  72. uint16_t message_id,int32_t interval_us)
  73. {
  74. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  75. char buf[MAVLINK_MSG_ID_MESSAGE_INTERVAL_LEN];
  76. _mav_put_int32_t(buf, 0, interval_us);
  77. _mav_put_uint16_t(buf, 4, message_id);
  78. memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_MESSAGE_INTERVAL_LEN);
  79. #else
  80. mavlink_message_interval_t packet;
  81. packet.interval_us = interval_us;
  82. packet.message_id = message_id;
  83. memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_MESSAGE_INTERVAL_LEN);
  84. #endif
  85. msg->msgid = MAVLINK_MSG_ID_MESSAGE_INTERVAL;
  86. return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_MESSAGE_INTERVAL_MIN_LEN, MAVLINK_MSG_ID_MESSAGE_INTERVAL_LEN, MAVLINK_MSG_ID_MESSAGE_INTERVAL_CRC);
  87. }
  88. /**
  89. * @brief Encode a message_interval struct
  90. *
  91. * @param system_id ID of this system
  92. * @param component_id ID of this component (e.g. 200 for IMU)
  93. * @param msg The MAVLink message to compress the data into
  94. * @param message_interval C-struct to read the message contents from
  95. */
  96. static inline uint16_t mavlink_msg_message_interval_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_message_interval_t* message_interval)
  97. {
  98. return mavlink_msg_message_interval_pack(system_id, component_id, msg, message_interval->message_id, message_interval->interval_us);
  99. }
  100. /**
  101. * @brief Encode a message_interval struct on a channel
  102. *
  103. * @param system_id ID of this system
  104. * @param component_id ID of this component (e.g. 200 for IMU)
  105. * @param chan The MAVLink channel this message will be sent over
  106. * @param msg The MAVLink message to compress the data into
  107. * @param message_interval C-struct to read the message contents from
  108. */
  109. static inline uint16_t mavlink_msg_message_interval_encode_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, const mavlink_message_interval_t* message_interval)
  110. {
  111. return mavlink_msg_message_interval_pack_chan(system_id, component_id, chan, msg, message_interval->message_id, message_interval->interval_us);
  112. }
  113. /**
  114. * @brief Send a message_interval message
  115. * @param chan MAVLink channel to send the message
  116. *
  117. * @param message_id The ID of the requested MAVLink message. v1.0 is limited to 254 messages.
  118. * @param interval_us [us] The interval between two messages. A value of -1 indicates this stream is disabled, 0 indicates it is not available, > 0 indicates the interval at which it is sent.
  119. */
  120. #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
  121. static inline void mavlink_msg_message_interval_send(mavlink_channel_t chan, uint16_t message_id, int32_t interval_us)
  122. {
  123. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  124. char buf[MAVLINK_MSG_ID_MESSAGE_INTERVAL_LEN];
  125. _mav_put_int32_t(buf, 0, interval_us);
  126. _mav_put_uint16_t(buf, 4, message_id);
  127. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_MESSAGE_INTERVAL, buf, MAVLINK_MSG_ID_MESSAGE_INTERVAL_MIN_LEN, MAVLINK_MSG_ID_MESSAGE_INTERVAL_LEN, MAVLINK_MSG_ID_MESSAGE_INTERVAL_CRC);
  128. #else
  129. mavlink_message_interval_t packet;
  130. packet.interval_us = interval_us;
  131. packet.message_id = message_id;
  132. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_MESSAGE_INTERVAL, (const char *)&packet, MAVLINK_MSG_ID_MESSAGE_INTERVAL_MIN_LEN, MAVLINK_MSG_ID_MESSAGE_INTERVAL_LEN, MAVLINK_MSG_ID_MESSAGE_INTERVAL_CRC);
  133. #endif
  134. }
  135. /**
  136. * @brief Send a message_interval message
  137. * @param chan MAVLink channel to send the message
  138. * @param struct The MAVLink struct to serialize
  139. */
  140. static inline void mavlink_msg_message_interval_send_struct(mavlink_channel_t chan, const mavlink_message_interval_t* message_interval)
  141. {
  142. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  143. mavlink_msg_message_interval_send(chan, message_interval->message_id, message_interval->interval_us);
  144. #else
  145. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_MESSAGE_INTERVAL, (const char *)message_interval, MAVLINK_MSG_ID_MESSAGE_INTERVAL_MIN_LEN, MAVLINK_MSG_ID_MESSAGE_INTERVAL_LEN, MAVLINK_MSG_ID_MESSAGE_INTERVAL_CRC);
  146. #endif
  147. }
  148. #if MAVLINK_MSG_ID_MESSAGE_INTERVAL_LEN <= MAVLINK_MAX_PAYLOAD_LEN
  149. /*
  150. This varient of _send() can be used to save stack space by re-using
  151. memory from the receive buffer. The caller provides a
  152. mavlink_message_t which is the size of a full mavlink message. This
  153. is usually the receive buffer for the channel, and allows a reply to an
  154. incoming message with minimum stack space usage.
  155. */
  156. static inline void mavlink_msg_message_interval_send_buf(mavlink_message_t *msgbuf, mavlink_channel_t chan, uint16_t message_id, int32_t interval_us)
  157. {
  158. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  159. char *buf = (char *)msgbuf;
  160. _mav_put_int32_t(buf, 0, interval_us);
  161. _mav_put_uint16_t(buf, 4, message_id);
  162. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_MESSAGE_INTERVAL, buf, MAVLINK_MSG_ID_MESSAGE_INTERVAL_MIN_LEN, MAVLINK_MSG_ID_MESSAGE_INTERVAL_LEN, MAVLINK_MSG_ID_MESSAGE_INTERVAL_CRC);
  163. #else
  164. mavlink_message_interval_t *packet = (mavlink_message_interval_t *)msgbuf;
  165. packet->interval_us = interval_us;
  166. packet->message_id = message_id;
  167. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_MESSAGE_INTERVAL, (const char *)packet, MAVLINK_MSG_ID_MESSAGE_INTERVAL_MIN_LEN, MAVLINK_MSG_ID_MESSAGE_INTERVAL_LEN, MAVLINK_MSG_ID_MESSAGE_INTERVAL_CRC);
  168. #endif
  169. }
  170. #endif
  171. #endif
  172. // MESSAGE MESSAGE_INTERVAL UNPACKING
  173. /**
  174. * @brief Get field message_id from message_interval message
  175. *
  176. * @return The ID of the requested MAVLink message. v1.0 is limited to 254 messages.
  177. */
  178. static inline uint16_t mavlink_msg_message_interval_get_message_id(const mavlink_message_t* msg)
  179. {
  180. return _MAV_RETURN_uint16_t(msg, 4);
  181. }
  182. /**
  183. * @brief Get field interval_us from message_interval message
  184. *
  185. * @return [us] The interval between two messages. A value of -1 indicates this stream is disabled, 0 indicates it is not available, > 0 indicates the interval at which it is sent.
  186. */
  187. static inline int32_t mavlink_msg_message_interval_get_interval_us(const mavlink_message_t* msg)
  188. {
  189. return _MAV_RETURN_int32_t(msg, 0);
  190. }
  191. /**
  192. * @brief Decode a message_interval message into a struct
  193. *
  194. * @param msg The message to decode
  195. * @param message_interval C-struct to decode the message contents into
  196. */
  197. static inline void mavlink_msg_message_interval_decode(const mavlink_message_t* msg, mavlink_message_interval_t* message_interval)
  198. {
  199. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  200. message_interval->interval_us = mavlink_msg_message_interval_get_interval_us(msg);
  201. message_interval->message_id = mavlink_msg_message_interval_get_message_id(msg);
  202. #else
  203. uint8_t len = msg->len < MAVLINK_MSG_ID_MESSAGE_INTERVAL_LEN? msg->len : MAVLINK_MSG_ID_MESSAGE_INTERVAL_LEN;
  204. memset(message_interval, 0, MAVLINK_MSG_ID_MESSAGE_INTERVAL_LEN);
  205. memcpy(message_interval, _MAV_PAYLOAD(msg), len);
  206. #endif
  207. }