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.

363 lines
16 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. #pragma once
  2. // MESSAGE STATUS_GPS PACKING
  3. #define MAVLINK_MSG_ID_STATUS_GPS 194
  4. MAVPACKED(
  5. typedef struct __mavlink_status_gps_t {
  6. float magVar; /*< [deg] Magnetic variation*/
  7. uint16_t csFails; /*< Number of times checksum has failed*/
  8. uint8_t gpsQuality; /*< The quality indicator, 0=fix not available or invalid, 1=GPS fix, 2=C/A differential GPS, 6=Dead reckoning mode, 7=Manual input mode (fixed position), 8=Simulator mode, 9= WAAS a*/
  9. uint8_t msgsType; /*< Indicates if GN, GL or GP messages are being received*/
  10. uint8_t posStatus; /*< A = data valid, V = data invalid*/
  11. int8_t magDir; /*< Magnetic variation direction E/W. Easterly variation (E) subtracts from True course and Westerly variation (W) adds to True course*/
  12. uint8_t modeInd; /*< Positioning system mode indicator. A - Autonomous;D-Differential; E-Estimated (dead reckoning) mode;M-Manual input; N-Data not valid*/
  13. }) mavlink_status_gps_t;
  14. #define MAVLINK_MSG_ID_STATUS_GPS_LEN 11
  15. #define MAVLINK_MSG_ID_STATUS_GPS_MIN_LEN 11
  16. #define MAVLINK_MSG_ID_194_LEN 11
  17. #define MAVLINK_MSG_ID_194_MIN_LEN 11
  18. #define MAVLINK_MSG_ID_STATUS_GPS_CRC 51
  19. #define MAVLINK_MSG_ID_194_CRC 51
  20. #if MAVLINK_COMMAND_24BIT
  21. #define MAVLINK_MESSAGE_INFO_STATUS_GPS { \
  22. 194, \
  23. "STATUS_GPS", \
  24. 7, \
  25. { { "csFails", NULL, MAVLINK_TYPE_UINT16_T, 0, 4, offsetof(mavlink_status_gps_t, csFails) }, \
  26. { "gpsQuality", NULL, MAVLINK_TYPE_UINT8_T, 0, 6, offsetof(mavlink_status_gps_t, gpsQuality) }, \
  27. { "msgsType", NULL, MAVLINK_TYPE_UINT8_T, 0, 7, offsetof(mavlink_status_gps_t, msgsType) }, \
  28. { "posStatus", NULL, MAVLINK_TYPE_UINT8_T, 0, 8, offsetof(mavlink_status_gps_t, posStatus) }, \
  29. { "magVar", NULL, MAVLINK_TYPE_FLOAT, 0, 0, offsetof(mavlink_status_gps_t, magVar) }, \
  30. { "magDir", NULL, MAVLINK_TYPE_INT8_T, 0, 9, offsetof(mavlink_status_gps_t, magDir) }, \
  31. { "modeInd", NULL, MAVLINK_TYPE_UINT8_T, 0, 10, offsetof(mavlink_status_gps_t, modeInd) }, \
  32. } \
  33. }
  34. #else
  35. #define MAVLINK_MESSAGE_INFO_STATUS_GPS { \
  36. "STATUS_GPS", \
  37. 7, \
  38. { { "csFails", NULL, MAVLINK_TYPE_UINT16_T, 0, 4, offsetof(mavlink_status_gps_t, csFails) }, \
  39. { "gpsQuality", NULL, MAVLINK_TYPE_UINT8_T, 0, 6, offsetof(mavlink_status_gps_t, gpsQuality) }, \
  40. { "msgsType", NULL, MAVLINK_TYPE_UINT8_T, 0, 7, offsetof(mavlink_status_gps_t, msgsType) }, \
  41. { "posStatus", NULL, MAVLINK_TYPE_UINT8_T, 0, 8, offsetof(mavlink_status_gps_t, posStatus) }, \
  42. { "magVar", NULL, MAVLINK_TYPE_FLOAT, 0, 0, offsetof(mavlink_status_gps_t, magVar) }, \
  43. { "magDir", NULL, MAVLINK_TYPE_INT8_T, 0, 9, offsetof(mavlink_status_gps_t, magDir) }, \
  44. { "modeInd", NULL, MAVLINK_TYPE_UINT8_T, 0, 10, offsetof(mavlink_status_gps_t, modeInd) }, \
  45. } \
  46. }
  47. #endif
  48. /**
  49. * @brief Pack a status_gps message
  50. * @param system_id ID of this system
  51. * @param component_id ID of this component (e.g. 200 for IMU)
  52. * @param msg The MAVLink message to compress the data into
  53. *
  54. * @param csFails Number of times checksum has failed
  55. * @param gpsQuality The quality indicator, 0=fix not available or invalid, 1=GPS fix, 2=C/A differential GPS, 6=Dead reckoning mode, 7=Manual input mode (fixed position), 8=Simulator mode, 9= WAAS a
  56. * @param msgsType Indicates if GN, GL or GP messages are being received
  57. * @param posStatus A = data valid, V = data invalid
  58. * @param magVar [deg] Magnetic variation
  59. * @param magDir Magnetic variation direction E/W. Easterly variation (E) subtracts from True course and Westerly variation (W) adds to True course
  60. * @param modeInd Positioning system mode indicator. A - Autonomous;D-Differential; E-Estimated (dead reckoning) mode;M-Manual input; N-Data not valid
  61. * @return length of the message in bytes (excluding serial stream start sign)
  62. */
  63. static inline uint16_t mavlink_msg_status_gps_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
  64. uint16_t csFails, uint8_t gpsQuality, uint8_t msgsType, uint8_t posStatus, float magVar, int8_t magDir, uint8_t modeInd)
  65. {
  66. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  67. char buf[MAVLINK_MSG_ID_STATUS_GPS_LEN];
  68. _mav_put_float(buf, 0, magVar);
  69. _mav_put_uint16_t(buf, 4, csFails);
  70. _mav_put_uint8_t(buf, 6, gpsQuality);
  71. _mav_put_uint8_t(buf, 7, msgsType);
  72. _mav_put_uint8_t(buf, 8, posStatus);
  73. _mav_put_int8_t(buf, 9, magDir);
  74. _mav_put_uint8_t(buf, 10, modeInd);
  75. memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_STATUS_GPS_LEN);
  76. #else
  77. mavlink_status_gps_t packet;
  78. packet.magVar = magVar;
  79. packet.csFails = csFails;
  80. packet.gpsQuality = gpsQuality;
  81. packet.msgsType = msgsType;
  82. packet.posStatus = posStatus;
  83. packet.magDir = magDir;
  84. packet.modeInd = modeInd;
  85. memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_STATUS_GPS_LEN);
  86. #endif
  87. msg->msgid = MAVLINK_MSG_ID_STATUS_GPS;
  88. return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_STATUS_GPS_MIN_LEN, MAVLINK_MSG_ID_STATUS_GPS_LEN, MAVLINK_MSG_ID_STATUS_GPS_CRC);
  89. }
  90. /**
  91. * @brief Pack a status_gps message on a channel
  92. * @param system_id ID of this system
  93. * @param component_id ID of this component (e.g. 200 for IMU)
  94. * @param chan The MAVLink channel this message will be sent over
  95. * @param msg The MAVLink message to compress the data into
  96. * @param csFails Number of times checksum has failed
  97. * @param gpsQuality The quality indicator, 0=fix not available or invalid, 1=GPS fix, 2=C/A differential GPS, 6=Dead reckoning mode, 7=Manual input mode (fixed position), 8=Simulator mode, 9= WAAS a
  98. * @param msgsType Indicates if GN, GL or GP messages are being received
  99. * @param posStatus A = data valid, V = data invalid
  100. * @param magVar [deg] Magnetic variation
  101. * @param magDir Magnetic variation direction E/W. Easterly variation (E) subtracts from True course and Westerly variation (W) adds to True course
  102. * @param modeInd Positioning system mode indicator. A - Autonomous;D-Differential; E-Estimated (dead reckoning) mode;M-Manual input; N-Data not valid
  103. * @return length of the message in bytes (excluding serial stream start sign)
  104. */
  105. static inline uint16_t mavlink_msg_status_gps_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
  106. mavlink_message_t* msg,
  107. uint16_t csFails,uint8_t gpsQuality,uint8_t msgsType,uint8_t posStatus,float magVar,int8_t magDir,uint8_t modeInd)
  108. {
  109. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  110. char buf[MAVLINK_MSG_ID_STATUS_GPS_LEN];
  111. _mav_put_float(buf, 0, magVar);
  112. _mav_put_uint16_t(buf, 4, csFails);
  113. _mav_put_uint8_t(buf, 6, gpsQuality);
  114. _mav_put_uint8_t(buf, 7, msgsType);
  115. _mav_put_uint8_t(buf, 8, posStatus);
  116. _mav_put_int8_t(buf, 9, magDir);
  117. _mav_put_uint8_t(buf, 10, modeInd);
  118. memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_STATUS_GPS_LEN);
  119. #else
  120. mavlink_status_gps_t packet;
  121. packet.magVar = magVar;
  122. packet.csFails = csFails;
  123. packet.gpsQuality = gpsQuality;
  124. packet.msgsType = msgsType;
  125. packet.posStatus = posStatus;
  126. packet.magDir = magDir;
  127. packet.modeInd = modeInd;
  128. memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_STATUS_GPS_LEN);
  129. #endif
  130. msg->msgid = MAVLINK_MSG_ID_STATUS_GPS;
  131. return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_STATUS_GPS_MIN_LEN, MAVLINK_MSG_ID_STATUS_GPS_LEN, MAVLINK_MSG_ID_STATUS_GPS_CRC);
  132. }
  133. /**
  134. * @brief Encode a status_gps 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 status_gps C-struct to read the message contents from
  140. */
  141. static inline uint16_t mavlink_msg_status_gps_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_status_gps_t* status_gps)
  142. {
  143. return mavlink_msg_status_gps_pack(system_id, component_id, msg, status_gps->csFails, status_gps->gpsQuality, status_gps->msgsType, status_gps->posStatus, status_gps->magVar, status_gps->magDir, status_gps->modeInd);
  144. }
  145. /**
  146. * @brief Encode a status_gps 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 status_gps C-struct to read the message contents from
  153. */
  154. static inline uint16_t mavlink_msg_status_gps_encode_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, const mavlink_status_gps_t* status_gps)
  155. {
  156. return mavlink_msg_status_gps_pack_chan(system_id, component_id, chan, msg, status_gps->csFails, status_gps->gpsQuality, status_gps->msgsType, status_gps->posStatus, status_gps->magVar, status_gps->magDir, status_gps->modeInd);
  157. }
  158. /**
  159. * @brief Send a status_gps message
  160. * @param chan MAVLink channel to send the message
  161. *
  162. * @param csFails Number of times checksum has failed
  163. * @param gpsQuality The quality indicator, 0=fix not available or invalid, 1=GPS fix, 2=C/A differential GPS, 6=Dead reckoning mode, 7=Manual input mode (fixed position), 8=Simulator mode, 9= WAAS a
  164. * @param msgsType Indicates if GN, GL or GP messages are being received
  165. * @param posStatus A = data valid, V = data invalid
  166. * @param magVar [deg] Magnetic variation
  167. * @param magDir Magnetic variation direction E/W. Easterly variation (E) subtracts from True course and Westerly variation (W) adds to True course
  168. * @param modeInd Positioning system mode indicator. A - Autonomous;D-Differential; E-Estimated (dead reckoning) mode;M-Manual input; N-Data not valid
  169. */
  170. #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
  171. static inline void mavlink_msg_status_gps_send(mavlink_channel_t chan, uint16_t csFails, uint8_t gpsQuality, uint8_t msgsType, uint8_t posStatus, float magVar, int8_t magDir, uint8_t modeInd)
  172. {
  173. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  174. char buf[MAVLINK_MSG_ID_STATUS_GPS_LEN];
  175. _mav_put_float(buf, 0, magVar);
  176. _mav_put_uint16_t(buf, 4, csFails);
  177. _mav_put_uint8_t(buf, 6, gpsQuality);
  178. _mav_put_uint8_t(buf, 7, msgsType);
  179. _mav_put_uint8_t(buf, 8, posStatus);
  180. _mav_put_int8_t(buf, 9, magDir);
  181. _mav_put_uint8_t(buf, 10, modeInd);
  182. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_STATUS_GPS, buf, MAVLINK_MSG_ID_STATUS_GPS_MIN_LEN, MAVLINK_MSG_ID_STATUS_GPS_LEN, MAVLINK_MSG_ID_STATUS_GPS_CRC);
  183. #else
  184. mavlink_status_gps_t packet;
  185. packet.magVar = magVar;
  186. packet.csFails = csFails;
  187. packet.gpsQuality = gpsQuality;
  188. packet.msgsType = msgsType;
  189. packet.posStatus = posStatus;
  190. packet.magDir = magDir;
  191. packet.modeInd = modeInd;
  192. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_STATUS_GPS, (const char *)&packet, MAVLINK_MSG_ID_STATUS_GPS_MIN_LEN, MAVLINK_MSG_ID_STATUS_GPS_LEN, MAVLINK_MSG_ID_STATUS_GPS_CRC);
  193. #endif
  194. }
  195. /**
  196. * @brief Send a status_gps message
  197. * @param chan MAVLink channel to send the message
  198. * @param struct The MAVLink struct to serialize
  199. */
  200. static inline void mavlink_msg_status_gps_send_struct(mavlink_channel_t chan, const mavlink_status_gps_t* status_gps)
  201. {
  202. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  203. mavlink_msg_status_gps_send(chan, status_gps->csFails, status_gps->gpsQuality, status_gps->msgsType, status_gps->posStatus, status_gps->magVar, status_gps->magDir, status_gps->modeInd);
  204. #else
  205. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_STATUS_GPS, (const char *)status_gps, MAVLINK_MSG_ID_STATUS_GPS_MIN_LEN, MAVLINK_MSG_ID_STATUS_GPS_LEN, MAVLINK_MSG_ID_STATUS_GPS_CRC);
  206. #endif
  207. }
  208. #if MAVLINK_MSG_ID_STATUS_GPS_LEN <= MAVLINK_MAX_PAYLOAD_LEN
  209. /*
  210. This varient of _send() can be used to save stack space by re-using
  211. memory from the receive buffer. The caller provides a
  212. mavlink_message_t which is the size of a full mavlink message. This
  213. is usually the receive buffer for the channel, and allows a reply to an
  214. incoming message with minimum stack space usage.
  215. */
  216. static inline void mavlink_msg_status_gps_send_buf(mavlink_message_t *msgbuf, mavlink_channel_t chan, uint16_t csFails, uint8_t gpsQuality, uint8_t msgsType, uint8_t posStatus, float magVar, int8_t magDir, uint8_t modeInd)
  217. {
  218. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  219. char *buf = (char *)msgbuf;
  220. _mav_put_float(buf, 0, magVar);
  221. _mav_put_uint16_t(buf, 4, csFails);
  222. _mav_put_uint8_t(buf, 6, gpsQuality);
  223. _mav_put_uint8_t(buf, 7, msgsType);
  224. _mav_put_uint8_t(buf, 8, posStatus);
  225. _mav_put_int8_t(buf, 9, magDir);
  226. _mav_put_uint8_t(buf, 10, modeInd);
  227. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_STATUS_GPS, buf, MAVLINK_MSG_ID_STATUS_GPS_MIN_LEN, MAVLINK_MSG_ID_STATUS_GPS_LEN, MAVLINK_MSG_ID_STATUS_GPS_CRC);
  228. #else
  229. mavlink_status_gps_t *packet = (mavlink_status_gps_t *)msgbuf;
  230. packet->magVar = magVar;
  231. packet->csFails = csFails;
  232. packet->gpsQuality = gpsQuality;
  233. packet->msgsType = msgsType;
  234. packet->posStatus = posStatus;
  235. packet->magDir = magDir;
  236. packet->modeInd = modeInd;
  237. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_STATUS_GPS, (const char *)packet, MAVLINK_MSG_ID_STATUS_GPS_MIN_LEN, MAVLINK_MSG_ID_STATUS_GPS_LEN, MAVLINK_MSG_ID_STATUS_GPS_CRC);
  238. #endif
  239. }
  240. #endif
  241. #endif
  242. // MESSAGE STATUS_GPS UNPACKING
  243. /**
  244. * @brief Get field csFails from status_gps message
  245. *
  246. * @return Number of times checksum has failed
  247. */
  248. static inline uint16_t mavlink_msg_status_gps_get_csFails(const mavlink_message_t* msg)
  249. {
  250. return _MAV_RETURN_uint16_t(msg, 4);
  251. }
  252. /**
  253. * @brief Get field gpsQuality from status_gps message
  254. *
  255. * @return The quality indicator, 0=fix not available or invalid, 1=GPS fix, 2=C/A differential GPS, 6=Dead reckoning mode, 7=Manual input mode (fixed position), 8=Simulator mode, 9= WAAS a
  256. */
  257. static inline uint8_t mavlink_msg_status_gps_get_gpsQuality(const mavlink_message_t* msg)
  258. {
  259. return _MAV_RETURN_uint8_t(msg, 6);
  260. }
  261. /**
  262. * @brief Get field msgsType from status_gps message
  263. *
  264. * @return Indicates if GN, GL or GP messages are being received
  265. */
  266. static inline uint8_t mavlink_msg_status_gps_get_msgsType(const mavlink_message_t* msg)
  267. {
  268. return _MAV_RETURN_uint8_t(msg, 7);
  269. }
  270. /**
  271. * @brief Get field posStatus from status_gps message
  272. *
  273. * @return A = data valid, V = data invalid
  274. */
  275. static inline uint8_t mavlink_msg_status_gps_get_posStatus(const mavlink_message_t* msg)
  276. {
  277. return _MAV_RETURN_uint8_t(msg, 8);
  278. }
  279. /**
  280. * @brief Get field magVar from status_gps message
  281. *
  282. * @return [deg] Magnetic variation
  283. */
  284. static inline float mavlink_msg_status_gps_get_magVar(const mavlink_message_t* msg)
  285. {
  286. return _MAV_RETURN_float(msg, 0);
  287. }
  288. /**
  289. * @brief Get field magDir from status_gps message
  290. *
  291. * @return Magnetic variation direction E/W. Easterly variation (E) subtracts from True course and Westerly variation (W) adds to True course
  292. */
  293. static inline int8_t mavlink_msg_status_gps_get_magDir(const mavlink_message_t* msg)
  294. {
  295. return _MAV_RETURN_int8_t(msg, 9);
  296. }
  297. /**
  298. * @brief Get field modeInd from status_gps message
  299. *
  300. * @return Positioning system mode indicator. A - Autonomous;D-Differential; E-Estimated (dead reckoning) mode;M-Manual input; N-Data not valid
  301. */
  302. static inline uint8_t mavlink_msg_status_gps_get_modeInd(const mavlink_message_t* msg)
  303. {
  304. return _MAV_RETURN_uint8_t(msg, 10);
  305. }
  306. /**
  307. * @brief Decode a status_gps message into a struct
  308. *
  309. * @param msg The message to decode
  310. * @param status_gps C-struct to decode the message contents into
  311. */
  312. static inline void mavlink_msg_status_gps_decode(const mavlink_message_t* msg, mavlink_status_gps_t* status_gps)
  313. {
  314. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  315. status_gps->magVar = mavlink_msg_status_gps_get_magVar(msg);
  316. status_gps->csFails = mavlink_msg_status_gps_get_csFails(msg);
  317. status_gps->gpsQuality = mavlink_msg_status_gps_get_gpsQuality(msg);
  318. status_gps->msgsType = mavlink_msg_status_gps_get_msgsType(msg);
  319. status_gps->posStatus = mavlink_msg_status_gps_get_posStatus(msg);
  320. status_gps->magDir = mavlink_msg_status_gps_get_magDir(msg);
  321. status_gps->modeInd = mavlink_msg_status_gps_get_modeInd(msg);
  322. #else
  323. uint8_t len = msg->len < MAVLINK_MSG_ID_STATUS_GPS_LEN? msg->len : MAVLINK_MSG_ID_STATUS_GPS_LEN;
  324. memset(status_gps, 0, MAVLINK_MSG_ID_STATUS_GPS_LEN);
  325. memcpy(status_gps, _MAV_PAYLOAD(msg), len);
  326. #endif
  327. }