mavlink_msg_gps_rtcm_data.h 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255
  1. #pragma once
  2. // MESSAGE GPS_RTCM_DATA PACKING
  3. #define MAVLINK_MSG_ID_GPS_RTCM_DATA 233
  4. typedef struct __mavlink_gps_rtcm_data_t {
  5. uint8_t flags; /*< LSB: 1 means message is fragmented, next 2 bits are the fragment ID, the remaining 5 bits are used for the sequence ID. Messages are only to be flushed to the GPS when the entire message has been reconstructed on the autopilot. The fragment ID specifies which order the fragments should be assembled into a buffer, while the sequence ID is used to detect a mismatch between different buffers. The buffer is considered fully reconstructed when either all 4 fragments are present, or all the fragments before the first fragment with a non full payload is received. This management is used to ensure that normal GPS operation doesn't corrupt RTCM data, and to recover from a unreliable transport delivery order.*/
  6. uint8_t len; /*< [bytes] data length*/
  7. uint8_t data[180]; /*< RTCM message (may be fragmented)*/
  8. } mavlink_gps_rtcm_data_t;
  9. #define MAVLINK_MSG_ID_GPS_RTCM_DATA_LEN 182
  10. #define MAVLINK_MSG_ID_GPS_RTCM_DATA_MIN_LEN 182
  11. #define MAVLINK_MSG_ID_233_LEN 182
  12. #define MAVLINK_MSG_ID_233_MIN_LEN 182
  13. #define MAVLINK_MSG_ID_GPS_RTCM_DATA_CRC 35
  14. #define MAVLINK_MSG_ID_233_CRC 35
  15. #define MAVLINK_MSG_GPS_RTCM_DATA_FIELD_DATA_LEN 180
  16. #if MAVLINK_COMMAND_24BIT
  17. #define MAVLINK_MESSAGE_INFO_GPS_RTCM_DATA { \
  18. 233, \
  19. "GPS_RTCM_DATA", \
  20. 3, \
  21. { { "flags", NULL, MAVLINK_TYPE_UINT8_T, 0, 0, offsetof(mavlink_gps_rtcm_data_t, flags) }, \
  22. { "len", NULL, MAVLINK_TYPE_UINT8_T, 0, 1, offsetof(mavlink_gps_rtcm_data_t, len) }, \
  23. { "data", NULL, MAVLINK_TYPE_UINT8_T, 180, 2, offsetof(mavlink_gps_rtcm_data_t, data) }, \
  24. } \
  25. }
  26. #else
  27. #define MAVLINK_MESSAGE_INFO_GPS_RTCM_DATA { \
  28. "GPS_RTCM_DATA", \
  29. 3, \
  30. { { "flags", NULL, MAVLINK_TYPE_UINT8_T, 0, 0, offsetof(mavlink_gps_rtcm_data_t, flags) }, \
  31. { "len", NULL, MAVLINK_TYPE_UINT8_T, 0, 1, offsetof(mavlink_gps_rtcm_data_t, len) }, \
  32. { "data", NULL, MAVLINK_TYPE_UINT8_T, 180, 2, offsetof(mavlink_gps_rtcm_data_t, data) }, \
  33. } \
  34. }
  35. #endif
  36. /**
  37. * @brief Pack a gps_rtcm_data message
  38. * @param system_id ID of this system
  39. * @param component_id ID of this component (e.g. 200 for IMU)
  40. * @param msg The MAVLink message to compress the data into
  41. *
  42. * @param flags LSB: 1 means message is fragmented, next 2 bits are the fragment ID, the remaining 5 bits are used for the sequence ID. Messages are only to be flushed to the GPS when the entire message has been reconstructed on the autopilot. The fragment ID specifies which order the fragments should be assembled into a buffer, while the sequence ID is used to detect a mismatch between different buffers. The buffer is considered fully reconstructed when either all 4 fragments are present, or all the fragments before the first fragment with a non full payload is received. This management is used to ensure that normal GPS operation doesn't corrupt RTCM data, and to recover from a unreliable transport delivery order.
  43. * @param len [bytes] data length
  44. * @param data RTCM message (may be fragmented)
  45. * @return length of the message in bytes (excluding serial stream start sign)
  46. */
  47. static inline uint16_t mavlink_msg_gps_rtcm_data_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
  48. uint8_t flags, uint8_t len, const uint8_t *data)
  49. {
  50. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  51. char buf[MAVLINK_MSG_ID_GPS_RTCM_DATA_LEN];
  52. _mav_put_uint8_t(buf, 0, flags);
  53. _mav_put_uint8_t(buf, 1, len);
  54. _mav_put_uint8_t_array(buf, 2, data, 180);
  55. memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_GPS_RTCM_DATA_LEN);
  56. #else
  57. mavlink_gps_rtcm_data_t packet;
  58. packet.flags = flags;
  59. packet.len = len;
  60. mav_array_memcpy(packet.data, data, sizeof(uint8_t)*180);
  61. memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_GPS_RTCM_DATA_LEN);
  62. #endif
  63. msg->msgid = MAVLINK_MSG_ID_GPS_RTCM_DATA;
  64. return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_GPS_RTCM_DATA_MIN_LEN, MAVLINK_MSG_ID_GPS_RTCM_DATA_LEN, MAVLINK_MSG_ID_GPS_RTCM_DATA_CRC);
  65. }
  66. /**
  67. * @brief Pack a gps_rtcm_data message on a channel
  68. * @param system_id ID of this system
  69. * @param component_id ID of this component (e.g. 200 for IMU)
  70. * @param chan The MAVLink channel this message will be sent over
  71. * @param msg The MAVLink message to compress the data into
  72. * @param flags LSB: 1 means message is fragmented, next 2 bits are the fragment ID, the remaining 5 bits are used for the sequence ID. Messages are only to be flushed to the GPS when the entire message has been reconstructed on the autopilot. The fragment ID specifies which order the fragments should be assembled into a buffer, while the sequence ID is used to detect a mismatch between different buffers. The buffer is considered fully reconstructed when either all 4 fragments are present, or all the fragments before the first fragment with a non full payload is received. This management is used to ensure that normal GPS operation doesn't corrupt RTCM data, and to recover from a unreliable transport delivery order.
  73. * @param len [bytes] data length
  74. * @param data RTCM message (may be fragmented)
  75. * @return length of the message in bytes (excluding serial stream start sign)
  76. */
  77. static inline uint16_t mavlink_msg_gps_rtcm_data_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
  78. mavlink_message_t* msg,
  79. uint8_t flags,uint8_t len,const uint8_t *data)
  80. {
  81. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  82. char buf[MAVLINK_MSG_ID_GPS_RTCM_DATA_LEN];
  83. _mav_put_uint8_t(buf, 0, flags);
  84. _mav_put_uint8_t(buf, 1, len);
  85. _mav_put_uint8_t_array(buf, 2, data, 180);
  86. memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_GPS_RTCM_DATA_LEN);
  87. #else
  88. mavlink_gps_rtcm_data_t packet;
  89. packet.flags = flags;
  90. packet.len = len;
  91. mav_array_memcpy(packet.data, data, sizeof(uint8_t)*180);
  92. memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_GPS_RTCM_DATA_LEN);
  93. #endif
  94. msg->msgid = MAVLINK_MSG_ID_GPS_RTCM_DATA;
  95. return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_GPS_RTCM_DATA_MIN_LEN, MAVLINK_MSG_ID_GPS_RTCM_DATA_LEN, MAVLINK_MSG_ID_GPS_RTCM_DATA_CRC);
  96. }
  97. /**
  98. * @brief Encode a gps_rtcm_data struct
  99. *
  100. * @param system_id ID of this system
  101. * @param component_id ID of this component (e.g. 200 for IMU)
  102. * @param msg The MAVLink message to compress the data into
  103. * @param gps_rtcm_data C-struct to read the message contents from
  104. */
  105. static inline uint16_t mavlink_msg_gps_rtcm_data_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_gps_rtcm_data_t* gps_rtcm_data)
  106. {
  107. return mavlink_msg_gps_rtcm_data_pack(system_id, component_id, msg, gps_rtcm_data->flags, gps_rtcm_data->len, gps_rtcm_data->data);
  108. }
  109. /**
  110. * @brief Encode a gps_rtcm_data struct on a channel
  111. *
  112. * @param system_id ID of this system
  113. * @param component_id ID of this component (e.g. 200 for IMU)
  114. * @param chan The MAVLink channel this message will be sent over
  115. * @param msg The MAVLink message to compress the data into
  116. * @param gps_rtcm_data C-struct to read the message contents from
  117. */
  118. static inline uint16_t mavlink_msg_gps_rtcm_data_encode_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, const mavlink_gps_rtcm_data_t* gps_rtcm_data)
  119. {
  120. return mavlink_msg_gps_rtcm_data_pack_chan(system_id, component_id, chan, msg, gps_rtcm_data->flags, gps_rtcm_data->len, gps_rtcm_data->data);
  121. }
  122. /**
  123. * @brief Send a gps_rtcm_data message
  124. * @param chan MAVLink channel to send the message
  125. *
  126. * @param flags LSB: 1 means message is fragmented, next 2 bits are the fragment ID, the remaining 5 bits are used for the sequence ID. Messages are only to be flushed to the GPS when the entire message has been reconstructed on the autopilot. The fragment ID specifies which order the fragments should be assembled into a buffer, while the sequence ID is used to detect a mismatch between different buffers. The buffer is considered fully reconstructed when either all 4 fragments are present, or all the fragments before the first fragment with a non full payload is received. This management is used to ensure that normal GPS operation doesn't corrupt RTCM data, and to recover from a unreliable transport delivery order.
  127. * @param len [bytes] data length
  128. * @param data RTCM message (may be fragmented)
  129. */
  130. #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
  131. static inline void mavlink_msg_gps_rtcm_data_send(mavlink_channel_t chan, uint8_t flags, uint8_t len, const uint8_t *data)
  132. {
  133. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  134. char buf[MAVLINK_MSG_ID_GPS_RTCM_DATA_LEN];
  135. _mav_put_uint8_t(buf, 0, flags);
  136. _mav_put_uint8_t(buf, 1, len);
  137. _mav_put_uint8_t_array(buf, 2, data, 180);
  138. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_GPS_RTCM_DATA, buf, MAVLINK_MSG_ID_GPS_RTCM_DATA_MIN_LEN, MAVLINK_MSG_ID_GPS_RTCM_DATA_LEN, MAVLINK_MSG_ID_GPS_RTCM_DATA_CRC);
  139. #else
  140. mavlink_gps_rtcm_data_t packet;
  141. packet.flags = flags;
  142. packet.len = len;
  143. mav_array_memcpy(packet.data, data, sizeof(uint8_t)*180);
  144. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_GPS_RTCM_DATA, (const char *)&packet, MAVLINK_MSG_ID_GPS_RTCM_DATA_MIN_LEN, MAVLINK_MSG_ID_GPS_RTCM_DATA_LEN, MAVLINK_MSG_ID_GPS_RTCM_DATA_CRC);
  145. #endif
  146. }
  147. /**
  148. * @brief Send a gps_rtcm_data message
  149. * @param chan MAVLink channel to send the message
  150. * @param struct The MAVLink struct to serialize
  151. */
  152. static inline void mavlink_msg_gps_rtcm_data_send_struct(mavlink_channel_t chan, const mavlink_gps_rtcm_data_t* gps_rtcm_data)
  153. {
  154. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  155. mavlink_msg_gps_rtcm_data_send(chan, gps_rtcm_data->flags, gps_rtcm_data->len, gps_rtcm_data->data);
  156. #else
  157. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_GPS_RTCM_DATA, (const char *)gps_rtcm_data, MAVLINK_MSG_ID_GPS_RTCM_DATA_MIN_LEN, MAVLINK_MSG_ID_GPS_RTCM_DATA_LEN, MAVLINK_MSG_ID_GPS_RTCM_DATA_CRC);
  158. #endif
  159. }
  160. #if MAVLINK_MSG_ID_GPS_RTCM_DATA_LEN <= MAVLINK_MAX_PAYLOAD_LEN
  161. /*
  162. This variant of _send() can be used to save stack space by re-using
  163. memory from the receive buffer. The caller provides a
  164. mavlink_message_t which is the size of a full mavlink message. This
  165. is usually the receive buffer for the channel, and allows a reply to an
  166. incoming message with minimum stack space usage.
  167. */
  168. static inline void mavlink_msg_gps_rtcm_data_send_buf(mavlink_message_t *msgbuf, mavlink_channel_t chan, uint8_t flags, uint8_t len, const uint8_t *data)
  169. {
  170. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  171. char *buf = (char *)msgbuf;
  172. _mav_put_uint8_t(buf, 0, flags);
  173. _mav_put_uint8_t(buf, 1, len);
  174. _mav_put_uint8_t_array(buf, 2, data, 180);
  175. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_GPS_RTCM_DATA, buf, MAVLINK_MSG_ID_GPS_RTCM_DATA_MIN_LEN, MAVLINK_MSG_ID_GPS_RTCM_DATA_LEN, MAVLINK_MSG_ID_GPS_RTCM_DATA_CRC);
  176. #else
  177. mavlink_gps_rtcm_data_t *packet = (mavlink_gps_rtcm_data_t *)msgbuf;
  178. packet->flags = flags;
  179. packet->len = len;
  180. mav_array_memcpy(packet->data, data, sizeof(uint8_t)*180);
  181. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_GPS_RTCM_DATA, (const char *)packet, MAVLINK_MSG_ID_GPS_RTCM_DATA_MIN_LEN, MAVLINK_MSG_ID_GPS_RTCM_DATA_LEN, MAVLINK_MSG_ID_GPS_RTCM_DATA_CRC);
  182. #endif
  183. }
  184. #endif
  185. #endif
  186. // MESSAGE GPS_RTCM_DATA UNPACKING
  187. /**
  188. * @brief Get field flags from gps_rtcm_data message
  189. *
  190. * @return LSB: 1 means message is fragmented, next 2 bits are the fragment ID, the remaining 5 bits are used for the sequence ID. Messages are only to be flushed to the GPS when the entire message has been reconstructed on the autopilot. The fragment ID specifies which order the fragments should be assembled into a buffer, while the sequence ID is used to detect a mismatch between different buffers. The buffer is considered fully reconstructed when either all 4 fragments are present, or all the fragments before the first fragment with a non full payload is received. This management is used to ensure that normal GPS operation doesn't corrupt RTCM data, and to recover from a unreliable transport delivery order.
  191. */
  192. static inline uint8_t mavlink_msg_gps_rtcm_data_get_flags(const mavlink_message_t* msg)
  193. {
  194. return _MAV_RETURN_uint8_t(msg, 0);
  195. }
  196. /**
  197. * @brief Get field len from gps_rtcm_data message
  198. *
  199. * @return [bytes] data length
  200. */
  201. static inline uint8_t mavlink_msg_gps_rtcm_data_get_len(const mavlink_message_t* msg)
  202. {
  203. return _MAV_RETURN_uint8_t(msg, 1);
  204. }
  205. /**
  206. * @brief Get field data from gps_rtcm_data message
  207. *
  208. * @return RTCM message (may be fragmented)
  209. */
  210. static inline uint16_t mavlink_msg_gps_rtcm_data_get_data(const mavlink_message_t* msg, uint8_t *data)
  211. {
  212. return _MAV_RETURN_uint8_t_array(msg, data, 180, 2);
  213. }
  214. /**
  215. * @brief Decode a gps_rtcm_data message into a struct
  216. *
  217. * @param msg The message to decode
  218. * @param gps_rtcm_data C-struct to decode the message contents into
  219. */
  220. static inline void mavlink_msg_gps_rtcm_data_decode(const mavlink_message_t* msg, mavlink_gps_rtcm_data_t* gps_rtcm_data)
  221. {
  222. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  223. gps_rtcm_data->flags = mavlink_msg_gps_rtcm_data_get_flags(msg);
  224. gps_rtcm_data->len = mavlink_msg_gps_rtcm_data_get_len(msg);
  225. mavlink_msg_gps_rtcm_data_get_data(msg, gps_rtcm_data->data);
  226. #else
  227. uint8_t len = msg->len < MAVLINK_MSG_ID_GPS_RTCM_DATA_LEN? msg->len : MAVLINK_MSG_ID_GPS_RTCM_DATA_LEN;
  228. memset(gps_rtcm_data, 0, MAVLINK_MSG_ID_GPS_RTCM_DATA_LEN);
  229. memcpy(gps_rtcm_data, _MAV_PAYLOAD(msg), len);
  230. #endif
  231. }