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
28 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. #pragma once
  2. // MESSAGE SYS_STATUS PACKING
  3. #define MAVLINK_MSG_ID_SYS_STATUS 1
  4. MAVPACKED(
  5. typedef struct __mavlink_sys_status_t {
  6. uint32_t onboard_control_sensors_present; /*< Bitmap showing which onboard controllers and sensors are present. Value of 0: not present. Value of 1: present.*/
  7. uint32_t onboard_control_sensors_enabled; /*< Bitmap showing which onboard controllers and sensors are enabled: Value of 0: not enabled. Value of 1: enabled.*/
  8. uint32_t onboard_control_sensors_health; /*< Bitmap showing which onboard controllers and sensors have an error (or are operational). Value of 0: error. Value of 1: healthy.*/
  9. uint16_t load; /*< [d%] Maximum usage in percent of the mainloop time. Values: [0-1000] - should always be below 1000*/
  10. uint16_t voltage_battery; /*< [mV] Battery voltage, UINT16_MAX: Voltage not sent by autopilot*/
  11. int16_t current_battery; /*< [cA] Battery current, -1: Current not sent by autopilot*/
  12. uint16_t drop_rate_comm; /*< [c%] Communication drop rate, (UART, I2C, SPI, CAN), dropped packets on all links (packets that were corrupted on reception on the MAV)*/
  13. uint16_t errors_comm; /*< Communication errors (UART, I2C, SPI, CAN), dropped packets on all links (packets that were corrupted on reception on the MAV)*/
  14. uint16_t errors_count1; /*< Autopilot-specific errors*/
  15. uint16_t errors_count2; /*< Autopilot-specific errors*/
  16. uint16_t errors_count3; /*< Autopilot-specific errors*/
  17. uint16_t errors_count4; /*< Autopilot-specific errors*/
  18. int8_t battery_remaining; /*< [%] Battery energy remaining, -1: Battery remaining energy not sent by autopilot*/
  19. }) mavlink_sys_status_t;
  20. #define MAVLINK_MSG_ID_SYS_STATUS_LEN 31
  21. #define MAVLINK_MSG_ID_SYS_STATUS_MIN_LEN 31
  22. #define MAVLINK_MSG_ID_1_LEN 31
  23. #define MAVLINK_MSG_ID_1_MIN_LEN 31
  24. #define MAVLINK_MSG_ID_SYS_STATUS_CRC 124
  25. #define MAVLINK_MSG_ID_1_CRC 124
  26. #if MAVLINK_COMMAND_24BIT
  27. #define MAVLINK_MESSAGE_INFO_SYS_STATUS { \
  28. 1, \
  29. "SYS_STATUS", \
  30. 13, \
  31. { { "onboard_control_sensors_present", "0x%04x", MAVLINK_TYPE_UINT32_T, 0, 0, offsetof(mavlink_sys_status_t, onboard_control_sensors_present) }, \
  32. { "onboard_control_sensors_enabled", "0x%04x", MAVLINK_TYPE_UINT32_T, 0, 4, offsetof(mavlink_sys_status_t, onboard_control_sensors_enabled) }, \
  33. { "onboard_control_sensors_health", "0x%04x", MAVLINK_TYPE_UINT32_T, 0, 8, offsetof(mavlink_sys_status_t, onboard_control_sensors_health) }, \
  34. { "load", NULL, MAVLINK_TYPE_UINT16_T, 0, 12, offsetof(mavlink_sys_status_t, load) }, \
  35. { "voltage_battery", NULL, MAVLINK_TYPE_UINT16_T, 0, 14, offsetof(mavlink_sys_status_t, voltage_battery) }, \
  36. { "current_battery", NULL, MAVLINK_TYPE_INT16_T, 0, 16, offsetof(mavlink_sys_status_t, current_battery) }, \
  37. { "battery_remaining", NULL, MAVLINK_TYPE_INT8_T, 0, 30, offsetof(mavlink_sys_status_t, battery_remaining) }, \
  38. { "drop_rate_comm", NULL, MAVLINK_TYPE_UINT16_T, 0, 18, offsetof(mavlink_sys_status_t, drop_rate_comm) }, \
  39. { "errors_comm", NULL, MAVLINK_TYPE_UINT16_T, 0, 20, offsetof(mavlink_sys_status_t, errors_comm) }, \
  40. { "errors_count1", NULL, MAVLINK_TYPE_UINT16_T, 0, 22, offsetof(mavlink_sys_status_t, errors_count1) }, \
  41. { "errors_count2", NULL, MAVLINK_TYPE_UINT16_T, 0, 24, offsetof(mavlink_sys_status_t, errors_count2) }, \
  42. { "errors_count3", NULL, MAVLINK_TYPE_UINT16_T, 0, 26, offsetof(mavlink_sys_status_t, errors_count3) }, \
  43. { "errors_count4", NULL, MAVLINK_TYPE_UINT16_T, 0, 28, offsetof(mavlink_sys_status_t, errors_count4) }, \
  44. } \
  45. }
  46. #else
  47. #define MAVLINK_MESSAGE_INFO_SYS_STATUS { \
  48. "SYS_STATUS", \
  49. 13, \
  50. { { "onboard_control_sensors_present", "0x%04x", MAVLINK_TYPE_UINT32_T, 0, 0, offsetof(mavlink_sys_status_t, onboard_control_sensors_present) }, \
  51. { "onboard_control_sensors_enabled", "0x%04x", MAVLINK_TYPE_UINT32_T, 0, 4, offsetof(mavlink_sys_status_t, onboard_control_sensors_enabled) }, \
  52. { "onboard_control_sensors_health", "0x%04x", MAVLINK_TYPE_UINT32_T, 0, 8, offsetof(mavlink_sys_status_t, onboard_control_sensors_health) }, \
  53. { "load", NULL, MAVLINK_TYPE_UINT16_T, 0, 12, offsetof(mavlink_sys_status_t, load) }, \
  54. { "voltage_battery", NULL, MAVLINK_TYPE_UINT16_T, 0, 14, offsetof(mavlink_sys_status_t, voltage_battery) }, \
  55. { "current_battery", NULL, MAVLINK_TYPE_INT16_T, 0, 16, offsetof(mavlink_sys_status_t, current_battery) }, \
  56. { "battery_remaining", NULL, MAVLINK_TYPE_INT8_T, 0, 30, offsetof(mavlink_sys_status_t, battery_remaining) }, \
  57. { "drop_rate_comm", NULL, MAVLINK_TYPE_UINT16_T, 0, 18, offsetof(mavlink_sys_status_t, drop_rate_comm) }, \
  58. { "errors_comm", NULL, MAVLINK_TYPE_UINT16_T, 0, 20, offsetof(mavlink_sys_status_t, errors_comm) }, \
  59. { "errors_count1", NULL, MAVLINK_TYPE_UINT16_T, 0, 22, offsetof(mavlink_sys_status_t, errors_count1) }, \
  60. { "errors_count2", NULL, MAVLINK_TYPE_UINT16_T, 0, 24, offsetof(mavlink_sys_status_t, errors_count2) }, \
  61. { "errors_count3", NULL, MAVLINK_TYPE_UINT16_T, 0, 26, offsetof(mavlink_sys_status_t, errors_count3) }, \
  62. { "errors_count4", NULL, MAVLINK_TYPE_UINT16_T, 0, 28, offsetof(mavlink_sys_status_t, errors_count4) }, \
  63. } \
  64. }
  65. #endif
  66. /**
  67. * @brief Pack a sys_status 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 onboard_control_sensors_present Bitmap showing which onboard controllers and sensors are present. Value of 0: not present. Value of 1: present.
  73. * @param onboard_control_sensors_enabled Bitmap showing which onboard controllers and sensors are enabled: Value of 0: not enabled. Value of 1: enabled.
  74. * @param onboard_control_sensors_health Bitmap showing which onboard controllers and sensors have an error (or are operational). Value of 0: error. Value of 1: healthy.
  75. * @param load [d%] Maximum usage in percent of the mainloop time. Values: [0-1000] - should always be below 1000
  76. * @param voltage_battery [mV] Battery voltage, UINT16_MAX: Voltage not sent by autopilot
  77. * @param current_battery [cA] Battery current, -1: Current not sent by autopilot
  78. * @param battery_remaining [%] Battery energy remaining, -1: Battery remaining energy not sent by autopilot
  79. * @param drop_rate_comm [c%] Communication drop rate, (UART, I2C, SPI, CAN), dropped packets on all links (packets that were corrupted on reception on the MAV)
  80. * @param errors_comm Communication errors (UART, I2C, SPI, CAN), dropped packets on all links (packets that were corrupted on reception on the MAV)
  81. * @param errors_count1 Autopilot-specific errors
  82. * @param errors_count2 Autopilot-specific errors
  83. * @param errors_count3 Autopilot-specific errors
  84. * @param errors_count4 Autopilot-specific errors
  85. * @return length of the message in bytes (excluding serial stream start sign)
  86. */
  87. static inline uint16_t mavlink_msg_sys_status_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
  88. uint32_t onboard_control_sensors_present, uint32_t onboard_control_sensors_enabled, uint32_t onboard_control_sensors_health, uint16_t load, uint16_t voltage_battery, int16_t current_battery, int8_t battery_remaining, uint16_t drop_rate_comm, uint16_t errors_comm, uint16_t errors_count1, uint16_t errors_count2, uint16_t errors_count3, uint16_t errors_count4)
  89. {
  90. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  91. char buf[MAVLINK_MSG_ID_SYS_STATUS_LEN];
  92. _mav_put_uint32_t(buf, 0, onboard_control_sensors_present);
  93. _mav_put_uint32_t(buf, 4, onboard_control_sensors_enabled);
  94. _mav_put_uint32_t(buf, 8, onboard_control_sensors_health);
  95. _mav_put_uint16_t(buf, 12, load);
  96. _mav_put_uint16_t(buf, 14, voltage_battery);
  97. _mav_put_int16_t(buf, 16, current_battery);
  98. _mav_put_uint16_t(buf, 18, drop_rate_comm);
  99. _mav_put_uint16_t(buf, 20, errors_comm);
  100. _mav_put_uint16_t(buf, 22, errors_count1);
  101. _mav_put_uint16_t(buf, 24, errors_count2);
  102. _mav_put_uint16_t(buf, 26, errors_count3);
  103. _mav_put_uint16_t(buf, 28, errors_count4);
  104. _mav_put_int8_t(buf, 30, battery_remaining);
  105. memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_SYS_STATUS_LEN);
  106. #else
  107. mavlink_sys_status_t packet;
  108. packet.onboard_control_sensors_present = onboard_control_sensors_present;
  109. packet.onboard_control_sensors_enabled = onboard_control_sensors_enabled;
  110. packet.onboard_control_sensors_health = onboard_control_sensors_health;
  111. packet.load = load;
  112. packet.voltage_battery = voltage_battery;
  113. packet.current_battery = current_battery;
  114. packet.drop_rate_comm = drop_rate_comm;
  115. packet.errors_comm = errors_comm;
  116. packet.errors_count1 = errors_count1;
  117. packet.errors_count2 = errors_count2;
  118. packet.errors_count3 = errors_count3;
  119. packet.errors_count4 = errors_count4;
  120. packet.battery_remaining = battery_remaining;
  121. memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_SYS_STATUS_LEN);
  122. #endif
  123. msg->msgid = MAVLINK_MSG_ID_SYS_STATUS;
  124. return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_SYS_STATUS_MIN_LEN, MAVLINK_MSG_ID_SYS_STATUS_LEN, MAVLINK_MSG_ID_SYS_STATUS_CRC);
  125. }
  126. /**
  127. * @brief Pack a sys_status 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 onboard_control_sensors_present Bitmap showing which onboard controllers and sensors are present. Value of 0: not present. Value of 1: present.
  133. * @param onboard_control_sensors_enabled Bitmap showing which onboard controllers and sensors are enabled: Value of 0: not enabled. Value of 1: enabled.
  134. * @param onboard_control_sensors_health Bitmap showing which onboard controllers and sensors have an error (or are operational). Value of 0: error. Value of 1: healthy.
  135. * @param load [d%] Maximum usage in percent of the mainloop time. Values: [0-1000] - should always be below 1000
  136. * @param voltage_battery [mV] Battery voltage, UINT16_MAX: Voltage not sent by autopilot
  137. * @param current_battery [cA] Battery current, -1: Current not sent by autopilot
  138. * @param battery_remaining [%] Battery energy remaining, -1: Battery remaining energy not sent by autopilot
  139. * @param drop_rate_comm [c%] Communication drop rate, (UART, I2C, SPI, CAN), dropped packets on all links (packets that were corrupted on reception on the MAV)
  140. * @param errors_comm Communication errors (UART, I2C, SPI, CAN), dropped packets on all links (packets that were corrupted on reception on the MAV)
  141. * @param errors_count1 Autopilot-specific errors
  142. * @param errors_count2 Autopilot-specific errors
  143. * @param errors_count3 Autopilot-specific errors
  144. * @param errors_count4 Autopilot-specific errors
  145. * @return length of the message in bytes (excluding serial stream start sign)
  146. */
  147. static inline uint16_t mavlink_msg_sys_status_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
  148. mavlink_message_t* msg,
  149. uint32_t onboard_control_sensors_present,uint32_t onboard_control_sensors_enabled,uint32_t onboard_control_sensors_health,uint16_t load,uint16_t voltage_battery,int16_t current_battery,int8_t battery_remaining,uint16_t drop_rate_comm,uint16_t errors_comm,uint16_t errors_count1,uint16_t errors_count2,uint16_t errors_count3,uint16_t errors_count4)
  150. {
  151. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  152. char buf[MAVLINK_MSG_ID_SYS_STATUS_LEN];
  153. _mav_put_uint32_t(buf, 0, onboard_control_sensors_present);
  154. _mav_put_uint32_t(buf, 4, onboard_control_sensors_enabled);
  155. _mav_put_uint32_t(buf, 8, onboard_control_sensors_health);
  156. _mav_put_uint16_t(buf, 12, load);
  157. _mav_put_uint16_t(buf, 14, voltage_battery);
  158. _mav_put_int16_t(buf, 16, current_battery);
  159. _mav_put_uint16_t(buf, 18, drop_rate_comm);
  160. _mav_put_uint16_t(buf, 20, errors_comm);
  161. _mav_put_uint16_t(buf, 22, errors_count1);
  162. _mav_put_uint16_t(buf, 24, errors_count2);
  163. _mav_put_uint16_t(buf, 26, errors_count3);
  164. _mav_put_uint16_t(buf, 28, errors_count4);
  165. _mav_put_int8_t(buf, 30, battery_remaining);
  166. memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_SYS_STATUS_LEN);
  167. #else
  168. mavlink_sys_status_t packet;
  169. packet.onboard_control_sensors_present = onboard_control_sensors_present;
  170. packet.onboard_control_sensors_enabled = onboard_control_sensors_enabled;
  171. packet.onboard_control_sensors_health = onboard_control_sensors_health;
  172. packet.load = load;
  173. packet.voltage_battery = voltage_battery;
  174. packet.current_battery = current_battery;
  175. packet.drop_rate_comm = drop_rate_comm;
  176. packet.errors_comm = errors_comm;
  177. packet.errors_count1 = errors_count1;
  178. packet.errors_count2 = errors_count2;
  179. packet.errors_count3 = errors_count3;
  180. packet.errors_count4 = errors_count4;
  181. packet.battery_remaining = battery_remaining;
  182. memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_SYS_STATUS_LEN);
  183. #endif
  184. msg->msgid = MAVLINK_MSG_ID_SYS_STATUS;
  185. return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_SYS_STATUS_MIN_LEN, MAVLINK_MSG_ID_SYS_STATUS_LEN, MAVLINK_MSG_ID_SYS_STATUS_CRC);
  186. }
  187. /**
  188. * @brief Encode a sys_status 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 sys_status C-struct to read the message contents from
  194. */
  195. static inline uint16_t mavlink_msg_sys_status_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_sys_status_t* sys_status)
  196. {
  197. return mavlink_msg_sys_status_pack(system_id, component_id, msg, sys_status->onboard_control_sensors_present, sys_status->onboard_control_sensors_enabled, sys_status->onboard_control_sensors_health, sys_status->load, sys_status->voltage_battery, sys_status->current_battery, sys_status->battery_remaining, sys_status->drop_rate_comm, sys_status->errors_comm, sys_status->errors_count1, sys_status->errors_count2, sys_status->errors_count3, sys_status->errors_count4);
  198. }
  199. /**
  200. * @brief Encode a sys_status 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 sys_status C-struct to read the message contents from
  207. */
  208. static inline uint16_t mavlink_msg_sys_status_encode_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, const mavlink_sys_status_t* sys_status)
  209. {
  210. return mavlink_msg_sys_status_pack_chan(system_id, component_id, chan, msg, sys_status->onboard_control_sensors_present, sys_status->onboard_control_sensors_enabled, sys_status->onboard_control_sensors_health, sys_status->load, sys_status->voltage_battery, sys_status->current_battery, sys_status->battery_remaining, sys_status->drop_rate_comm, sys_status->errors_comm, sys_status->errors_count1, sys_status->errors_count2, sys_status->errors_count3, sys_status->errors_count4);
  211. }
  212. /**
  213. * @brief Send a sys_status message
  214. * @param chan MAVLink channel to send the message
  215. *
  216. * @param onboard_control_sensors_present Bitmap showing which onboard controllers and sensors are present. Value of 0: not present. Value of 1: present.
  217. * @param onboard_control_sensors_enabled Bitmap showing which onboard controllers and sensors are enabled: Value of 0: not enabled. Value of 1: enabled.
  218. * @param onboard_control_sensors_health Bitmap showing which onboard controllers and sensors have an error (or are operational). Value of 0: error. Value of 1: healthy.
  219. * @param load [d%] Maximum usage in percent of the mainloop time. Values: [0-1000] - should always be below 1000
  220. * @param voltage_battery [mV] Battery voltage, UINT16_MAX: Voltage not sent by autopilot
  221. * @param current_battery [cA] Battery current, -1: Current not sent by autopilot
  222. * @param battery_remaining [%] Battery energy remaining, -1: Battery remaining energy not sent by autopilot
  223. * @param drop_rate_comm [c%] Communication drop rate, (UART, I2C, SPI, CAN), dropped packets on all links (packets that were corrupted on reception on the MAV)
  224. * @param errors_comm Communication errors (UART, I2C, SPI, CAN), dropped packets on all links (packets that were corrupted on reception on the MAV)
  225. * @param errors_count1 Autopilot-specific errors
  226. * @param errors_count2 Autopilot-specific errors
  227. * @param errors_count3 Autopilot-specific errors
  228. * @param errors_count4 Autopilot-specific errors
  229. */
  230. #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
  231. static inline void mavlink_msg_sys_status_send(mavlink_channel_t chan, uint32_t onboard_control_sensors_present, uint32_t onboard_control_sensors_enabled, uint32_t onboard_control_sensors_health, uint16_t load, uint16_t voltage_battery, int16_t current_battery, int8_t battery_remaining, uint16_t drop_rate_comm, uint16_t errors_comm, uint16_t errors_count1, uint16_t errors_count2, uint16_t errors_count3, uint16_t errors_count4)
  232. {
  233. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  234. char buf[MAVLINK_MSG_ID_SYS_STATUS_LEN];
  235. _mav_put_uint32_t(buf, 0, onboard_control_sensors_present);
  236. _mav_put_uint32_t(buf, 4, onboard_control_sensors_enabled);
  237. _mav_put_uint32_t(buf, 8, onboard_control_sensors_health);
  238. _mav_put_uint16_t(buf, 12, load);
  239. _mav_put_uint16_t(buf, 14, voltage_battery);
  240. _mav_put_int16_t(buf, 16, current_battery);
  241. _mav_put_uint16_t(buf, 18, drop_rate_comm);
  242. _mav_put_uint16_t(buf, 20, errors_comm);
  243. _mav_put_uint16_t(buf, 22, errors_count1);
  244. _mav_put_uint16_t(buf, 24, errors_count2);
  245. _mav_put_uint16_t(buf, 26, errors_count3);
  246. _mav_put_uint16_t(buf, 28, errors_count4);
  247. _mav_put_int8_t(buf, 30, battery_remaining);
  248. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_SYS_STATUS, buf, MAVLINK_MSG_ID_SYS_STATUS_MIN_LEN, MAVLINK_MSG_ID_SYS_STATUS_LEN, MAVLINK_MSG_ID_SYS_STATUS_CRC);
  249. #else
  250. mavlink_sys_status_t packet;
  251. packet.onboard_control_sensors_present = onboard_control_sensors_present;
  252. packet.onboard_control_sensors_enabled = onboard_control_sensors_enabled;
  253. packet.onboard_control_sensors_health = onboard_control_sensors_health;
  254. packet.load = load;
  255. packet.voltage_battery = voltage_battery;
  256. packet.current_battery = current_battery;
  257. packet.drop_rate_comm = drop_rate_comm;
  258. packet.errors_comm = errors_comm;
  259. packet.errors_count1 = errors_count1;
  260. packet.errors_count2 = errors_count2;
  261. packet.errors_count3 = errors_count3;
  262. packet.errors_count4 = errors_count4;
  263. packet.battery_remaining = battery_remaining;
  264. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_SYS_STATUS, (const char *)&packet, MAVLINK_MSG_ID_SYS_STATUS_MIN_LEN, MAVLINK_MSG_ID_SYS_STATUS_LEN, MAVLINK_MSG_ID_SYS_STATUS_CRC);
  265. #endif
  266. }
  267. /**
  268. * @brief Send a sys_status 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_sys_status_send_struct(mavlink_channel_t chan, const mavlink_sys_status_t* sys_status)
  273. {
  274. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  275. mavlink_msg_sys_status_send(chan, sys_status->onboard_control_sensors_present, sys_status->onboard_control_sensors_enabled, sys_status->onboard_control_sensors_health, sys_status->load, sys_status->voltage_battery, sys_status->current_battery, sys_status->battery_remaining, sys_status->drop_rate_comm, sys_status->errors_comm, sys_status->errors_count1, sys_status->errors_count2, sys_status->errors_count3, sys_status->errors_count4);
  276. #else
  277. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_SYS_STATUS, (const char *)sys_status, MAVLINK_MSG_ID_SYS_STATUS_MIN_LEN, MAVLINK_MSG_ID_SYS_STATUS_LEN, MAVLINK_MSG_ID_SYS_STATUS_CRC);
  278. #endif
  279. }
  280. #if MAVLINK_MSG_ID_SYS_STATUS_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_sys_status_send_buf(mavlink_message_t *msgbuf, mavlink_channel_t chan, uint32_t onboard_control_sensors_present, uint32_t onboard_control_sensors_enabled, uint32_t onboard_control_sensors_health, uint16_t load, uint16_t voltage_battery, int16_t current_battery, int8_t battery_remaining, uint16_t drop_rate_comm, uint16_t errors_comm, uint16_t errors_count1, uint16_t errors_count2, uint16_t errors_count3, uint16_t errors_count4)
  289. {
  290. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  291. char *buf = (char *)msgbuf;
  292. _mav_put_uint32_t(buf, 0, onboard_control_sensors_present);
  293. _mav_put_uint32_t(buf, 4, onboard_control_sensors_enabled);
  294. _mav_put_uint32_t(buf, 8, onboard_control_sensors_health);
  295. _mav_put_uint16_t(buf, 12, load);
  296. _mav_put_uint16_t(buf, 14, voltage_battery);
  297. _mav_put_int16_t(buf, 16, current_battery);
  298. _mav_put_uint16_t(buf, 18, drop_rate_comm);
  299. _mav_put_uint16_t(buf, 20, errors_comm);
  300. _mav_put_uint16_t(buf, 22, errors_count1);
  301. _mav_put_uint16_t(buf, 24, errors_count2);
  302. _mav_put_uint16_t(buf, 26, errors_count3);
  303. _mav_put_uint16_t(buf, 28, errors_count4);
  304. _mav_put_int8_t(buf, 30, battery_remaining);
  305. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_SYS_STATUS, buf, MAVLINK_MSG_ID_SYS_STATUS_MIN_LEN, MAVLINK_MSG_ID_SYS_STATUS_LEN, MAVLINK_MSG_ID_SYS_STATUS_CRC);
  306. #else
  307. mavlink_sys_status_t *packet = (mavlink_sys_status_t *)msgbuf;
  308. packet->onboard_control_sensors_present = onboard_control_sensors_present;
  309. packet->onboard_control_sensors_enabled = onboard_control_sensors_enabled;
  310. packet->onboard_control_sensors_health = onboard_control_sensors_health;
  311. packet->load = load;
  312. packet->voltage_battery = voltage_battery;
  313. packet->current_battery = current_battery;
  314. packet->drop_rate_comm = drop_rate_comm;
  315. packet->errors_comm = errors_comm;
  316. packet->errors_count1 = errors_count1;
  317. packet->errors_count2 = errors_count2;
  318. packet->errors_count3 = errors_count3;
  319. packet->errors_count4 = errors_count4;
  320. packet->battery_remaining = battery_remaining;
  321. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_SYS_STATUS, (const char *)packet, MAVLINK_MSG_ID_SYS_STATUS_MIN_LEN, MAVLINK_MSG_ID_SYS_STATUS_LEN, MAVLINK_MSG_ID_SYS_STATUS_CRC);
  322. #endif
  323. }
  324. #endif
  325. #endif
  326. // MESSAGE SYS_STATUS UNPACKING
  327. /**
  328. * @brief Get field onboard_control_sensors_present from sys_status message
  329. *
  330. * @return Bitmap showing which onboard controllers and sensors are present. Value of 0: not present. Value of 1: present.
  331. */
  332. static inline uint32_t mavlink_msg_sys_status_get_onboard_control_sensors_present(const mavlink_message_t* msg)
  333. {
  334. return _MAV_RETURN_uint32_t(msg, 0);
  335. }
  336. /**
  337. * @brief Get field onboard_control_sensors_enabled from sys_status message
  338. *
  339. * @return Bitmap showing which onboard controllers and sensors are enabled: Value of 0: not enabled. Value of 1: enabled.
  340. */
  341. static inline uint32_t mavlink_msg_sys_status_get_onboard_control_sensors_enabled(const mavlink_message_t* msg)
  342. {
  343. return _MAV_RETURN_uint32_t(msg, 4);
  344. }
  345. /**
  346. * @brief Get field onboard_control_sensors_health from sys_status message
  347. *
  348. * @return Bitmap showing which onboard controllers and sensors have an error (or are operational). Value of 0: error. Value of 1: healthy.
  349. */
  350. static inline uint32_t mavlink_msg_sys_status_get_onboard_control_sensors_health(const mavlink_message_t* msg)
  351. {
  352. return _MAV_RETURN_uint32_t(msg, 8);
  353. }
  354. /**
  355. * @brief Get field load from sys_status message
  356. *
  357. * @return [d%] Maximum usage in percent of the mainloop time. Values: [0-1000] - should always be below 1000
  358. */
  359. static inline uint16_t mavlink_msg_sys_status_get_load(const mavlink_message_t* msg)
  360. {
  361. return _MAV_RETURN_uint16_t(msg, 12);
  362. }
  363. /**
  364. * @brief Get field voltage_battery from sys_status message
  365. *
  366. * @return [mV] Battery voltage, UINT16_MAX: Voltage not sent by autopilot
  367. */
  368. static inline uint16_t mavlink_msg_sys_status_get_voltage_battery(const mavlink_message_t* msg)
  369. {
  370. return _MAV_RETURN_uint16_t(msg, 14);
  371. }
  372. /**
  373. * @brief Get field current_battery from sys_status message
  374. *
  375. * @return [cA] Battery current, -1: Current not sent by autopilot
  376. */
  377. static inline int16_t mavlink_msg_sys_status_get_current_battery(const mavlink_message_t* msg)
  378. {
  379. return _MAV_RETURN_int16_t(msg, 16);
  380. }
  381. /**
  382. * @brief Get field battery_remaining from sys_status message
  383. *
  384. * @return [%] Battery energy remaining, -1: Battery remaining energy not sent by autopilot
  385. */
  386. static inline int8_t mavlink_msg_sys_status_get_battery_remaining(const mavlink_message_t* msg)
  387. {
  388. return _MAV_RETURN_int8_t(msg, 30);
  389. }
  390. /**
  391. * @brief Get field drop_rate_comm from sys_status message
  392. *
  393. * @return [c%] Communication drop rate, (UART, I2C, SPI, CAN), dropped packets on all links (packets that were corrupted on reception on the MAV)
  394. */
  395. static inline uint16_t mavlink_msg_sys_status_get_drop_rate_comm(const mavlink_message_t* msg)
  396. {
  397. return _MAV_RETURN_uint16_t(msg, 18);
  398. }
  399. /**
  400. * @brief Get field errors_comm from sys_status message
  401. *
  402. * @return Communication errors (UART, I2C, SPI, CAN), dropped packets on all links (packets that were corrupted on reception on the MAV)
  403. */
  404. static inline uint16_t mavlink_msg_sys_status_get_errors_comm(const mavlink_message_t* msg)
  405. {
  406. return _MAV_RETURN_uint16_t(msg, 20);
  407. }
  408. /**
  409. * @brief Get field errors_count1 from sys_status message
  410. *
  411. * @return Autopilot-specific errors
  412. */
  413. static inline uint16_t mavlink_msg_sys_status_get_errors_count1(const mavlink_message_t* msg)
  414. {
  415. return _MAV_RETURN_uint16_t(msg, 22);
  416. }
  417. /**
  418. * @brief Get field errors_count2 from sys_status message
  419. *
  420. * @return Autopilot-specific errors
  421. */
  422. static inline uint16_t mavlink_msg_sys_status_get_errors_count2(const mavlink_message_t* msg)
  423. {
  424. return _MAV_RETURN_uint16_t(msg, 24);
  425. }
  426. /**
  427. * @brief Get field errors_count3 from sys_status message
  428. *
  429. * @return Autopilot-specific errors
  430. */
  431. static inline uint16_t mavlink_msg_sys_status_get_errors_count3(const mavlink_message_t* msg)
  432. {
  433. return _MAV_RETURN_uint16_t(msg, 26);
  434. }
  435. /**
  436. * @brief Get field errors_count4 from sys_status message
  437. *
  438. * @return Autopilot-specific errors
  439. */
  440. static inline uint16_t mavlink_msg_sys_status_get_errors_count4(const mavlink_message_t* msg)
  441. {
  442. return _MAV_RETURN_uint16_t(msg, 28);
  443. }
  444. /**
  445. * @brief Decode a sys_status message into a struct
  446. *
  447. * @param msg The message to decode
  448. * @param sys_status C-struct to decode the message contents into
  449. */
  450. static inline void mavlink_msg_sys_status_decode(const mavlink_message_t* msg, mavlink_sys_status_t* sys_status)
  451. {
  452. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  453. sys_status->onboard_control_sensors_present = mavlink_msg_sys_status_get_onboard_control_sensors_present(msg);
  454. sys_status->onboard_control_sensors_enabled = mavlink_msg_sys_status_get_onboard_control_sensors_enabled(msg);
  455. sys_status->onboard_control_sensors_health = mavlink_msg_sys_status_get_onboard_control_sensors_health(msg);
  456. sys_status->load = mavlink_msg_sys_status_get_load(msg);
  457. sys_status->voltage_battery = mavlink_msg_sys_status_get_voltage_battery(msg);
  458. sys_status->current_battery = mavlink_msg_sys_status_get_current_battery(msg);
  459. sys_status->drop_rate_comm = mavlink_msg_sys_status_get_drop_rate_comm(msg);
  460. sys_status->errors_comm = mavlink_msg_sys_status_get_errors_comm(msg);
  461. sys_status->errors_count1 = mavlink_msg_sys_status_get_errors_count1(msg);
  462. sys_status->errors_count2 = mavlink_msg_sys_status_get_errors_count2(msg);
  463. sys_status->errors_count3 = mavlink_msg_sys_status_get_errors_count3(msg);
  464. sys_status->errors_count4 = mavlink_msg_sys_status_get_errors_count4(msg);
  465. sys_status->battery_remaining = mavlink_msg_sys_status_get_battery_remaining(msg);
  466. #else
  467. uint8_t len = msg->len < MAVLINK_MSG_ID_SYS_STATUS_LEN? msg->len : MAVLINK_MSG_ID_SYS_STATUS_LEN;
  468. memset(sys_status, 0, MAVLINK_MSG_ID_SYS_STATUS_LEN);
  469. memcpy(sys_status, _MAV_PAYLOAD(msg), len);
  470. #endif
  471. }