mavlink_msg_dtu_status.h 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307
  1. #pragma once
  2. // MESSAGE DTU_STATUS PACKING
  3. #define MAVLINK_MSG_ID_DTU_STATUS 54010
  4. typedef struct __mavlink_dtu_status_t {
  5. uint8_t csq; /*< Receive signal strength indicator,Values: [0-254]*/
  6. uint8_t sn[32]; /*< Sim Card sn code.*/
  7. uint8_t imei[32]; /*< Dtu board imei code.*/
  8. } mavlink_dtu_status_t;
  9. #define MAVLINK_MSG_ID_DTU_STATUS_LEN 65
  10. #define MAVLINK_MSG_ID_DTU_STATUS_MIN_LEN 65
  11. #define MAVLINK_MSG_ID_54010_LEN 65
  12. #define MAVLINK_MSG_ID_54010_MIN_LEN 65
  13. #define MAVLINK_MSG_ID_DTU_STATUS_CRC 100
  14. #define MAVLINK_MSG_ID_54010_CRC 100
  15. #define MAVLINK_MSG_DTU_STATUS_FIELD_SN_LEN 32
  16. #define MAVLINK_MSG_DTU_STATUS_FIELD_IMEI_LEN 32
  17. #if MAVLINK_COMMAND_24BIT
  18. #define MAVLINK_MESSAGE_INFO_DTU_STATUS { \
  19. 54010, \
  20. "DTU_STATUS", \
  21. 3, \
  22. { { "csq", NULL, MAVLINK_TYPE_UINT8_T, 0, 0, offsetof(mavlink_dtu_status_t, csq) }, \
  23. { "sn", NULL, MAVLINK_TYPE_UINT8_T, 32, 1, offsetof(mavlink_dtu_status_t, sn) }, \
  24. { "imei", NULL, MAVLINK_TYPE_UINT8_T, 32, 33, offsetof(mavlink_dtu_status_t, imei) }, \
  25. } \
  26. }
  27. #else
  28. #define MAVLINK_MESSAGE_INFO_DTU_STATUS { \
  29. "DTU_STATUS", \
  30. 3, \
  31. { { "csq", NULL, MAVLINK_TYPE_UINT8_T, 0, 0, offsetof(mavlink_dtu_status_t, csq) }, \
  32. { "sn", NULL, MAVLINK_TYPE_UINT8_T, 32, 1, offsetof(mavlink_dtu_status_t, sn) }, \
  33. { "imei", NULL, MAVLINK_TYPE_UINT8_T, 32, 33, offsetof(mavlink_dtu_status_t, imei) }, \
  34. } \
  35. }
  36. #endif
  37. /**
  38. * @brief Pack a dtu_status message
  39. * @param system_id ID of this system
  40. * @param component_id ID of this component (e.g. 200 for IMU)
  41. * @param msg The MAVLink message to compress the data into
  42. *
  43. * @param csq Receive signal strength indicator,Values: [0-254]
  44. * @param sn Sim Card sn code.
  45. * @param imei Dtu board imei code.
  46. * @return length of the message in bytes (excluding serial stream start sign)
  47. */
  48. static inline uint16_t mavlink_msg_dtu_status_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
  49. uint8_t csq, const uint8_t *sn, const uint8_t *imei)
  50. {
  51. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  52. char buf[MAVLINK_MSG_ID_DTU_STATUS_LEN];
  53. _mav_put_uint8_t(buf, 0, csq);
  54. _mav_put_uint8_t_array(buf, 1, sn, 32);
  55. _mav_put_uint8_t_array(buf, 33, imei, 32);
  56. memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_DTU_STATUS_LEN);
  57. #else
  58. mavlink_dtu_status_t packet;
  59. packet.csq = csq;
  60. mav_array_memcpy(packet.sn, sn, sizeof(uint8_t)*32);
  61. mav_array_memcpy(packet.imei, imei, sizeof(uint8_t)*32);
  62. memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_DTU_STATUS_LEN);
  63. #endif
  64. msg->msgid = MAVLINK_MSG_ID_DTU_STATUS;
  65. return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_DTU_STATUS_MIN_LEN, MAVLINK_MSG_ID_DTU_STATUS_LEN, MAVLINK_MSG_ID_DTU_STATUS_CRC);
  66. }
  67. /**
  68. * @brief Pack a dtu_status message
  69. * @param system_id ID of this system
  70. * @param component_id ID of this component (e.g. 200 for IMU)
  71. * @param status MAVLink status structure
  72. * @param msg The MAVLink message to compress the data into
  73. *
  74. * @param csq Receive signal strength indicator,Values: [0-254]
  75. * @param sn Sim Card sn code.
  76. * @param imei Dtu board imei code.
  77. * @return length of the message in bytes (excluding serial stream start sign)
  78. */
  79. static inline uint16_t mavlink_msg_dtu_status_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg,
  80. uint8_t csq, const uint8_t *sn, const uint8_t *imei)
  81. {
  82. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  83. char buf[MAVLINK_MSG_ID_DTU_STATUS_LEN];
  84. _mav_put_uint8_t(buf, 0, csq);
  85. _mav_put_uint8_t_array(buf, 1, sn, 32);
  86. _mav_put_uint8_t_array(buf, 33, imei, 32);
  87. memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_DTU_STATUS_LEN);
  88. #else
  89. mavlink_dtu_status_t packet;
  90. packet.csq = csq;
  91. mav_array_memcpy(packet.sn, sn, sizeof(uint8_t)*32);
  92. mav_array_memcpy(packet.imei, imei, sizeof(uint8_t)*32);
  93. memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_DTU_STATUS_LEN);
  94. #endif
  95. msg->msgid = MAVLINK_MSG_ID_DTU_STATUS;
  96. #if MAVLINK_CRC_EXTRA
  97. return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_DTU_STATUS_MIN_LEN, MAVLINK_MSG_ID_DTU_STATUS_LEN, MAVLINK_MSG_ID_DTU_STATUS_CRC);
  98. #else
  99. return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_DTU_STATUS_MIN_LEN, MAVLINK_MSG_ID_DTU_STATUS_LEN);
  100. #endif
  101. }
  102. /**
  103. * @brief Pack a dtu_status message on a channel
  104. * @param system_id ID of this system
  105. * @param component_id ID of this component (e.g. 200 for IMU)
  106. * @param chan The MAVLink channel this message will be sent over
  107. * @param msg The MAVLink message to compress the data into
  108. * @param csq Receive signal strength indicator,Values: [0-254]
  109. * @param sn Sim Card sn code.
  110. * @param imei Dtu board imei code.
  111. * @return length of the message in bytes (excluding serial stream start sign)
  112. */
  113. static inline uint16_t mavlink_msg_dtu_status_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
  114. mavlink_message_t* msg,
  115. uint8_t csq,const uint8_t *sn,const uint8_t *imei)
  116. {
  117. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  118. char buf[MAVLINK_MSG_ID_DTU_STATUS_LEN];
  119. _mav_put_uint8_t(buf, 0, csq);
  120. _mav_put_uint8_t_array(buf, 1, sn, 32);
  121. _mav_put_uint8_t_array(buf, 33, imei, 32);
  122. memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_DTU_STATUS_LEN);
  123. #else
  124. mavlink_dtu_status_t packet;
  125. packet.csq = csq;
  126. mav_array_memcpy(packet.sn, sn, sizeof(uint8_t)*32);
  127. mav_array_memcpy(packet.imei, imei, sizeof(uint8_t)*32);
  128. memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_DTU_STATUS_LEN);
  129. #endif
  130. msg->msgid = MAVLINK_MSG_ID_DTU_STATUS;
  131. return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_DTU_STATUS_MIN_LEN, MAVLINK_MSG_ID_DTU_STATUS_LEN, MAVLINK_MSG_ID_DTU_STATUS_CRC);
  132. }
  133. /**
  134. * @brief Encode a dtu_status struct
  135. *
  136. * @param system_id ID of this system
  137. * @param component_id ID of this component (e.g. 200 for IMU)
  138. * @param msg The MAVLink message to compress the data into
  139. * @param dtu_status C-struct to read the message contents from
  140. */
  141. static inline uint16_t mavlink_msg_dtu_status_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_dtu_status_t* dtu_status)
  142. {
  143. return mavlink_msg_dtu_status_pack(system_id, component_id, msg, dtu_status->csq, dtu_status->sn, dtu_status->imei);
  144. }
  145. /**
  146. * @brief Encode a dtu_status struct on a channel
  147. *
  148. * @param system_id ID of this system
  149. * @param component_id ID of this component (e.g. 200 for IMU)
  150. * @param chan The MAVLink channel this message will be sent over
  151. * @param msg The MAVLink message to compress the data into
  152. * @param dtu_status C-struct to read the message contents from
  153. */
  154. static inline uint16_t mavlink_msg_dtu_status_encode_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, const mavlink_dtu_status_t* dtu_status)
  155. {
  156. return mavlink_msg_dtu_status_pack_chan(system_id, component_id, chan, msg, dtu_status->csq, dtu_status->sn, dtu_status->imei);
  157. }
  158. /**
  159. * @brief Encode a dtu_status struct with provided status structure
  160. *
  161. * @param system_id ID of this system
  162. * @param component_id ID of this component (e.g. 200 for IMU)
  163. * @param status MAVLink status structure
  164. * @param msg The MAVLink message to compress the data into
  165. * @param dtu_status C-struct to read the message contents from
  166. */
  167. static inline uint16_t mavlink_msg_dtu_status_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_dtu_status_t* dtu_status)
  168. {
  169. return mavlink_msg_dtu_status_pack_status(system_id, component_id, _status, msg, dtu_status->csq, dtu_status->sn, dtu_status->imei);
  170. }
  171. /**
  172. * @brief Send a dtu_status message
  173. * @param chan MAVLink channel to send the message
  174. *
  175. * @param csq Receive signal strength indicator,Values: [0-254]
  176. * @param sn Sim Card sn code.
  177. * @param imei Dtu board imei code.
  178. */
  179. #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
  180. static inline void mavlink_msg_dtu_status_send(mavlink_channel_t chan, uint8_t csq, const uint8_t *sn, const uint8_t *imei)
  181. {
  182. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  183. char buf[MAVLINK_MSG_ID_DTU_STATUS_LEN];
  184. _mav_put_uint8_t(buf, 0, csq);
  185. _mav_put_uint8_t_array(buf, 1, sn, 32);
  186. _mav_put_uint8_t_array(buf, 33, imei, 32);
  187. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_DTU_STATUS, buf, MAVLINK_MSG_ID_DTU_STATUS_MIN_LEN, MAVLINK_MSG_ID_DTU_STATUS_LEN, MAVLINK_MSG_ID_DTU_STATUS_CRC);
  188. #else
  189. mavlink_dtu_status_t packet;
  190. packet.csq = csq;
  191. mav_array_memcpy(packet.sn, sn, sizeof(uint8_t)*32);
  192. mav_array_memcpy(packet.imei, imei, sizeof(uint8_t)*32);
  193. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_DTU_STATUS, (const char *)&packet, MAVLINK_MSG_ID_DTU_STATUS_MIN_LEN, MAVLINK_MSG_ID_DTU_STATUS_LEN, MAVLINK_MSG_ID_DTU_STATUS_CRC);
  194. #endif
  195. }
  196. /**
  197. * @brief Send a dtu_status message
  198. * @param chan MAVLink channel to send the message
  199. * @param struct The MAVLink struct to serialize
  200. */
  201. static inline void mavlink_msg_dtu_status_send_struct(mavlink_channel_t chan, const mavlink_dtu_status_t* dtu_status)
  202. {
  203. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  204. mavlink_msg_dtu_status_send(chan, dtu_status->csq, dtu_status->sn, dtu_status->imei);
  205. #else
  206. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_DTU_STATUS, (const char *)dtu_status, MAVLINK_MSG_ID_DTU_STATUS_MIN_LEN, MAVLINK_MSG_ID_DTU_STATUS_LEN, MAVLINK_MSG_ID_DTU_STATUS_CRC);
  207. #endif
  208. }
  209. #if MAVLINK_MSG_ID_DTU_STATUS_LEN <= MAVLINK_MAX_PAYLOAD_LEN
  210. /*
  211. This variant of _send() can be used to save stack space by re-using
  212. memory from the receive buffer. The caller provides a
  213. mavlink_message_t which is the size of a full mavlink message. This
  214. is usually the receive buffer for the channel, and allows a reply to an
  215. incoming message with minimum stack space usage.
  216. */
  217. static inline void mavlink_msg_dtu_status_send_buf(mavlink_message_t *msgbuf, mavlink_channel_t chan, uint8_t csq, const uint8_t *sn, const uint8_t *imei)
  218. {
  219. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  220. char *buf = (char *)msgbuf;
  221. _mav_put_uint8_t(buf, 0, csq);
  222. _mav_put_uint8_t_array(buf, 1, sn, 32);
  223. _mav_put_uint8_t_array(buf, 33, imei, 32);
  224. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_DTU_STATUS, buf, MAVLINK_MSG_ID_DTU_STATUS_MIN_LEN, MAVLINK_MSG_ID_DTU_STATUS_LEN, MAVLINK_MSG_ID_DTU_STATUS_CRC);
  225. #else
  226. mavlink_dtu_status_t *packet = (mavlink_dtu_status_t *)msgbuf;
  227. packet->csq = csq;
  228. mav_array_memcpy(packet->sn, sn, sizeof(uint8_t)*32);
  229. mav_array_memcpy(packet->imei, imei, sizeof(uint8_t)*32);
  230. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_DTU_STATUS, (const char *)packet, MAVLINK_MSG_ID_DTU_STATUS_MIN_LEN, MAVLINK_MSG_ID_DTU_STATUS_LEN, MAVLINK_MSG_ID_DTU_STATUS_CRC);
  231. #endif
  232. }
  233. #endif
  234. #endif
  235. // MESSAGE DTU_STATUS UNPACKING
  236. /**
  237. * @brief Get field csq from dtu_status message
  238. *
  239. * @return Receive signal strength indicator,Values: [0-254]
  240. */
  241. static inline uint8_t mavlink_msg_dtu_status_get_csq(const mavlink_message_t* msg)
  242. {
  243. return _MAV_RETURN_uint8_t(msg, 0);
  244. }
  245. /**
  246. * @brief Get field sn from dtu_status message
  247. *
  248. * @return Sim Card sn code.
  249. */
  250. static inline uint16_t mavlink_msg_dtu_status_get_sn(const mavlink_message_t* msg, uint8_t *sn)
  251. {
  252. return _MAV_RETURN_uint8_t_array(msg, sn, 32, 1);
  253. }
  254. /**
  255. * @brief Get field imei from dtu_status message
  256. *
  257. * @return Dtu board imei code.
  258. */
  259. static inline uint16_t mavlink_msg_dtu_status_get_imei(const mavlink_message_t* msg, uint8_t *imei)
  260. {
  261. return _MAV_RETURN_uint8_t_array(msg, imei, 32, 33);
  262. }
  263. /**
  264. * @brief Decode a dtu_status message into a struct
  265. *
  266. * @param msg The message to decode
  267. * @param dtu_status C-struct to decode the message contents into
  268. */
  269. static inline void mavlink_msg_dtu_status_decode(const mavlink_message_t* msg, mavlink_dtu_status_t* dtu_status)
  270. {
  271. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  272. dtu_status->csq = mavlink_msg_dtu_status_get_csq(msg);
  273. mavlink_msg_dtu_status_get_sn(msg, dtu_status->sn);
  274. mavlink_msg_dtu_status_get_imei(msg, dtu_status->imei);
  275. #else
  276. uint8_t len = msg->len < MAVLINK_MSG_ID_DTU_STATUS_LEN? msg->len : MAVLINK_MSG_ID_DTU_STATUS_LEN;
  277. memset(dtu_status, 0, MAVLINK_MSG_ID_DTU_STATUS_LEN);
  278. memcpy(dtu_status, _MAV_PAYLOAD(msg), len);
  279. #endif
  280. }