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.

330 lines
14 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. #pragma once
  2. // MESSAGE LED_CONTROL PACKING
  3. #define MAVLINK_MSG_ID_LED_CONTROL 186
  4. MAVPACKED(
  5. typedef struct __mavlink_led_control_t {
  6. uint8_t target_system; /*< System ID.*/
  7. uint8_t target_component; /*< Component ID.*/
  8. uint8_t instance; /*< Instance (LED instance to control or 255 for all LEDs).*/
  9. uint8_t pattern; /*< Pattern (see LED_PATTERN_ENUM).*/
  10. uint8_t custom_len; /*< Custom Byte Length.*/
  11. uint8_t custom_bytes[24]; /*< Custom Bytes.*/
  12. }) mavlink_led_control_t;
  13. #define MAVLINK_MSG_ID_LED_CONTROL_LEN 29
  14. #define MAVLINK_MSG_ID_LED_CONTROL_MIN_LEN 29
  15. #define MAVLINK_MSG_ID_186_LEN 29
  16. #define MAVLINK_MSG_ID_186_MIN_LEN 29
  17. #define MAVLINK_MSG_ID_LED_CONTROL_CRC 72
  18. #define MAVLINK_MSG_ID_186_CRC 72
  19. #define MAVLINK_MSG_LED_CONTROL_FIELD_CUSTOM_BYTES_LEN 24
  20. #if MAVLINK_COMMAND_24BIT
  21. #define MAVLINK_MESSAGE_INFO_LED_CONTROL { \
  22. 186, \
  23. "LED_CONTROL", \
  24. 6, \
  25. { { "target_system", NULL, MAVLINK_TYPE_UINT8_T, 0, 0, offsetof(mavlink_led_control_t, target_system) }, \
  26. { "target_component", NULL, MAVLINK_TYPE_UINT8_T, 0, 1, offsetof(mavlink_led_control_t, target_component) }, \
  27. { "instance", NULL, MAVLINK_TYPE_UINT8_T, 0, 2, offsetof(mavlink_led_control_t, instance) }, \
  28. { "pattern", NULL, MAVLINK_TYPE_UINT8_T, 0, 3, offsetof(mavlink_led_control_t, pattern) }, \
  29. { "custom_len", NULL, MAVLINK_TYPE_UINT8_T, 0, 4, offsetof(mavlink_led_control_t, custom_len) }, \
  30. { "custom_bytes", NULL, MAVLINK_TYPE_UINT8_T, 24, 5, offsetof(mavlink_led_control_t, custom_bytes) }, \
  31. } \
  32. }
  33. #else
  34. #define MAVLINK_MESSAGE_INFO_LED_CONTROL { \
  35. "LED_CONTROL", \
  36. 6, \
  37. { { "target_system", NULL, MAVLINK_TYPE_UINT8_T, 0, 0, offsetof(mavlink_led_control_t, target_system) }, \
  38. { "target_component", NULL, MAVLINK_TYPE_UINT8_T, 0, 1, offsetof(mavlink_led_control_t, target_component) }, \
  39. { "instance", NULL, MAVLINK_TYPE_UINT8_T, 0, 2, offsetof(mavlink_led_control_t, instance) }, \
  40. { "pattern", NULL, MAVLINK_TYPE_UINT8_T, 0, 3, offsetof(mavlink_led_control_t, pattern) }, \
  41. { "custom_len", NULL, MAVLINK_TYPE_UINT8_T, 0, 4, offsetof(mavlink_led_control_t, custom_len) }, \
  42. { "custom_bytes", NULL, MAVLINK_TYPE_UINT8_T, 24, 5, offsetof(mavlink_led_control_t, custom_bytes) }, \
  43. } \
  44. }
  45. #endif
  46. /**
  47. * @brief Pack a led_control message
  48. * @param system_id ID of this system
  49. * @param component_id ID of this component (e.g. 200 for IMU)
  50. * @param msg The MAVLink message to compress the data into
  51. *
  52. * @param target_system System ID.
  53. * @param target_component Component ID.
  54. * @param instance Instance (LED instance to control or 255 for all LEDs).
  55. * @param pattern Pattern (see LED_PATTERN_ENUM).
  56. * @param custom_len Custom Byte Length.
  57. * @param custom_bytes Custom Bytes.
  58. * @return length of the message in bytes (excluding serial stream start sign)
  59. */
  60. static inline uint16_t mavlink_msg_led_control_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
  61. uint8_t target_system, uint8_t target_component, uint8_t instance, uint8_t pattern, uint8_t custom_len, const uint8_t *custom_bytes)
  62. {
  63. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  64. char buf[MAVLINK_MSG_ID_LED_CONTROL_LEN];
  65. _mav_put_uint8_t(buf, 0, target_system);
  66. _mav_put_uint8_t(buf, 1, target_component);
  67. _mav_put_uint8_t(buf, 2, instance);
  68. _mav_put_uint8_t(buf, 3, pattern);
  69. _mav_put_uint8_t(buf, 4, custom_len);
  70. _mav_put_uint8_t_array(buf, 5, custom_bytes, 24);
  71. memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_LED_CONTROL_LEN);
  72. #else
  73. mavlink_led_control_t packet;
  74. packet.target_system = target_system;
  75. packet.target_component = target_component;
  76. packet.instance = instance;
  77. packet.pattern = pattern;
  78. packet.custom_len = custom_len;
  79. mav_array_memcpy(packet.custom_bytes, custom_bytes, sizeof(uint8_t)*24);
  80. memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_LED_CONTROL_LEN);
  81. #endif
  82. msg->msgid = MAVLINK_MSG_ID_LED_CONTROL;
  83. return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_LED_CONTROL_MIN_LEN, MAVLINK_MSG_ID_LED_CONTROL_LEN, MAVLINK_MSG_ID_LED_CONTROL_CRC);
  84. }
  85. /**
  86. * @brief Pack a led_control message on a channel
  87. * @param system_id ID of this system
  88. * @param component_id ID of this component (e.g. 200 for IMU)
  89. * @param chan The MAVLink channel this message will be sent over
  90. * @param msg The MAVLink message to compress the data into
  91. * @param target_system System ID.
  92. * @param target_component Component ID.
  93. * @param instance Instance (LED instance to control or 255 for all LEDs).
  94. * @param pattern Pattern (see LED_PATTERN_ENUM).
  95. * @param custom_len Custom Byte Length.
  96. * @param custom_bytes Custom Bytes.
  97. * @return length of the message in bytes (excluding serial stream start sign)
  98. */
  99. static inline uint16_t mavlink_msg_led_control_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
  100. mavlink_message_t* msg,
  101. uint8_t target_system,uint8_t target_component,uint8_t instance,uint8_t pattern,uint8_t custom_len,const uint8_t *custom_bytes)
  102. {
  103. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  104. char buf[MAVLINK_MSG_ID_LED_CONTROL_LEN];
  105. _mav_put_uint8_t(buf, 0, target_system);
  106. _mav_put_uint8_t(buf, 1, target_component);
  107. _mav_put_uint8_t(buf, 2, instance);
  108. _mav_put_uint8_t(buf, 3, pattern);
  109. _mav_put_uint8_t(buf, 4, custom_len);
  110. _mav_put_uint8_t_array(buf, 5, custom_bytes, 24);
  111. memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_LED_CONTROL_LEN);
  112. #else
  113. mavlink_led_control_t packet;
  114. packet.target_system = target_system;
  115. packet.target_component = target_component;
  116. packet.instance = instance;
  117. packet.pattern = pattern;
  118. packet.custom_len = custom_len;
  119. mav_array_memcpy(packet.custom_bytes, custom_bytes, sizeof(uint8_t)*24);
  120. memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_LED_CONTROL_LEN);
  121. #endif
  122. msg->msgid = MAVLINK_MSG_ID_LED_CONTROL;
  123. return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_LED_CONTROL_MIN_LEN, MAVLINK_MSG_ID_LED_CONTROL_LEN, MAVLINK_MSG_ID_LED_CONTROL_CRC);
  124. }
  125. /**
  126. * @brief Encode a led_control struct
  127. *
  128. * @param system_id ID of this system
  129. * @param component_id ID of this component (e.g. 200 for IMU)
  130. * @param msg The MAVLink message to compress the data into
  131. * @param led_control C-struct to read the message contents from
  132. */
  133. static inline uint16_t mavlink_msg_led_control_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_led_control_t* led_control)
  134. {
  135. return mavlink_msg_led_control_pack(system_id, component_id, msg, led_control->target_system, led_control->target_component, led_control->instance, led_control->pattern, led_control->custom_len, led_control->custom_bytes);
  136. }
  137. /**
  138. * @brief Encode a led_control struct on a channel
  139. *
  140. * @param system_id ID of this system
  141. * @param component_id ID of this component (e.g. 200 for IMU)
  142. * @param chan The MAVLink channel this message will be sent over
  143. * @param msg The MAVLink message to compress the data into
  144. * @param led_control C-struct to read the message contents from
  145. */
  146. static inline uint16_t mavlink_msg_led_control_encode_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, const mavlink_led_control_t* led_control)
  147. {
  148. return mavlink_msg_led_control_pack_chan(system_id, component_id, chan, msg, led_control->target_system, led_control->target_component, led_control->instance, led_control->pattern, led_control->custom_len, led_control->custom_bytes);
  149. }
  150. /**
  151. * @brief Send a led_control message
  152. * @param chan MAVLink channel to send the message
  153. *
  154. * @param target_system System ID.
  155. * @param target_component Component ID.
  156. * @param instance Instance (LED instance to control or 255 for all LEDs).
  157. * @param pattern Pattern (see LED_PATTERN_ENUM).
  158. * @param custom_len Custom Byte Length.
  159. * @param custom_bytes Custom Bytes.
  160. */
  161. #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
  162. static inline void mavlink_msg_led_control_send(mavlink_channel_t chan, uint8_t target_system, uint8_t target_component, uint8_t instance, uint8_t pattern, uint8_t custom_len, const uint8_t *custom_bytes)
  163. {
  164. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  165. char buf[MAVLINK_MSG_ID_LED_CONTROL_LEN];
  166. _mav_put_uint8_t(buf, 0, target_system);
  167. _mav_put_uint8_t(buf, 1, target_component);
  168. _mav_put_uint8_t(buf, 2, instance);
  169. _mav_put_uint8_t(buf, 3, pattern);
  170. _mav_put_uint8_t(buf, 4, custom_len);
  171. _mav_put_uint8_t_array(buf, 5, custom_bytes, 24);
  172. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_LED_CONTROL, buf, MAVLINK_MSG_ID_LED_CONTROL_MIN_LEN, MAVLINK_MSG_ID_LED_CONTROL_LEN, MAVLINK_MSG_ID_LED_CONTROL_CRC);
  173. #else
  174. mavlink_led_control_t packet;
  175. packet.target_system = target_system;
  176. packet.target_component = target_component;
  177. packet.instance = instance;
  178. packet.pattern = pattern;
  179. packet.custom_len = custom_len;
  180. mav_array_memcpy(packet.custom_bytes, custom_bytes, sizeof(uint8_t)*24);
  181. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_LED_CONTROL, (const char *)&packet, MAVLINK_MSG_ID_LED_CONTROL_MIN_LEN, MAVLINK_MSG_ID_LED_CONTROL_LEN, MAVLINK_MSG_ID_LED_CONTROL_CRC);
  182. #endif
  183. }
  184. /**
  185. * @brief Send a led_control message
  186. * @param chan MAVLink channel to send the message
  187. * @param struct The MAVLink struct to serialize
  188. */
  189. static inline void mavlink_msg_led_control_send_struct(mavlink_channel_t chan, const mavlink_led_control_t* led_control)
  190. {
  191. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  192. mavlink_msg_led_control_send(chan, led_control->target_system, led_control->target_component, led_control->instance, led_control->pattern, led_control->custom_len, led_control->custom_bytes);
  193. #else
  194. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_LED_CONTROL, (const char *)led_control, MAVLINK_MSG_ID_LED_CONTROL_MIN_LEN, MAVLINK_MSG_ID_LED_CONTROL_LEN, MAVLINK_MSG_ID_LED_CONTROL_CRC);
  195. #endif
  196. }
  197. #if MAVLINK_MSG_ID_LED_CONTROL_LEN <= MAVLINK_MAX_PAYLOAD_LEN
  198. /*
  199. This varient of _send() can be used to save stack space by re-using
  200. memory from the receive buffer. The caller provides a
  201. mavlink_message_t which is the size of a full mavlink message. This
  202. is usually the receive buffer for the channel, and allows a reply to an
  203. incoming message with minimum stack space usage.
  204. */
  205. static inline void mavlink_msg_led_control_send_buf(mavlink_message_t *msgbuf, mavlink_channel_t chan, uint8_t target_system, uint8_t target_component, uint8_t instance, uint8_t pattern, uint8_t custom_len, const uint8_t *custom_bytes)
  206. {
  207. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  208. char *buf = (char *)msgbuf;
  209. _mav_put_uint8_t(buf, 0, target_system);
  210. _mav_put_uint8_t(buf, 1, target_component);
  211. _mav_put_uint8_t(buf, 2, instance);
  212. _mav_put_uint8_t(buf, 3, pattern);
  213. _mav_put_uint8_t(buf, 4, custom_len);
  214. _mav_put_uint8_t_array(buf, 5, custom_bytes, 24);
  215. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_LED_CONTROL, buf, MAVLINK_MSG_ID_LED_CONTROL_MIN_LEN, MAVLINK_MSG_ID_LED_CONTROL_LEN, MAVLINK_MSG_ID_LED_CONTROL_CRC);
  216. #else
  217. mavlink_led_control_t *packet = (mavlink_led_control_t *)msgbuf;
  218. packet->target_system = target_system;
  219. packet->target_component = target_component;
  220. packet->instance = instance;
  221. packet->pattern = pattern;
  222. packet->custom_len = custom_len;
  223. mav_array_memcpy(packet->custom_bytes, custom_bytes, sizeof(uint8_t)*24);
  224. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_LED_CONTROL, (const char *)packet, MAVLINK_MSG_ID_LED_CONTROL_MIN_LEN, MAVLINK_MSG_ID_LED_CONTROL_LEN, MAVLINK_MSG_ID_LED_CONTROL_CRC);
  225. #endif
  226. }
  227. #endif
  228. #endif
  229. // MESSAGE LED_CONTROL UNPACKING
  230. /**
  231. * @brief Get field target_system from led_control message
  232. *
  233. * @return System ID.
  234. */
  235. static inline uint8_t mavlink_msg_led_control_get_target_system(const mavlink_message_t* msg)
  236. {
  237. return _MAV_RETURN_uint8_t(msg, 0);
  238. }
  239. /**
  240. * @brief Get field target_component from led_control message
  241. *
  242. * @return Component ID.
  243. */
  244. static inline uint8_t mavlink_msg_led_control_get_target_component(const mavlink_message_t* msg)
  245. {
  246. return _MAV_RETURN_uint8_t(msg, 1);
  247. }
  248. /**
  249. * @brief Get field instance from led_control message
  250. *
  251. * @return Instance (LED instance to control or 255 for all LEDs).
  252. */
  253. static inline uint8_t mavlink_msg_led_control_get_instance(const mavlink_message_t* msg)
  254. {
  255. return _MAV_RETURN_uint8_t(msg, 2);
  256. }
  257. /**
  258. * @brief Get field pattern from led_control message
  259. *
  260. * @return Pattern (see LED_PATTERN_ENUM).
  261. */
  262. static inline uint8_t mavlink_msg_led_control_get_pattern(const mavlink_message_t* msg)
  263. {
  264. return _MAV_RETURN_uint8_t(msg, 3);
  265. }
  266. /**
  267. * @brief Get field custom_len from led_control message
  268. *
  269. * @return Custom Byte Length.
  270. */
  271. static inline uint8_t mavlink_msg_led_control_get_custom_len(const mavlink_message_t* msg)
  272. {
  273. return _MAV_RETURN_uint8_t(msg, 4);
  274. }
  275. /**
  276. * @brief Get field custom_bytes from led_control message
  277. *
  278. * @return Custom Bytes.
  279. */
  280. static inline uint16_t mavlink_msg_led_control_get_custom_bytes(const mavlink_message_t* msg, uint8_t *custom_bytes)
  281. {
  282. return _MAV_RETURN_uint8_t_array(msg, custom_bytes, 24, 5);
  283. }
  284. /**
  285. * @brief Decode a led_control message into a struct
  286. *
  287. * @param msg The message to decode
  288. * @param led_control C-struct to decode the message contents into
  289. */
  290. static inline void mavlink_msg_led_control_decode(const mavlink_message_t* msg, mavlink_led_control_t* led_control)
  291. {
  292. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  293. led_control->target_system = mavlink_msg_led_control_get_target_system(msg);
  294. led_control->target_component = mavlink_msg_led_control_get_target_component(msg);
  295. led_control->instance = mavlink_msg_led_control_get_instance(msg);
  296. led_control->pattern = mavlink_msg_led_control_get_pattern(msg);
  297. led_control->custom_len = mavlink_msg_led_control_get_custom_len(msg);
  298. mavlink_msg_led_control_get_custom_bytes(msg, led_control->custom_bytes);
  299. #else
  300. uint8_t len = msg->len < MAVLINK_MSG_ID_LED_CONTROL_LEN? msg->len : MAVLINK_MSG_ID_LED_CONTROL_LEN;
  301. memset(led_control, 0, MAVLINK_MSG_ID_LED_CONTROL_LEN);
  302. memcpy(led_control, _MAV_PAYLOAD(msg), len);
  303. #endif
  304. }