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.

513 lines
22 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. #pragma once
  2. // MESSAGE HIL_GPS PACKING
  3. #define MAVLINK_MSG_ID_HIL_GPS 113
  4. MAVPACKED(
  5. typedef struct __mavlink_hil_gps_t {
  6. uint64_t time_usec; /*< [us] Timestamp (UNIX Epoch time or time since system boot). The receiving end can infer timestamp format (since 1.1.1970 or since system boot) by checking for the magnitude the number.*/
  7. int32_t lat; /*< [degE7] Latitude (WGS84)*/
  8. int32_t lon; /*< [degE7] Longitude (WGS84)*/
  9. int32_t alt; /*< [mm] Altitude (MSL). Positive for up.*/
  10. uint16_t eph; /*< [cm] GPS HDOP horizontal dilution of position. If unknown, set to: 65535*/
  11. uint16_t epv; /*< [cm] GPS VDOP vertical dilution of position. If unknown, set to: 65535*/
  12. uint16_t vel; /*< [cm/s] GPS ground speed. If unknown, set to: 65535*/
  13. int16_t vn; /*< [cm/s] GPS velocity in north direction in earth-fixed NED frame*/
  14. int16_t ve; /*< [cm/s] GPS velocity in east direction in earth-fixed NED frame*/
  15. int16_t vd; /*< [cm/s] GPS velocity in down direction in earth-fixed NED frame*/
  16. uint16_t cog; /*< [cdeg] Course over ground (NOT heading, but direction of movement), 0.0..359.99 degrees. If unknown, set to: 65535*/
  17. uint8_t fix_type; /*< 0-1: no fix, 2: 2D fix, 3: 3D fix. Some applications will not use the value of this field unless it is at least two, so always correctly fill in the fix.*/
  18. uint8_t satellites_visible; /*< Number of satellites visible. If unknown, set to 255*/
  19. }) mavlink_hil_gps_t;
  20. #define MAVLINK_MSG_ID_HIL_GPS_LEN 36
  21. #define MAVLINK_MSG_ID_HIL_GPS_MIN_LEN 36
  22. #define MAVLINK_MSG_ID_113_LEN 36
  23. #define MAVLINK_MSG_ID_113_MIN_LEN 36
  24. #define MAVLINK_MSG_ID_HIL_GPS_CRC 124
  25. #define MAVLINK_MSG_ID_113_CRC 124
  26. #if MAVLINK_COMMAND_24BIT
  27. #define MAVLINK_MESSAGE_INFO_HIL_GPS { \
  28. 113, \
  29. "HIL_GPS", \
  30. 13, \
  31. { { "time_usec", NULL, MAVLINK_TYPE_UINT64_T, 0, 0, offsetof(mavlink_hil_gps_t, time_usec) }, \
  32. { "fix_type", NULL, MAVLINK_TYPE_UINT8_T, 0, 34, offsetof(mavlink_hil_gps_t, fix_type) }, \
  33. { "lat", NULL, MAVLINK_TYPE_INT32_T, 0, 8, offsetof(mavlink_hil_gps_t, lat) }, \
  34. { "lon", NULL, MAVLINK_TYPE_INT32_T, 0, 12, offsetof(mavlink_hil_gps_t, lon) }, \
  35. { "alt", NULL, MAVLINK_TYPE_INT32_T, 0, 16, offsetof(mavlink_hil_gps_t, alt) }, \
  36. { "eph", NULL, MAVLINK_TYPE_UINT16_T, 0, 20, offsetof(mavlink_hil_gps_t, eph) }, \
  37. { "epv", NULL, MAVLINK_TYPE_UINT16_T, 0, 22, offsetof(mavlink_hil_gps_t, epv) }, \
  38. { "vel", NULL, MAVLINK_TYPE_UINT16_T, 0, 24, offsetof(mavlink_hil_gps_t, vel) }, \
  39. { "vn", NULL, MAVLINK_TYPE_INT16_T, 0, 26, offsetof(mavlink_hil_gps_t, vn) }, \
  40. { "ve", NULL, MAVLINK_TYPE_INT16_T, 0, 28, offsetof(mavlink_hil_gps_t, ve) }, \
  41. { "vd", NULL, MAVLINK_TYPE_INT16_T, 0, 30, offsetof(mavlink_hil_gps_t, vd) }, \
  42. { "cog", NULL, MAVLINK_TYPE_UINT16_T, 0, 32, offsetof(mavlink_hil_gps_t, cog) }, \
  43. { "satellites_visible", NULL, MAVLINK_TYPE_UINT8_T, 0, 35, offsetof(mavlink_hil_gps_t, satellites_visible) }, \
  44. } \
  45. }
  46. #else
  47. #define MAVLINK_MESSAGE_INFO_HIL_GPS { \
  48. "HIL_GPS", \
  49. 13, \
  50. { { "time_usec", NULL, MAVLINK_TYPE_UINT64_T, 0, 0, offsetof(mavlink_hil_gps_t, time_usec) }, \
  51. { "fix_type", NULL, MAVLINK_TYPE_UINT8_T, 0, 34, offsetof(mavlink_hil_gps_t, fix_type) }, \
  52. { "lat", NULL, MAVLINK_TYPE_INT32_T, 0, 8, offsetof(mavlink_hil_gps_t, lat) }, \
  53. { "lon", NULL, MAVLINK_TYPE_INT32_T, 0, 12, offsetof(mavlink_hil_gps_t, lon) }, \
  54. { "alt", NULL, MAVLINK_TYPE_INT32_T, 0, 16, offsetof(mavlink_hil_gps_t, alt) }, \
  55. { "eph", NULL, MAVLINK_TYPE_UINT16_T, 0, 20, offsetof(mavlink_hil_gps_t, eph) }, \
  56. { "epv", NULL, MAVLINK_TYPE_UINT16_T, 0, 22, offsetof(mavlink_hil_gps_t, epv) }, \
  57. { "vel", NULL, MAVLINK_TYPE_UINT16_T, 0, 24, offsetof(mavlink_hil_gps_t, vel) }, \
  58. { "vn", NULL, MAVLINK_TYPE_INT16_T, 0, 26, offsetof(mavlink_hil_gps_t, vn) }, \
  59. { "ve", NULL, MAVLINK_TYPE_INT16_T, 0, 28, offsetof(mavlink_hil_gps_t, ve) }, \
  60. { "vd", NULL, MAVLINK_TYPE_INT16_T, 0, 30, offsetof(mavlink_hil_gps_t, vd) }, \
  61. { "cog", NULL, MAVLINK_TYPE_UINT16_T, 0, 32, offsetof(mavlink_hil_gps_t, cog) }, \
  62. { "satellites_visible", NULL, MAVLINK_TYPE_UINT8_T, 0, 35, offsetof(mavlink_hil_gps_t, satellites_visible) }, \
  63. } \
  64. }
  65. #endif
  66. /**
  67. * @brief Pack a hil_gps message
  68. * @param system_id ID of this system
  69. * @param component_id ID of this component (e.g. 200 for IMU)
  70. * @param msg The MAVLink message to compress the data into
  71. *
  72. * @param time_usec [us] Timestamp (UNIX Epoch time or time since system boot). The receiving end can infer timestamp format (since 1.1.1970 or since system boot) by checking for the magnitude the number.
  73. * @param fix_type 0-1: no fix, 2: 2D fix, 3: 3D fix. Some applications will not use the value of this field unless it is at least two, so always correctly fill in the fix.
  74. * @param lat [degE7] Latitude (WGS84)
  75. * @param lon [degE7] Longitude (WGS84)
  76. * @param alt [mm] Altitude (MSL). Positive for up.
  77. * @param eph [cm] GPS HDOP horizontal dilution of position. If unknown, set to: 65535
  78. * @param epv [cm] GPS VDOP vertical dilution of position. If unknown, set to: 65535
  79. * @param vel [cm/s] GPS ground speed. If unknown, set to: 65535
  80. * @param vn [cm/s] GPS velocity in north direction in earth-fixed NED frame
  81. * @param ve [cm/s] GPS velocity in east direction in earth-fixed NED frame
  82. * @param vd [cm/s] GPS velocity in down direction in earth-fixed NED frame
  83. * @param cog [cdeg] Course over ground (NOT heading, but direction of movement), 0.0..359.99 degrees. If unknown, set to: 65535
  84. * @param satellites_visible Number of satellites visible. If unknown, set to 255
  85. * @return length of the message in bytes (excluding serial stream start sign)
  86. */
  87. static inline uint16_t mavlink_msg_hil_gps_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
  88. uint64_t time_usec, uint8_t fix_type, int32_t lat, int32_t lon, int32_t alt, uint16_t eph, uint16_t epv, uint16_t vel, int16_t vn, int16_t ve, int16_t vd, uint16_t cog, uint8_t satellites_visible)
  89. {
  90. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  91. char buf[MAVLINK_MSG_ID_HIL_GPS_LEN];
  92. _mav_put_uint64_t(buf, 0, time_usec);
  93. _mav_put_int32_t(buf, 8, lat);
  94. _mav_put_int32_t(buf, 12, lon);
  95. _mav_put_int32_t(buf, 16, alt);
  96. _mav_put_uint16_t(buf, 20, eph);
  97. _mav_put_uint16_t(buf, 22, epv);
  98. _mav_put_uint16_t(buf, 24, vel);
  99. _mav_put_int16_t(buf, 26, vn);
  100. _mav_put_int16_t(buf, 28, ve);
  101. _mav_put_int16_t(buf, 30, vd);
  102. _mav_put_uint16_t(buf, 32, cog);
  103. _mav_put_uint8_t(buf, 34, fix_type);
  104. _mav_put_uint8_t(buf, 35, satellites_visible);
  105. memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_HIL_GPS_LEN);
  106. #else
  107. mavlink_hil_gps_t packet;
  108. packet.time_usec = time_usec;
  109. packet.lat = lat;
  110. packet.lon = lon;
  111. packet.alt = alt;
  112. packet.eph = eph;
  113. packet.epv = epv;
  114. packet.vel = vel;
  115. packet.vn = vn;
  116. packet.ve = ve;
  117. packet.vd = vd;
  118. packet.cog = cog;
  119. packet.fix_type = fix_type;
  120. packet.satellites_visible = satellites_visible;
  121. memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_HIL_GPS_LEN);
  122. #endif
  123. msg->msgid = MAVLINK_MSG_ID_HIL_GPS;
  124. return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_HIL_GPS_MIN_LEN, MAVLINK_MSG_ID_HIL_GPS_LEN, MAVLINK_MSG_ID_HIL_GPS_CRC);
  125. }
  126. /**
  127. * @brief Pack a hil_gps message on a channel
  128. * @param system_id ID of this system
  129. * @param component_id ID of this component (e.g. 200 for IMU)
  130. * @param chan The MAVLink channel this message will be sent over
  131. * @param msg The MAVLink message to compress the data into
  132. * @param time_usec [us] Timestamp (UNIX Epoch time or time since system boot). The receiving end can infer timestamp format (since 1.1.1970 or since system boot) by checking for the magnitude the number.
  133. * @param fix_type 0-1: no fix, 2: 2D fix, 3: 3D fix. Some applications will not use the value of this field unless it is at least two, so always correctly fill in the fix.
  134. * @param lat [degE7] Latitude (WGS84)
  135. * @param lon [degE7] Longitude (WGS84)
  136. * @param alt [mm] Altitude (MSL). Positive for up.
  137. * @param eph [cm] GPS HDOP horizontal dilution of position. If unknown, set to: 65535
  138. * @param epv [cm] GPS VDOP vertical dilution of position. If unknown, set to: 65535
  139. * @param vel [cm/s] GPS ground speed. If unknown, set to: 65535
  140. * @param vn [cm/s] GPS velocity in north direction in earth-fixed NED frame
  141. * @param ve [cm/s] GPS velocity in east direction in earth-fixed NED frame
  142. * @param vd [cm/s] GPS velocity in down direction in earth-fixed NED frame
  143. * @param cog [cdeg] Course over ground (NOT heading, but direction of movement), 0.0..359.99 degrees. If unknown, set to: 65535
  144. * @param satellites_visible Number of satellites visible. If unknown, set to 255
  145. * @return length of the message in bytes (excluding serial stream start sign)
  146. */
  147. static inline uint16_t mavlink_msg_hil_gps_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
  148. mavlink_message_t* msg,
  149. uint64_t time_usec,uint8_t fix_type,int32_t lat,int32_t lon,int32_t alt,uint16_t eph,uint16_t epv,uint16_t vel,int16_t vn,int16_t ve,int16_t vd,uint16_t cog,uint8_t satellites_visible)
  150. {
  151. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  152. char buf[MAVLINK_MSG_ID_HIL_GPS_LEN];
  153. _mav_put_uint64_t(buf, 0, time_usec);
  154. _mav_put_int32_t(buf, 8, lat);
  155. _mav_put_int32_t(buf, 12, lon);
  156. _mav_put_int32_t(buf, 16, alt);
  157. _mav_put_uint16_t(buf, 20, eph);
  158. _mav_put_uint16_t(buf, 22, epv);
  159. _mav_put_uint16_t(buf, 24, vel);
  160. _mav_put_int16_t(buf, 26, vn);
  161. _mav_put_int16_t(buf, 28, ve);
  162. _mav_put_int16_t(buf, 30, vd);
  163. _mav_put_uint16_t(buf, 32, cog);
  164. _mav_put_uint8_t(buf, 34, fix_type);
  165. _mav_put_uint8_t(buf, 35, satellites_visible);
  166. memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_HIL_GPS_LEN);
  167. #else
  168. mavlink_hil_gps_t packet;
  169. packet.time_usec = time_usec;
  170. packet.lat = lat;
  171. packet.lon = lon;
  172. packet.alt = alt;
  173. packet.eph = eph;
  174. packet.epv = epv;
  175. packet.vel = vel;
  176. packet.vn = vn;
  177. packet.ve = ve;
  178. packet.vd = vd;
  179. packet.cog = cog;
  180. packet.fix_type = fix_type;
  181. packet.satellites_visible = satellites_visible;
  182. memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_HIL_GPS_LEN);
  183. #endif
  184. msg->msgid = MAVLINK_MSG_ID_HIL_GPS;
  185. return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_HIL_GPS_MIN_LEN, MAVLINK_MSG_ID_HIL_GPS_LEN, MAVLINK_MSG_ID_HIL_GPS_CRC);
  186. }
  187. /**
  188. * @brief Encode a hil_gps struct
  189. *
  190. * @param system_id ID of this system
  191. * @param component_id ID of this component (e.g. 200 for IMU)
  192. * @param msg The MAVLink message to compress the data into
  193. * @param hil_gps C-struct to read the message contents from
  194. */
  195. static inline uint16_t mavlink_msg_hil_gps_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_hil_gps_t* hil_gps)
  196. {
  197. return mavlink_msg_hil_gps_pack(system_id, component_id, msg, hil_gps->time_usec, hil_gps->fix_type, hil_gps->lat, hil_gps->lon, hil_gps->alt, hil_gps->eph, hil_gps->epv, hil_gps->vel, hil_gps->vn, hil_gps->ve, hil_gps->vd, hil_gps->cog, hil_gps->satellites_visible);
  198. }
  199. /**
  200. * @brief Encode a hil_gps struct on a channel
  201. *
  202. * @param system_id ID of this system
  203. * @param component_id ID of this component (e.g. 200 for IMU)
  204. * @param chan The MAVLink channel this message will be sent over
  205. * @param msg The MAVLink message to compress the data into
  206. * @param hil_gps C-struct to read the message contents from
  207. */
  208. static inline uint16_t mavlink_msg_hil_gps_encode_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, const mavlink_hil_gps_t* hil_gps)
  209. {
  210. return mavlink_msg_hil_gps_pack_chan(system_id, component_id, chan, msg, hil_gps->time_usec, hil_gps->fix_type, hil_gps->lat, hil_gps->lon, hil_gps->alt, hil_gps->eph, hil_gps->epv, hil_gps->vel, hil_gps->vn, hil_gps->ve, hil_gps->vd, hil_gps->cog, hil_gps->satellites_visible);
  211. }
  212. /**
  213. * @brief Send a hil_gps message
  214. * @param chan MAVLink channel to send the message
  215. *
  216. * @param time_usec [us] Timestamp (UNIX Epoch time or time since system boot). The receiving end can infer timestamp format (since 1.1.1970 or since system boot) by checking for the magnitude the number.
  217. * @param fix_type 0-1: no fix, 2: 2D fix, 3: 3D fix. Some applications will not use the value of this field unless it is at least two, so always correctly fill in the fix.
  218. * @param lat [degE7] Latitude (WGS84)
  219. * @param lon [degE7] Longitude (WGS84)
  220. * @param alt [mm] Altitude (MSL). Positive for up.
  221. * @param eph [cm] GPS HDOP horizontal dilution of position. If unknown, set to: 65535
  222. * @param epv [cm] GPS VDOP vertical dilution of position. If unknown, set to: 65535
  223. * @param vel [cm/s] GPS ground speed. If unknown, set to: 65535
  224. * @param vn [cm/s] GPS velocity in north direction in earth-fixed NED frame
  225. * @param ve [cm/s] GPS velocity in east direction in earth-fixed NED frame
  226. * @param vd [cm/s] GPS velocity in down direction in earth-fixed NED frame
  227. * @param cog [cdeg] Course over ground (NOT heading, but direction of movement), 0.0..359.99 degrees. If unknown, set to: 65535
  228. * @param satellites_visible Number of satellites visible. If unknown, set to 255
  229. */
  230. #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
  231. static inline void mavlink_msg_hil_gps_send(mavlink_channel_t chan, uint64_t time_usec, uint8_t fix_type, int32_t lat, int32_t lon, int32_t alt, uint16_t eph, uint16_t epv, uint16_t vel, int16_t vn, int16_t ve, int16_t vd, uint16_t cog, uint8_t satellites_visible)
  232. {
  233. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  234. char buf[MAVLINK_MSG_ID_HIL_GPS_LEN];
  235. _mav_put_uint64_t(buf, 0, time_usec);
  236. _mav_put_int32_t(buf, 8, lat);
  237. _mav_put_int32_t(buf, 12, lon);
  238. _mav_put_int32_t(buf, 16, alt);
  239. _mav_put_uint16_t(buf, 20, eph);
  240. _mav_put_uint16_t(buf, 22, epv);
  241. _mav_put_uint16_t(buf, 24, vel);
  242. _mav_put_int16_t(buf, 26, vn);
  243. _mav_put_int16_t(buf, 28, ve);
  244. _mav_put_int16_t(buf, 30, vd);
  245. _mav_put_uint16_t(buf, 32, cog);
  246. _mav_put_uint8_t(buf, 34, fix_type);
  247. _mav_put_uint8_t(buf, 35, satellites_visible);
  248. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_HIL_GPS, buf, MAVLINK_MSG_ID_HIL_GPS_MIN_LEN, MAVLINK_MSG_ID_HIL_GPS_LEN, MAVLINK_MSG_ID_HIL_GPS_CRC);
  249. #else
  250. mavlink_hil_gps_t packet;
  251. packet.time_usec = time_usec;
  252. packet.lat = lat;
  253. packet.lon = lon;
  254. packet.alt = alt;
  255. packet.eph = eph;
  256. packet.epv = epv;
  257. packet.vel = vel;
  258. packet.vn = vn;
  259. packet.ve = ve;
  260. packet.vd = vd;
  261. packet.cog = cog;
  262. packet.fix_type = fix_type;
  263. packet.satellites_visible = satellites_visible;
  264. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_HIL_GPS, (const char *)&packet, MAVLINK_MSG_ID_HIL_GPS_MIN_LEN, MAVLINK_MSG_ID_HIL_GPS_LEN, MAVLINK_MSG_ID_HIL_GPS_CRC);
  265. #endif
  266. }
  267. /**
  268. * @brief Send a hil_gps message
  269. * @param chan MAVLink channel to send the message
  270. * @param struct The MAVLink struct to serialize
  271. */
  272. static inline void mavlink_msg_hil_gps_send_struct(mavlink_channel_t chan, const mavlink_hil_gps_t* hil_gps)
  273. {
  274. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  275. mavlink_msg_hil_gps_send(chan, hil_gps->time_usec, hil_gps->fix_type, hil_gps->lat, hil_gps->lon, hil_gps->alt, hil_gps->eph, hil_gps->epv, hil_gps->vel, hil_gps->vn, hil_gps->ve, hil_gps->vd, hil_gps->cog, hil_gps->satellites_visible);
  276. #else
  277. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_HIL_GPS, (const char *)hil_gps, MAVLINK_MSG_ID_HIL_GPS_MIN_LEN, MAVLINK_MSG_ID_HIL_GPS_LEN, MAVLINK_MSG_ID_HIL_GPS_CRC);
  278. #endif
  279. }
  280. #if MAVLINK_MSG_ID_HIL_GPS_LEN <= MAVLINK_MAX_PAYLOAD_LEN
  281. /*
  282. This varient of _send() can be used to save stack space by re-using
  283. memory from the receive buffer. The caller provides a
  284. mavlink_message_t which is the size of a full mavlink message. This
  285. is usually the receive buffer for the channel, and allows a reply to an
  286. incoming message with minimum stack space usage.
  287. */
  288. static inline void mavlink_msg_hil_gps_send_buf(mavlink_message_t *msgbuf, mavlink_channel_t chan, uint64_t time_usec, uint8_t fix_type, int32_t lat, int32_t lon, int32_t alt, uint16_t eph, uint16_t epv, uint16_t vel, int16_t vn, int16_t ve, int16_t vd, uint16_t cog, uint8_t satellites_visible)
  289. {
  290. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  291. char *buf = (char *)msgbuf;
  292. _mav_put_uint64_t(buf, 0, time_usec);
  293. _mav_put_int32_t(buf, 8, lat);
  294. _mav_put_int32_t(buf, 12, lon);
  295. _mav_put_int32_t(buf, 16, alt);
  296. _mav_put_uint16_t(buf, 20, eph);
  297. _mav_put_uint16_t(buf, 22, epv);
  298. _mav_put_uint16_t(buf, 24, vel);
  299. _mav_put_int16_t(buf, 26, vn);
  300. _mav_put_int16_t(buf, 28, ve);
  301. _mav_put_int16_t(buf, 30, vd);
  302. _mav_put_uint16_t(buf, 32, cog);
  303. _mav_put_uint8_t(buf, 34, fix_type);
  304. _mav_put_uint8_t(buf, 35, satellites_visible);
  305. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_HIL_GPS, buf, MAVLINK_MSG_ID_HIL_GPS_MIN_LEN, MAVLINK_MSG_ID_HIL_GPS_LEN, MAVLINK_MSG_ID_HIL_GPS_CRC);
  306. #else
  307. mavlink_hil_gps_t *packet = (mavlink_hil_gps_t *)msgbuf;
  308. packet->time_usec = time_usec;
  309. packet->lat = lat;
  310. packet->lon = lon;
  311. packet->alt = alt;
  312. packet->eph = eph;
  313. packet->epv = epv;
  314. packet->vel = vel;
  315. packet->vn = vn;
  316. packet->ve = ve;
  317. packet->vd = vd;
  318. packet->cog = cog;
  319. packet->fix_type = fix_type;
  320. packet->satellites_visible = satellites_visible;
  321. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_HIL_GPS, (const char *)packet, MAVLINK_MSG_ID_HIL_GPS_MIN_LEN, MAVLINK_MSG_ID_HIL_GPS_LEN, MAVLINK_MSG_ID_HIL_GPS_CRC);
  322. #endif
  323. }
  324. #endif
  325. #endif
  326. // MESSAGE HIL_GPS UNPACKING
  327. /**
  328. * @brief Get field time_usec from hil_gps message
  329. *
  330. * @return [us] Timestamp (UNIX Epoch time or time since system boot). The receiving end can infer timestamp format (since 1.1.1970 or since system boot) by checking for the magnitude the number.
  331. */
  332. static inline uint64_t mavlink_msg_hil_gps_get_time_usec(const mavlink_message_t* msg)
  333. {
  334. return _MAV_RETURN_uint64_t(msg, 0);
  335. }
  336. /**
  337. * @brief Get field fix_type from hil_gps message
  338. *
  339. * @return 0-1: no fix, 2: 2D fix, 3: 3D fix. Some applications will not use the value of this field unless it is at least two, so always correctly fill in the fix.
  340. */
  341. static inline uint8_t mavlink_msg_hil_gps_get_fix_type(const mavlink_message_t* msg)
  342. {
  343. return _MAV_RETURN_uint8_t(msg, 34);
  344. }
  345. /**
  346. * @brief Get field lat from hil_gps message
  347. *
  348. * @return [degE7] Latitude (WGS84)
  349. */
  350. static inline int32_t mavlink_msg_hil_gps_get_lat(const mavlink_message_t* msg)
  351. {
  352. return _MAV_RETURN_int32_t(msg, 8);
  353. }
  354. /**
  355. * @brief Get field lon from hil_gps message
  356. *
  357. * @return [degE7] Longitude (WGS84)
  358. */
  359. static inline int32_t mavlink_msg_hil_gps_get_lon(const mavlink_message_t* msg)
  360. {
  361. return _MAV_RETURN_int32_t(msg, 12);
  362. }
  363. /**
  364. * @brief Get field alt from hil_gps message
  365. *
  366. * @return [mm] Altitude (MSL). Positive for up.
  367. */
  368. static inline int32_t mavlink_msg_hil_gps_get_alt(const mavlink_message_t* msg)
  369. {
  370. return _MAV_RETURN_int32_t(msg, 16);
  371. }
  372. /**
  373. * @brief Get field eph from hil_gps message
  374. *
  375. * @return [cm] GPS HDOP horizontal dilution of position. If unknown, set to: 65535
  376. */
  377. static inline uint16_t mavlink_msg_hil_gps_get_eph(const mavlink_message_t* msg)
  378. {
  379. return _MAV_RETURN_uint16_t(msg, 20);
  380. }
  381. /**
  382. * @brief Get field epv from hil_gps message
  383. *
  384. * @return [cm] GPS VDOP vertical dilution of position. If unknown, set to: 65535
  385. */
  386. static inline uint16_t mavlink_msg_hil_gps_get_epv(const mavlink_message_t* msg)
  387. {
  388. return _MAV_RETURN_uint16_t(msg, 22);
  389. }
  390. /**
  391. * @brief Get field vel from hil_gps message
  392. *
  393. * @return [cm/s] GPS ground speed. If unknown, set to: 65535
  394. */
  395. static inline uint16_t mavlink_msg_hil_gps_get_vel(const mavlink_message_t* msg)
  396. {
  397. return _MAV_RETURN_uint16_t(msg, 24);
  398. }
  399. /**
  400. * @brief Get field vn from hil_gps message
  401. *
  402. * @return [cm/s] GPS velocity in north direction in earth-fixed NED frame
  403. */
  404. static inline int16_t mavlink_msg_hil_gps_get_vn(const mavlink_message_t* msg)
  405. {
  406. return _MAV_RETURN_int16_t(msg, 26);
  407. }
  408. /**
  409. * @brief Get field ve from hil_gps message
  410. *
  411. * @return [cm/s] GPS velocity in east direction in earth-fixed NED frame
  412. */
  413. static inline int16_t mavlink_msg_hil_gps_get_ve(const mavlink_message_t* msg)
  414. {
  415. return _MAV_RETURN_int16_t(msg, 28);
  416. }
  417. /**
  418. * @brief Get field vd from hil_gps message
  419. *
  420. * @return [cm/s] GPS velocity in down direction in earth-fixed NED frame
  421. */
  422. static inline int16_t mavlink_msg_hil_gps_get_vd(const mavlink_message_t* msg)
  423. {
  424. return _MAV_RETURN_int16_t(msg, 30);
  425. }
  426. /**
  427. * @brief Get field cog from hil_gps message
  428. *
  429. * @return [cdeg] Course over ground (NOT heading, but direction of movement), 0.0..359.99 degrees. If unknown, set to: 65535
  430. */
  431. static inline uint16_t mavlink_msg_hil_gps_get_cog(const mavlink_message_t* msg)
  432. {
  433. return _MAV_RETURN_uint16_t(msg, 32);
  434. }
  435. /**
  436. * @brief Get field satellites_visible from hil_gps message
  437. *
  438. * @return Number of satellites visible. If unknown, set to 255
  439. */
  440. static inline uint8_t mavlink_msg_hil_gps_get_satellites_visible(const mavlink_message_t* msg)
  441. {
  442. return _MAV_RETURN_uint8_t(msg, 35);
  443. }
  444. /**
  445. * @brief Decode a hil_gps message into a struct
  446. *
  447. * @param msg The message to decode
  448. * @param hil_gps C-struct to decode the message contents into
  449. */
  450. static inline void mavlink_msg_hil_gps_decode(const mavlink_message_t* msg, mavlink_hil_gps_t* hil_gps)
  451. {
  452. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  453. hil_gps->time_usec = mavlink_msg_hil_gps_get_time_usec(msg);
  454. hil_gps->lat = mavlink_msg_hil_gps_get_lat(msg);
  455. hil_gps->lon = mavlink_msg_hil_gps_get_lon(msg);
  456. hil_gps->alt = mavlink_msg_hil_gps_get_alt(msg);
  457. hil_gps->eph = mavlink_msg_hil_gps_get_eph(msg);
  458. hil_gps->epv = mavlink_msg_hil_gps_get_epv(msg);
  459. hil_gps->vel = mavlink_msg_hil_gps_get_vel(msg);
  460. hil_gps->vn = mavlink_msg_hil_gps_get_vn(msg);
  461. hil_gps->ve = mavlink_msg_hil_gps_get_ve(msg);
  462. hil_gps->vd = mavlink_msg_hil_gps_get_vd(msg);
  463. hil_gps->cog = mavlink_msg_hil_gps_get_cog(msg);
  464. hil_gps->fix_type = mavlink_msg_hil_gps_get_fix_type(msg);
  465. hil_gps->satellites_visible = mavlink_msg_hil_gps_get_satellites_visible(msg);
  466. #else
  467. uint8_t len = msg->len < MAVLINK_MSG_ID_HIL_GPS_LEN? msg->len : MAVLINK_MSG_ID_HIL_GPS_LEN;
  468. memset(hil_gps, 0, MAVLINK_MSG_ID_HIL_GPS_LEN);
  469. memcpy(hil_gps, _MAV_PAYLOAD(msg), len);
  470. #endif
  471. }