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 SERIAL_CONTROL PACKING
  3. #define MAVLINK_MSG_ID_SERIAL_CONTROL 126
  4. MAVPACKED(
  5. typedef struct __mavlink_serial_control_t {
  6. uint32_t baudrate; /*< [bits/s] Baudrate of transfer. Zero means no change.*/
  7. uint16_t timeout; /*< [ms] Timeout for reply data*/
  8. uint8_t device; /*< Serial control device type.*/
  9. uint8_t flags; /*< Bitmap of serial control flags.*/
  10. uint8_t count; /*< [bytes] how many bytes in this transfer*/
  11. uint8_t data[70]; /*< serial data*/
  12. }) mavlink_serial_control_t;
  13. #define MAVLINK_MSG_ID_SERIAL_CONTROL_LEN 79
  14. #define MAVLINK_MSG_ID_SERIAL_CONTROL_MIN_LEN 79
  15. #define MAVLINK_MSG_ID_126_LEN 79
  16. #define MAVLINK_MSG_ID_126_MIN_LEN 79
  17. #define MAVLINK_MSG_ID_SERIAL_CONTROL_CRC 220
  18. #define MAVLINK_MSG_ID_126_CRC 220
  19. #define MAVLINK_MSG_SERIAL_CONTROL_FIELD_DATA_LEN 70
  20. #if MAVLINK_COMMAND_24BIT
  21. #define MAVLINK_MESSAGE_INFO_SERIAL_CONTROL { \
  22. 126, \
  23. "SERIAL_CONTROL", \
  24. 6, \
  25. { { "device", NULL, MAVLINK_TYPE_UINT8_T, 0, 6, offsetof(mavlink_serial_control_t, device) }, \
  26. { "flags", NULL, MAVLINK_TYPE_UINT8_T, 0, 7, offsetof(mavlink_serial_control_t, flags) }, \
  27. { "timeout", NULL, MAVLINK_TYPE_UINT16_T, 0, 4, offsetof(mavlink_serial_control_t, timeout) }, \
  28. { "baudrate", NULL, MAVLINK_TYPE_UINT32_T, 0, 0, offsetof(mavlink_serial_control_t, baudrate) }, \
  29. { "count", NULL, MAVLINK_TYPE_UINT8_T, 0, 8, offsetof(mavlink_serial_control_t, count) }, \
  30. { "data", NULL, MAVLINK_TYPE_UINT8_T, 70, 9, offsetof(mavlink_serial_control_t, data) }, \
  31. } \
  32. }
  33. #else
  34. #define MAVLINK_MESSAGE_INFO_SERIAL_CONTROL { \
  35. "SERIAL_CONTROL", \
  36. 6, \
  37. { { "device", NULL, MAVLINK_TYPE_UINT8_T, 0, 6, offsetof(mavlink_serial_control_t, device) }, \
  38. { "flags", NULL, MAVLINK_TYPE_UINT8_T, 0, 7, offsetof(mavlink_serial_control_t, flags) }, \
  39. { "timeout", NULL, MAVLINK_TYPE_UINT16_T, 0, 4, offsetof(mavlink_serial_control_t, timeout) }, \
  40. { "baudrate", NULL, MAVLINK_TYPE_UINT32_T, 0, 0, offsetof(mavlink_serial_control_t, baudrate) }, \
  41. { "count", NULL, MAVLINK_TYPE_UINT8_T, 0, 8, offsetof(mavlink_serial_control_t, count) }, \
  42. { "data", NULL, MAVLINK_TYPE_UINT8_T, 70, 9, offsetof(mavlink_serial_control_t, data) }, \
  43. } \
  44. }
  45. #endif
  46. /**
  47. * @brief Pack a serial_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 device Serial control device type.
  53. * @param flags Bitmap of serial control flags.
  54. * @param timeout [ms] Timeout for reply data
  55. * @param baudrate [bits/s] Baudrate of transfer. Zero means no change.
  56. * @param count [bytes] how many bytes in this transfer
  57. * @param data serial data
  58. * @return length of the message in bytes (excluding serial stream start sign)
  59. */
  60. static inline uint16_t mavlink_msg_serial_control_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
  61. uint8_t device, uint8_t flags, uint16_t timeout, uint32_t baudrate, uint8_t count, const uint8_t *data)
  62. {
  63. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  64. char buf[MAVLINK_MSG_ID_SERIAL_CONTROL_LEN];
  65. _mav_put_uint32_t(buf, 0, baudrate);
  66. _mav_put_uint16_t(buf, 4, timeout);
  67. _mav_put_uint8_t(buf, 6, device);
  68. _mav_put_uint8_t(buf, 7, flags);
  69. _mav_put_uint8_t(buf, 8, count);
  70. _mav_put_uint8_t_array(buf, 9, data, 70);
  71. memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_SERIAL_CONTROL_LEN);
  72. #else
  73. mavlink_serial_control_t packet;
  74. packet.baudrate = baudrate;
  75. packet.timeout = timeout;
  76. packet.device = device;
  77. packet.flags = flags;
  78. packet.count = count;
  79. mav_array_memcpy(packet.data, data, sizeof(uint8_t)*70);
  80. memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_SERIAL_CONTROL_LEN);
  81. #endif
  82. msg->msgid = MAVLINK_MSG_ID_SERIAL_CONTROL;
  83. return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_SERIAL_CONTROL_MIN_LEN, MAVLINK_MSG_ID_SERIAL_CONTROL_LEN, MAVLINK_MSG_ID_SERIAL_CONTROL_CRC);
  84. }
  85. /**
  86. * @brief Pack a serial_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 device Serial control device type.
  92. * @param flags Bitmap of serial control flags.
  93. * @param timeout [ms] Timeout for reply data
  94. * @param baudrate [bits/s] Baudrate of transfer. Zero means no change.
  95. * @param count [bytes] how many bytes in this transfer
  96. * @param data serial data
  97. * @return length of the message in bytes (excluding serial stream start sign)
  98. */
  99. static inline uint16_t mavlink_msg_serial_control_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
  100. mavlink_message_t* msg,
  101. uint8_t device,uint8_t flags,uint16_t timeout,uint32_t baudrate,uint8_t count,const uint8_t *data)
  102. {
  103. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  104. char buf[MAVLINK_MSG_ID_SERIAL_CONTROL_LEN];
  105. _mav_put_uint32_t(buf, 0, baudrate);
  106. _mav_put_uint16_t(buf, 4, timeout);
  107. _mav_put_uint8_t(buf, 6, device);
  108. _mav_put_uint8_t(buf, 7, flags);
  109. _mav_put_uint8_t(buf, 8, count);
  110. _mav_put_uint8_t_array(buf, 9, data, 70);
  111. memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_SERIAL_CONTROL_LEN);
  112. #else
  113. mavlink_serial_control_t packet;
  114. packet.baudrate = baudrate;
  115. packet.timeout = timeout;
  116. packet.device = device;
  117. packet.flags = flags;
  118. packet.count = count;
  119. mav_array_memcpy(packet.data, data, sizeof(uint8_t)*70);
  120. memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_SERIAL_CONTROL_LEN);
  121. #endif
  122. msg->msgid = MAVLINK_MSG_ID_SERIAL_CONTROL;
  123. return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_SERIAL_CONTROL_MIN_LEN, MAVLINK_MSG_ID_SERIAL_CONTROL_LEN, MAVLINK_MSG_ID_SERIAL_CONTROL_CRC);
  124. }
  125. /**
  126. * @brief Encode a serial_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 serial_control C-struct to read the message contents from
  132. */
  133. static inline uint16_t mavlink_msg_serial_control_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_serial_control_t* serial_control)
  134. {
  135. return mavlink_msg_serial_control_pack(system_id, component_id, msg, serial_control->device, serial_control->flags, serial_control->timeout, serial_control->baudrate, serial_control->count, serial_control->data);
  136. }
  137. /**
  138. * @brief Encode a serial_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 serial_control C-struct to read the message contents from
  145. */
  146. static inline uint16_t mavlink_msg_serial_control_encode_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, const mavlink_serial_control_t* serial_control)
  147. {
  148. return mavlink_msg_serial_control_pack_chan(system_id, component_id, chan, msg, serial_control->device, serial_control->flags, serial_control->timeout, serial_control->baudrate, serial_control->count, serial_control->data);
  149. }
  150. /**
  151. * @brief Send a serial_control message
  152. * @param chan MAVLink channel to send the message
  153. *
  154. * @param device Serial control device type.
  155. * @param flags Bitmap of serial control flags.
  156. * @param timeout [ms] Timeout for reply data
  157. * @param baudrate [bits/s] Baudrate of transfer. Zero means no change.
  158. * @param count [bytes] how many bytes in this transfer
  159. * @param data serial data
  160. */
  161. #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
  162. static inline void mavlink_msg_serial_control_send(mavlink_channel_t chan, uint8_t device, uint8_t flags, uint16_t timeout, uint32_t baudrate, uint8_t count, const uint8_t *data)
  163. {
  164. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  165. char buf[MAVLINK_MSG_ID_SERIAL_CONTROL_LEN];
  166. _mav_put_uint32_t(buf, 0, baudrate);
  167. _mav_put_uint16_t(buf, 4, timeout);
  168. _mav_put_uint8_t(buf, 6, device);
  169. _mav_put_uint8_t(buf, 7, flags);
  170. _mav_put_uint8_t(buf, 8, count);
  171. _mav_put_uint8_t_array(buf, 9, data, 70);
  172. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_SERIAL_CONTROL, buf, MAVLINK_MSG_ID_SERIAL_CONTROL_MIN_LEN, MAVLINK_MSG_ID_SERIAL_CONTROL_LEN, MAVLINK_MSG_ID_SERIAL_CONTROL_CRC);
  173. #else
  174. mavlink_serial_control_t packet;
  175. packet.baudrate = baudrate;
  176. packet.timeout = timeout;
  177. packet.device = device;
  178. packet.flags = flags;
  179. packet.count = count;
  180. mav_array_memcpy(packet.data, data, sizeof(uint8_t)*70);
  181. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_SERIAL_CONTROL, (const char *)&packet, MAVLINK_MSG_ID_SERIAL_CONTROL_MIN_LEN, MAVLINK_MSG_ID_SERIAL_CONTROL_LEN, MAVLINK_MSG_ID_SERIAL_CONTROL_CRC);
  182. #endif
  183. }
  184. /**
  185. * @brief Send a serial_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_serial_control_send_struct(mavlink_channel_t chan, const mavlink_serial_control_t* serial_control)
  190. {
  191. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  192. mavlink_msg_serial_control_send(chan, serial_control->device, serial_control->flags, serial_control->timeout, serial_control->baudrate, serial_control->count, serial_control->data);
  193. #else
  194. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_SERIAL_CONTROL, (const char *)serial_control, MAVLINK_MSG_ID_SERIAL_CONTROL_MIN_LEN, MAVLINK_MSG_ID_SERIAL_CONTROL_LEN, MAVLINK_MSG_ID_SERIAL_CONTROL_CRC);
  195. #endif
  196. }
  197. #if MAVLINK_MSG_ID_SERIAL_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_serial_control_send_buf(mavlink_message_t *msgbuf, mavlink_channel_t chan, uint8_t device, uint8_t flags, uint16_t timeout, uint32_t baudrate, uint8_t count, const uint8_t *data)
  206. {
  207. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  208. char *buf = (char *)msgbuf;
  209. _mav_put_uint32_t(buf, 0, baudrate);
  210. _mav_put_uint16_t(buf, 4, timeout);
  211. _mav_put_uint8_t(buf, 6, device);
  212. _mav_put_uint8_t(buf, 7, flags);
  213. _mav_put_uint8_t(buf, 8, count);
  214. _mav_put_uint8_t_array(buf, 9, data, 70);
  215. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_SERIAL_CONTROL, buf, MAVLINK_MSG_ID_SERIAL_CONTROL_MIN_LEN, MAVLINK_MSG_ID_SERIAL_CONTROL_LEN, MAVLINK_MSG_ID_SERIAL_CONTROL_CRC);
  216. #else
  217. mavlink_serial_control_t *packet = (mavlink_serial_control_t *)msgbuf;
  218. packet->baudrate = baudrate;
  219. packet->timeout = timeout;
  220. packet->device = device;
  221. packet->flags = flags;
  222. packet->count = count;
  223. mav_array_memcpy(packet->data, data, sizeof(uint8_t)*70);
  224. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_SERIAL_CONTROL, (const char *)packet, MAVLINK_MSG_ID_SERIAL_CONTROL_MIN_LEN, MAVLINK_MSG_ID_SERIAL_CONTROL_LEN, MAVLINK_MSG_ID_SERIAL_CONTROL_CRC);
  225. #endif
  226. }
  227. #endif
  228. #endif
  229. // MESSAGE SERIAL_CONTROL UNPACKING
  230. /**
  231. * @brief Get field device from serial_control message
  232. *
  233. * @return Serial control device type.
  234. */
  235. static inline uint8_t mavlink_msg_serial_control_get_device(const mavlink_message_t* msg)
  236. {
  237. return _MAV_RETURN_uint8_t(msg, 6);
  238. }
  239. /**
  240. * @brief Get field flags from serial_control message
  241. *
  242. * @return Bitmap of serial control flags.
  243. */
  244. static inline uint8_t mavlink_msg_serial_control_get_flags(const mavlink_message_t* msg)
  245. {
  246. return _MAV_RETURN_uint8_t(msg, 7);
  247. }
  248. /**
  249. * @brief Get field timeout from serial_control message
  250. *
  251. * @return [ms] Timeout for reply data
  252. */
  253. static inline uint16_t mavlink_msg_serial_control_get_timeout(const mavlink_message_t* msg)
  254. {
  255. return _MAV_RETURN_uint16_t(msg, 4);
  256. }
  257. /**
  258. * @brief Get field baudrate from serial_control message
  259. *
  260. * @return [bits/s] Baudrate of transfer. Zero means no change.
  261. */
  262. static inline uint32_t mavlink_msg_serial_control_get_baudrate(const mavlink_message_t* msg)
  263. {
  264. return _MAV_RETURN_uint32_t(msg, 0);
  265. }
  266. /**
  267. * @brief Get field count from serial_control message
  268. *
  269. * @return [bytes] how many bytes in this transfer
  270. */
  271. static inline uint8_t mavlink_msg_serial_control_get_count(const mavlink_message_t* msg)
  272. {
  273. return _MAV_RETURN_uint8_t(msg, 8);
  274. }
  275. /**
  276. * @brief Get field data from serial_control message
  277. *
  278. * @return serial data
  279. */
  280. static inline uint16_t mavlink_msg_serial_control_get_data(const mavlink_message_t* msg, uint8_t *data)
  281. {
  282. return _MAV_RETURN_uint8_t_array(msg, data, 70, 9);
  283. }
  284. /**
  285. * @brief Decode a serial_control message into a struct
  286. *
  287. * @param msg The message to decode
  288. * @param serial_control C-struct to decode the message contents into
  289. */
  290. static inline void mavlink_msg_serial_control_decode(const mavlink_message_t* msg, mavlink_serial_control_t* serial_control)
  291. {
  292. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  293. serial_control->baudrate = mavlink_msg_serial_control_get_baudrate(msg);
  294. serial_control->timeout = mavlink_msg_serial_control_get_timeout(msg);
  295. serial_control->device = mavlink_msg_serial_control_get_device(msg);
  296. serial_control->flags = mavlink_msg_serial_control_get_flags(msg);
  297. serial_control->count = mavlink_msg_serial_control_get_count(msg);
  298. mavlink_msg_serial_control_get_data(msg, serial_control->data);
  299. #else
  300. uint8_t len = msg->len < MAVLINK_MSG_ID_SERIAL_CONTROL_LEN? msg->len : MAVLINK_MSG_ID_SERIAL_CONTROL_LEN;
  301. memset(serial_control, 0, MAVLINK_MSG_ID_SERIAL_CONTROL_LEN);
  302. memcpy(serial_control, _MAV_PAYLOAD(msg), len);
  303. #endif
  304. }