mavlink_msg_sys_status.h 31.7 KB
Newer Older
James Goppert's avatar
James Goppert committed
1 2
// MESSAGE SYS_STATUS PACKING

3
#define MAVLINK_MSG_ID_SYS_STATUS 1
James Goppert's avatar
James Goppert committed
4

lm's avatar
lm committed
5
typedef struct __mavlink_sys_status_t
James Goppert's avatar
James Goppert committed
6
{
lm's avatar
lm committed
7 8 9 10 11 12 13 14 15 16 17 18
 uint16_t onboard_control_sensors_present; ///< Bitmask showing which onboard controllers and sensors are present. Value of 0: not present. Value of 1: present. Indices: 0: 3D gyro, 1: 3D acc, 2: 3D mag, 3: absolute pressure, 4: differential pressure, 5: GPS, 6: optical flow, 7: computer vision position, 8: laser based position, 9: external ground-truth (Vicon or Leica). Controllers: 10: 3D angular rate control 11: attitude stabilization, 12: yaw position, 13: z/altitude control, 14: x/y position control, 15: motor outputs / control
 uint16_t onboard_control_sensors_enabled; ///< Bitmask showing which onboard controllers and sensors are enabled:  Value of 0: not enabled. Value of 1: enabled. Indices: 0: 3D gyro, 1: 3D acc, 2: 3D mag, 3: absolute pressure, 4: differential pressure, 5: GPS, 6: optical flow, 7: computer vision position, 8: laser based position, 9: external ground-truth (Vicon or Leica). Controllers: 10: 3D angular rate control 11: attitude stabilization, 12: yaw position, 13: z/altitude control, 14: x/y position control, 15: motor outputs / control
 uint16_t onboard_control_sensors_health; ///< Bitmask showing which onboard controllers and sensors are operational or have an error:  Value of 0: not enabled. Value of 1: enabled. Indices: 0: 3D gyro, 1: 3D acc, 2: 3D mag, 3: absolute pressure, 4: differential pressure, 5: GPS, 6: optical flow, 7: computer vision position, 8: laser based position, 9: external ground-truth (Vicon or Leica). Controllers: 10: 3D angular rate control 11: attitude stabilization, 12: yaw position, 13: z/altitude control, 14: x/y position control, 15: motor outputs / control
 uint16_t load; ///< Maximum usage in percent of the mainloop time, (0%: 0, 100%: 1000) should be always below 1000
 uint16_t voltage_battery; ///< Battery voltage, in millivolts (1 = 1 millivolt)
 uint16_t current_battery; ///< Battery current, in milliamperes (1 = 1 milliampere)
 uint16_t watt; ///< Watts consumed from this battery since startup
 uint16_t errors_uart; ///< Dropped packets on all links (packets that were corrupted on reception on the MAV)
 uint16_t errors_i2c; ///< Dropped packets on all links (packets that were corrupted on reception)
 uint16_t errors_spi; ///< Dropped packets on all links (packets that were corrupted on reception)
 uint16_t errors_can; ///< Dropped packets on all links (packets that were corrupted on reception)
 uint8_t battery_percent; ///< Remaining battery energy: (0%: 0, 100%: 255)
James Goppert's avatar
James Goppert committed
19 20
} mavlink_sys_status_t;

lm's avatar
lm committed
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
#define MAVLINK_MSG_ID_SYS_STATUS_LEN 23
#define MAVLINK_MSG_ID_1_LEN 23



#define MAVLINK_MESSAGE_INFO_SYS_STATUS { \
	"SYS_STATUS", \
	12, \
	{  { "onboard_control_sensors_present", MAVLINK_TYPE_UINT16_T, 0, 0, offsetof(mavlink_sys_status_t, onboard_control_sensors_present) }, \
         { "onboard_control_sensors_enabled", MAVLINK_TYPE_UINT16_T, 0, 2, offsetof(mavlink_sys_status_t, onboard_control_sensors_enabled) }, \
         { "onboard_control_sensors_health", MAVLINK_TYPE_UINT16_T, 0, 4, offsetof(mavlink_sys_status_t, onboard_control_sensors_health) }, \
         { "load", MAVLINK_TYPE_UINT16_T, 0, 6, offsetof(mavlink_sys_status_t, load) }, \
         { "voltage_battery", MAVLINK_TYPE_UINT16_T, 0, 8, offsetof(mavlink_sys_status_t, voltage_battery) }, \
         { "current_battery", MAVLINK_TYPE_UINT16_T, 0, 10, offsetof(mavlink_sys_status_t, current_battery) }, \
         { "watt", MAVLINK_TYPE_UINT16_T, 0, 12, offsetof(mavlink_sys_status_t, watt) }, \
         { "errors_uart", MAVLINK_TYPE_UINT16_T, 0, 14, offsetof(mavlink_sys_status_t, errors_uart) }, \
         { "errors_i2c", MAVLINK_TYPE_UINT16_T, 0, 16, offsetof(mavlink_sys_status_t, errors_i2c) }, \
         { "errors_spi", MAVLINK_TYPE_UINT16_T, 0, 18, offsetof(mavlink_sys_status_t, errors_spi) }, \
         { "errors_can", MAVLINK_TYPE_UINT16_T, 0, 20, offsetof(mavlink_sys_status_t, errors_can) }, \
         { "battery_percent", MAVLINK_TYPE_UINT8_T, 0, 22, offsetof(mavlink_sys_status_t, battery_percent) }, \
         } \
}


James Goppert's avatar
James Goppert committed
45 46 47 48 49 50
/**
 * @brief Pack a sys_status message
 * @param system_id ID of this system
 * @param component_id ID of this component (e.g. 200 for IMU)
 * @param msg The MAVLink message to compress the data into
 *
51 52 53
 * @param onboard_control_sensors_present Bitmask showing which onboard controllers and sensors are present. Value of 0: not present. Value of 1: present. Indices: 0: 3D gyro, 1: 3D acc, 2: 3D mag, 3: absolute pressure, 4: differential pressure, 5: GPS, 6: optical flow, 7: computer vision position, 8: laser based position, 9: external ground-truth (Vicon or Leica). Controllers: 10: 3D angular rate control 11: attitude stabilization, 12: yaw position, 13: z/altitude control, 14: x/y position control, 15: motor outputs / control
 * @param onboard_control_sensors_enabled Bitmask showing which onboard controllers and sensors are enabled:  Value of 0: not enabled. Value of 1: enabled. Indices: 0: 3D gyro, 1: 3D acc, 2: 3D mag, 3: absolute pressure, 4: differential pressure, 5: GPS, 6: optical flow, 7: computer vision position, 8: laser based position, 9: external ground-truth (Vicon or Leica). Controllers: 10: 3D angular rate control 11: attitude stabilization, 12: yaw position, 13: z/altitude control, 14: x/y position control, 15: motor outputs / control
 * @param onboard_control_sensors_health Bitmask showing which onboard controllers and sensors are operational or have an error:  Value of 0: not enabled. Value of 1: enabled. Indices: 0: 3D gyro, 1: 3D acc, 2: 3D mag, 3: absolute pressure, 4: differential pressure, 5: GPS, 6: optical flow, 7: computer vision position, 8: laser based position, 9: external ground-truth (Vicon or Leica). Controllers: 10: 3D angular rate control 11: attitude stabilization, 12: yaw position, 13: z/altitude control, 14: x/y position control, 15: motor outputs / control
James Goppert's avatar
James Goppert committed
54
 * @param load Maximum usage in percent of the mainloop time, (0%: 0, 100%: 1000) should be always below 1000
55 56 57 58 59 60 61 62
 * @param voltage_battery Battery voltage, in millivolts (1 = 1 millivolt)
 * @param current_battery Battery current, in milliamperes (1 = 1 milliampere)
 * @param watt Watts consumed from this battery since startup
 * @param battery_percent Remaining battery energy: (0%: 0, 100%: 255)
 * @param errors_uart Dropped packets on all links (packets that were corrupted on reception on the MAV)
 * @param errors_i2c Dropped packets on all links (packets that were corrupted on reception)
 * @param errors_spi Dropped packets on all links (packets that were corrupted on reception)
 * @param errors_can Dropped packets on all links (packets that were corrupted on reception)
James Goppert's avatar
James Goppert committed
63 64
 * @return length of the message in bytes (excluding serial stream start sign)
 */
lm's avatar
lm committed
65 66
static inline uint16_t mavlink_msg_sys_status_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
						       uint16_t onboard_control_sensors_present, uint16_t onboard_control_sensors_enabled, uint16_t onboard_control_sensors_health, uint16_t load, uint16_t voltage_battery, uint16_t current_battery, uint16_t watt, uint8_t battery_percent, uint16_t errors_uart, uint16_t errors_i2c, uint16_t errors_spi, uint16_t errors_can)
James Goppert's avatar
James Goppert committed
67 68 69
{
	msg->msgid = MAVLINK_MSG_ID_SYS_STATUS;

lm's avatar
lm committed
70 71 72 73 74 75 76 77 78 79 80 81 82 83
	put_uint16_t_by_index(msg, 0, onboard_control_sensors_present); // Bitmask showing which onboard controllers and sensors are present. Value of 0: not present. Value of 1: present. Indices: 0: 3D gyro, 1: 3D acc, 2: 3D mag, 3: absolute pressure, 4: differential pressure, 5: GPS, 6: optical flow, 7: computer vision position, 8: laser based position, 9: external ground-truth (Vicon or Leica). Controllers: 10: 3D angular rate control 11: attitude stabilization, 12: yaw position, 13: z/altitude control, 14: x/y position control, 15: motor outputs / control
	put_uint16_t_by_index(msg, 2, onboard_control_sensors_enabled); // Bitmask showing which onboard controllers and sensors are enabled:  Value of 0: not enabled. Value of 1: enabled. Indices: 0: 3D gyro, 1: 3D acc, 2: 3D mag, 3: absolute pressure, 4: differential pressure, 5: GPS, 6: optical flow, 7: computer vision position, 8: laser based position, 9: external ground-truth (Vicon or Leica). Controllers: 10: 3D angular rate control 11: attitude stabilization, 12: yaw position, 13: z/altitude control, 14: x/y position control, 15: motor outputs / control
	put_uint16_t_by_index(msg, 4, onboard_control_sensors_health); // Bitmask showing which onboard controllers and sensors are operational or have an error:  Value of 0: not enabled. Value of 1: enabled. Indices: 0: 3D gyro, 1: 3D acc, 2: 3D mag, 3: absolute pressure, 4: differential pressure, 5: GPS, 6: optical flow, 7: computer vision position, 8: laser based position, 9: external ground-truth (Vicon or Leica). Controllers: 10: 3D angular rate control 11: attitude stabilization, 12: yaw position, 13: z/altitude control, 14: x/y position control, 15: motor outputs / control
	put_uint16_t_by_index(msg, 6, load); // Maximum usage in percent of the mainloop time, (0%: 0, 100%: 1000) should be always below 1000
	put_uint16_t_by_index(msg, 8, voltage_battery); // Battery voltage, in millivolts (1 = 1 millivolt)
	put_uint16_t_by_index(msg, 10, current_battery); // Battery current, in milliamperes (1 = 1 milliampere)
	put_uint16_t_by_index(msg, 12, watt); // Watts consumed from this battery since startup
	put_uint16_t_by_index(msg, 14, errors_uart); // Dropped packets on all links (packets that were corrupted on reception on the MAV)
	put_uint16_t_by_index(msg, 16, errors_i2c); // Dropped packets on all links (packets that were corrupted on reception)
	put_uint16_t_by_index(msg, 18, errors_spi); // Dropped packets on all links (packets that were corrupted on reception)
	put_uint16_t_by_index(msg, 20, errors_can); // Dropped packets on all links (packets that were corrupted on reception)
	put_uint8_t_by_index(msg, 22, battery_percent); // Remaining battery energy: (0%: 0, 100%: 255)

	return mavlink_finalize_message(msg, system_id, component_id, 23, 114);
James Goppert's avatar
James Goppert committed
84 85 86
}

/**
lm's avatar
lm committed
87
 * @brief Pack a sys_status message on a channel
James Goppert's avatar
James Goppert committed
88 89 90 91
 * @param system_id ID of this system
 * @param component_id ID of this component (e.g. 200 for IMU)
 * @param chan The MAVLink channel this message was sent over
 * @param msg The MAVLink message to compress the data into
92 93 94
 * @param onboard_control_sensors_present Bitmask showing which onboard controllers and sensors are present. Value of 0: not present. Value of 1: present. Indices: 0: 3D gyro, 1: 3D acc, 2: 3D mag, 3: absolute pressure, 4: differential pressure, 5: GPS, 6: optical flow, 7: computer vision position, 8: laser based position, 9: external ground-truth (Vicon or Leica). Controllers: 10: 3D angular rate control 11: attitude stabilization, 12: yaw position, 13: z/altitude control, 14: x/y position control, 15: motor outputs / control
 * @param onboard_control_sensors_enabled Bitmask showing which onboard controllers and sensors are enabled:  Value of 0: not enabled. Value of 1: enabled. Indices: 0: 3D gyro, 1: 3D acc, 2: 3D mag, 3: absolute pressure, 4: differential pressure, 5: GPS, 6: optical flow, 7: computer vision position, 8: laser based position, 9: external ground-truth (Vicon or Leica). Controllers: 10: 3D angular rate control 11: attitude stabilization, 12: yaw position, 13: z/altitude control, 14: x/y position control, 15: motor outputs / control
 * @param onboard_control_sensors_health Bitmask showing which onboard controllers and sensors are operational or have an error:  Value of 0: not enabled. Value of 1: enabled. Indices: 0: 3D gyro, 1: 3D acc, 2: 3D mag, 3: absolute pressure, 4: differential pressure, 5: GPS, 6: optical flow, 7: computer vision position, 8: laser based position, 9: external ground-truth (Vicon or Leica). Controllers: 10: 3D angular rate control 11: attitude stabilization, 12: yaw position, 13: z/altitude control, 14: x/y position control, 15: motor outputs / control
James Goppert's avatar
James Goppert committed
95
 * @param load Maximum usage in percent of the mainloop time, (0%: 0, 100%: 1000) should be always below 1000
96 97 98 99 100 101 102 103
 * @param voltage_battery Battery voltage, in millivolts (1 = 1 millivolt)
 * @param current_battery Battery current, in milliamperes (1 = 1 milliampere)
 * @param watt Watts consumed from this battery since startup
 * @param battery_percent Remaining battery energy: (0%: 0, 100%: 255)
 * @param errors_uart Dropped packets on all links (packets that were corrupted on reception on the MAV)
 * @param errors_i2c Dropped packets on all links (packets that were corrupted on reception)
 * @param errors_spi Dropped packets on all links (packets that were corrupted on reception)
 * @param errors_can Dropped packets on all links (packets that were corrupted on reception)
James Goppert's avatar
James Goppert committed
104 105
 * @return length of the message in bytes (excluding serial stream start sign)
 */
lm's avatar
lm committed
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149
static inline uint16_t mavlink_msg_sys_status_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
							   mavlink_message_t* msg,
						           uint16_t onboard_control_sensors_present,uint16_t onboard_control_sensors_enabled,uint16_t onboard_control_sensors_health,uint16_t load,uint16_t voltage_battery,uint16_t current_battery,uint16_t watt,uint8_t battery_percent,uint16_t errors_uart,uint16_t errors_i2c,uint16_t errors_spi,uint16_t errors_can)
{
	msg->msgid = MAVLINK_MSG_ID_SYS_STATUS;

	put_uint16_t_by_index(msg, 0, onboard_control_sensors_present); // Bitmask showing which onboard controllers and sensors are present. Value of 0: not present. Value of 1: present. Indices: 0: 3D gyro, 1: 3D acc, 2: 3D mag, 3: absolute pressure, 4: differential pressure, 5: GPS, 6: optical flow, 7: computer vision position, 8: laser based position, 9: external ground-truth (Vicon or Leica). Controllers: 10: 3D angular rate control 11: attitude stabilization, 12: yaw position, 13: z/altitude control, 14: x/y position control, 15: motor outputs / control
	put_uint16_t_by_index(msg, 2, onboard_control_sensors_enabled); // Bitmask showing which onboard controllers and sensors are enabled:  Value of 0: not enabled. Value of 1: enabled. Indices: 0: 3D gyro, 1: 3D acc, 2: 3D mag, 3: absolute pressure, 4: differential pressure, 5: GPS, 6: optical flow, 7: computer vision position, 8: laser based position, 9: external ground-truth (Vicon or Leica). Controllers: 10: 3D angular rate control 11: attitude stabilization, 12: yaw position, 13: z/altitude control, 14: x/y position control, 15: motor outputs / control
	put_uint16_t_by_index(msg, 4, onboard_control_sensors_health); // Bitmask showing which onboard controllers and sensors are operational or have an error:  Value of 0: not enabled. Value of 1: enabled. Indices: 0: 3D gyro, 1: 3D acc, 2: 3D mag, 3: absolute pressure, 4: differential pressure, 5: GPS, 6: optical flow, 7: computer vision position, 8: laser based position, 9: external ground-truth (Vicon or Leica). Controllers: 10: 3D angular rate control 11: attitude stabilization, 12: yaw position, 13: z/altitude control, 14: x/y position control, 15: motor outputs / control
	put_uint16_t_by_index(msg, 6, load); // Maximum usage in percent of the mainloop time, (0%: 0, 100%: 1000) should be always below 1000
	put_uint16_t_by_index(msg, 8, voltage_battery); // Battery voltage, in millivolts (1 = 1 millivolt)
	put_uint16_t_by_index(msg, 10, current_battery); // Battery current, in milliamperes (1 = 1 milliampere)
	put_uint16_t_by_index(msg, 12, watt); // Watts consumed from this battery since startup
	put_uint16_t_by_index(msg, 14, errors_uart); // Dropped packets on all links (packets that were corrupted on reception on the MAV)
	put_uint16_t_by_index(msg, 16, errors_i2c); // Dropped packets on all links (packets that were corrupted on reception)
	put_uint16_t_by_index(msg, 18, errors_spi); // Dropped packets on all links (packets that were corrupted on reception)
	put_uint16_t_by_index(msg, 20, errors_can); // Dropped packets on all links (packets that were corrupted on reception)
	put_uint8_t_by_index(msg, 22, battery_percent); // Remaining battery energy: (0%: 0, 100%: 255)

	return mavlink_finalize_message_chan(msg, system_id, component_id, chan, 23, 114);
}

#ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS

/**
 * @brief Pack a sys_status message on a channel and send
 * @param chan The MAVLink channel this message was sent over
 * @param msg The MAVLink message to compress the data into
 * @param onboard_control_sensors_present Bitmask showing which onboard controllers and sensors are present. Value of 0: not present. Value of 1: present. Indices: 0: 3D gyro, 1: 3D acc, 2: 3D mag, 3: absolute pressure, 4: differential pressure, 5: GPS, 6: optical flow, 7: computer vision position, 8: laser based position, 9: external ground-truth (Vicon or Leica). Controllers: 10: 3D angular rate control 11: attitude stabilization, 12: yaw position, 13: z/altitude control, 14: x/y position control, 15: motor outputs / control
 * @param onboard_control_sensors_enabled Bitmask showing which onboard controllers and sensors are enabled:  Value of 0: not enabled. Value of 1: enabled. Indices: 0: 3D gyro, 1: 3D acc, 2: 3D mag, 3: absolute pressure, 4: differential pressure, 5: GPS, 6: optical flow, 7: computer vision position, 8: laser based position, 9: external ground-truth (Vicon or Leica). Controllers: 10: 3D angular rate control 11: attitude stabilization, 12: yaw position, 13: z/altitude control, 14: x/y position control, 15: motor outputs / control
 * @param onboard_control_sensors_health Bitmask showing which onboard controllers and sensors are operational or have an error:  Value of 0: not enabled. Value of 1: enabled. Indices: 0: 3D gyro, 1: 3D acc, 2: 3D mag, 3: absolute pressure, 4: differential pressure, 5: GPS, 6: optical flow, 7: computer vision position, 8: laser based position, 9: external ground-truth (Vicon or Leica). Controllers: 10: 3D angular rate control 11: attitude stabilization, 12: yaw position, 13: z/altitude control, 14: x/y position control, 15: motor outputs / control
 * @param load Maximum usage in percent of the mainloop time, (0%: 0, 100%: 1000) should be always below 1000
 * @param voltage_battery Battery voltage, in millivolts (1 = 1 millivolt)
 * @param current_battery Battery current, in milliamperes (1 = 1 milliampere)
 * @param watt Watts consumed from this battery since startup
 * @param battery_percent Remaining battery energy: (0%: 0, 100%: 255)
 * @param errors_uart Dropped packets on all links (packets that were corrupted on reception on the MAV)
 * @param errors_i2c Dropped packets on all links (packets that were corrupted on reception)
 * @param errors_spi Dropped packets on all links (packets that were corrupted on reception)
 * @param errors_can Dropped packets on all links (packets that were corrupted on reception)
 */
static inline void mavlink_msg_sys_status_pack_chan_send(mavlink_channel_t chan,
							   mavlink_message_t* msg,
						           uint16_t onboard_control_sensors_present,uint16_t onboard_control_sensors_enabled,uint16_t onboard_control_sensors_health,uint16_t load,uint16_t voltage_battery,uint16_t current_battery,uint16_t watt,uint8_t battery_percent,uint16_t errors_uart,uint16_t errors_i2c,uint16_t errors_spi,uint16_t errors_can)
James Goppert's avatar
James Goppert committed
150 151 152
{
	msg->msgid = MAVLINK_MSG_ID_SYS_STATUS;

lm's avatar
lm committed
153 154 155 156 157 158 159 160 161 162 163 164 165 166
	put_uint16_t_by_index(msg, 0, onboard_control_sensors_present); // Bitmask showing which onboard controllers and sensors are present. Value of 0: not present. Value of 1: present. Indices: 0: 3D gyro, 1: 3D acc, 2: 3D mag, 3: absolute pressure, 4: differential pressure, 5: GPS, 6: optical flow, 7: computer vision position, 8: laser based position, 9: external ground-truth (Vicon or Leica). Controllers: 10: 3D angular rate control 11: attitude stabilization, 12: yaw position, 13: z/altitude control, 14: x/y position control, 15: motor outputs / control
	put_uint16_t_by_index(msg, 2, onboard_control_sensors_enabled); // Bitmask showing which onboard controllers and sensors are enabled:  Value of 0: not enabled. Value of 1: enabled. Indices: 0: 3D gyro, 1: 3D acc, 2: 3D mag, 3: absolute pressure, 4: differential pressure, 5: GPS, 6: optical flow, 7: computer vision position, 8: laser based position, 9: external ground-truth (Vicon or Leica). Controllers: 10: 3D angular rate control 11: attitude stabilization, 12: yaw position, 13: z/altitude control, 14: x/y position control, 15: motor outputs / control
	put_uint16_t_by_index(msg, 4, onboard_control_sensors_health); // Bitmask showing which onboard controllers and sensors are operational or have an error:  Value of 0: not enabled. Value of 1: enabled. Indices: 0: 3D gyro, 1: 3D acc, 2: 3D mag, 3: absolute pressure, 4: differential pressure, 5: GPS, 6: optical flow, 7: computer vision position, 8: laser based position, 9: external ground-truth (Vicon or Leica). Controllers: 10: 3D angular rate control 11: attitude stabilization, 12: yaw position, 13: z/altitude control, 14: x/y position control, 15: motor outputs / control
	put_uint16_t_by_index(msg, 6, load); // Maximum usage in percent of the mainloop time, (0%: 0, 100%: 1000) should be always below 1000
	put_uint16_t_by_index(msg, 8, voltage_battery); // Battery voltage, in millivolts (1 = 1 millivolt)
	put_uint16_t_by_index(msg, 10, current_battery); // Battery current, in milliamperes (1 = 1 milliampere)
	put_uint16_t_by_index(msg, 12, watt); // Watts consumed from this battery since startup
	put_uint16_t_by_index(msg, 14, errors_uart); // Dropped packets on all links (packets that were corrupted on reception on the MAV)
	put_uint16_t_by_index(msg, 16, errors_i2c); // Dropped packets on all links (packets that were corrupted on reception)
	put_uint16_t_by_index(msg, 18, errors_spi); // Dropped packets on all links (packets that were corrupted on reception)
	put_uint16_t_by_index(msg, 20, errors_can); // Dropped packets on all links (packets that were corrupted on reception)
	put_uint8_t_by_index(msg, 22, battery_percent); // Remaining battery energy: (0%: 0, 100%: 255)

	mavlink_finalize_message_chan_send(msg, chan, 23, 114);
James Goppert's avatar
James Goppert committed
167
}
lm's avatar
lm committed
168 169
#endif // MAVLINK_USE_CONVENIENCE_FUNCTIONS

James Goppert's avatar
James Goppert committed
170 171 172 173 174 175 176 177 178 179 180

/**
 * @brief Encode a sys_status struct into a message
 *
 * @param system_id ID of this system
 * @param component_id ID of this component (e.g. 200 for IMU)
 * @param msg The MAVLink message to compress the data into
 * @param sys_status C-struct to read the message contents from
 */
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)
{
181
	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->watt, sys_status->battery_percent, sys_status->errors_uart, sys_status->errors_i2c, sys_status->errors_spi, sys_status->errors_can);
James Goppert's avatar
James Goppert committed
182 183 184 185 186 187
}

/**
 * @brief Send a sys_status message
 * @param chan MAVLink channel to send the message
 *
188 189 190
 * @param onboard_control_sensors_present Bitmask showing which onboard controllers and sensors are present. Value of 0: not present. Value of 1: present. Indices: 0: 3D gyro, 1: 3D acc, 2: 3D mag, 3: absolute pressure, 4: differential pressure, 5: GPS, 6: optical flow, 7: computer vision position, 8: laser based position, 9: external ground-truth (Vicon or Leica). Controllers: 10: 3D angular rate control 11: attitude stabilization, 12: yaw position, 13: z/altitude control, 14: x/y position control, 15: motor outputs / control
 * @param onboard_control_sensors_enabled Bitmask showing which onboard controllers and sensors are enabled:  Value of 0: not enabled. Value of 1: enabled. Indices: 0: 3D gyro, 1: 3D acc, 2: 3D mag, 3: absolute pressure, 4: differential pressure, 5: GPS, 6: optical flow, 7: computer vision position, 8: laser based position, 9: external ground-truth (Vicon or Leica). Controllers: 10: 3D angular rate control 11: attitude stabilization, 12: yaw position, 13: z/altitude control, 14: x/y position control, 15: motor outputs / control
 * @param onboard_control_sensors_health Bitmask showing which onboard controllers and sensors are operational or have an error:  Value of 0: not enabled. Value of 1: enabled. Indices: 0: 3D gyro, 1: 3D acc, 2: 3D mag, 3: absolute pressure, 4: differential pressure, 5: GPS, 6: optical flow, 7: computer vision position, 8: laser based position, 9: external ground-truth (Vicon or Leica). Controllers: 10: 3D angular rate control 11: attitude stabilization, 12: yaw position, 13: z/altitude control, 14: x/y position control, 15: motor outputs / control
James Goppert's avatar
James Goppert committed
191
 * @param load Maximum usage in percent of the mainloop time, (0%: 0, 100%: 1000) should be always below 1000
192 193 194 195 196 197 198 199
 * @param voltage_battery Battery voltage, in millivolts (1 = 1 millivolt)
 * @param current_battery Battery current, in milliamperes (1 = 1 milliampere)
 * @param watt Watts consumed from this battery since startup
 * @param battery_percent Remaining battery energy: (0%: 0, 100%: 255)
 * @param errors_uart Dropped packets on all links (packets that were corrupted on reception on the MAV)
 * @param errors_i2c Dropped packets on all links (packets that were corrupted on reception)
 * @param errors_spi Dropped packets on all links (packets that were corrupted on reception)
 * @param errors_can Dropped packets on all links (packets that were corrupted on reception)
James Goppert's avatar
James Goppert committed
200
 */
lm's avatar
lm committed
201 202
#ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS

203
static inline void mavlink_msg_sys_status_send(mavlink_channel_t chan, uint16_t onboard_control_sensors_present, uint16_t onboard_control_sensors_enabled, uint16_t onboard_control_sensors_health, uint16_t load, uint16_t voltage_battery, uint16_t current_battery, uint16_t watt, uint8_t battery_percent, uint16_t errors_uart, uint16_t errors_i2c, uint16_t errors_spi, uint16_t errors_can)
lm's avatar
lm committed
204
{
lm's avatar
lm committed
205 206
	MAVLINK_ALIGNED_MESSAGE(msg, 23);
	mavlink_msg_sys_status_pack_chan_send(chan, msg, onboard_control_sensors_present, onboard_control_sensors_enabled, onboard_control_sensors_health, load, voltage_battery, current_battery, watt, battery_percent, errors_uart, errors_i2c, errors_spi, errors_can);
James Goppert's avatar
James Goppert committed
207 208 209
}

#endif
lm's avatar
lm committed
210

James Goppert's avatar
James Goppert committed
211 212
// MESSAGE SYS_STATUS UNPACKING

lm's avatar
lm committed
213

James Goppert's avatar
James Goppert committed
214
/**
215
 * @brief Get field onboard_control_sensors_present from sys_status message
James Goppert's avatar
James Goppert committed
216
 *
217
 * @return Bitmask showing which onboard controllers and sensors are present. Value of 0: not present. Value of 1: present. Indices: 0: 3D gyro, 1: 3D acc, 2: 3D mag, 3: absolute pressure, 4: differential pressure, 5: GPS, 6: optical flow, 7: computer vision position, 8: laser based position, 9: external ground-truth (Vicon or Leica). Controllers: 10: 3D angular rate control 11: attitude stabilization, 12: yaw position, 13: z/altitude control, 14: x/y position control, 15: motor outputs / control
James Goppert's avatar
James Goppert committed
218
 */
219
static inline uint16_t mavlink_msg_sys_status_get_onboard_control_sensors_present(const mavlink_message_t* msg)
James Goppert's avatar
James Goppert committed
220
{
lm's avatar
lm committed
221
	return MAVLINK_MSG_RETURN_uint16_t(msg,  0);
James Goppert's avatar
James Goppert committed
222 223 224
}

/**
225
 * @brief Get field onboard_control_sensors_enabled from sys_status message
James Goppert's avatar
James Goppert committed
226
 *
227
 * @return Bitmask showing which onboard controllers and sensors are enabled:  Value of 0: not enabled. Value of 1: enabled. Indices: 0: 3D gyro, 1: 3D acc, 2: 3D mag, 3: absolute pressure, 4: differential pressure, 5: GPS, 6: optical flow, 7: computer vision position, 8: laser based position, 9: external ground-truth (Vicon or Leica). Controllers: 10: 3D angular rate control 11: attitude stabilization, 12: yaw position, 13: z/altitude control, 14: x/y position control, 15: motor outputs / control
James Goppert's avatar
James Goppert committed
228
 */
229
static inline uint16_t mavlink_msg_sys_status_get_onboard_control_sensors_enabled(const mavlink_message_t* msg)
James Goppert's avatar
James Goppert committed
230
{
lm's avatar
lm committed
231
	return MAVLINK_MSG_RETURN_uint16_t(msg,  2);
James Goppert's avatar
James Goppert committed
232 233 234
}

/**
235
 * @brief Get field onboard_control_sensors_health from sys_status message
James Goppert's avatar
James Goppert committed
236
 *
237
 * @return Bitmask showing which onboard controllers and sensors are operational or have an error:  Value of 0: not enabled. Value of 1: enabled. Indices: 0: 3D gyro, 1: 3D acc, 2: 3D mag, 3: absolute pressure, 4: differential pressure, 5: GPS, 6: optical flow, 7: computer vision position, 8: laser based position, 9: external ground-truth (Vicon or Leica). Controllers: 10: 3D angular rate control 11: attitude stabilization, 12: yaw position, 13: z/altitude control, 14: x/y position control, 15: motor outputs / control
James Goppert's avatar
James Goppert committed
238
 */
239
static inline uint16_t mavlink_msg_sys_status_get_onboard_control_sensors_health(const mavlink_message_t* msg)
James Goppert's avatar
James Goppert committed
240
{
lm's avatar
lm committed
241
	return MAVLINK_MSG_RETURN_uint16_t(msg,  4);
James Goppert's avatar
James Goppert committed
242 243 244 245 246 247 248 249 250
}

/**
 * @brief Get field load from sys_status message
 *
 * @return Maximum usage in percent of the mainloop time, (0%: 0, 100%: 1000) should be always below 1000
 */
static inline uint16_t mavlink_msg_sys_status_get_load(const mavlink_message_t* msg)
{
lm's avatar
lm committed
251
	return MAVLINK_MSG_RETURN_uint16_t(msg,  6);
James Goppert's avatar
James Goppert committed
252 253 254
}

/**
255
 * @brief Get field voltage_battery from sys_status message
James Goppert's avatar
James Goppert committed
256 257 258
 *
 * @return Battery voltage, in millivolts (1 = 1 millivolt)
 */
259
static inline uint16_t mavlink_msg_sys_status_get_voltage_battery(const mavlink_message_t* msg)
James Goppert's avatar
James Goppert committed
260
{
lm's avatar
lm committed
261
	return MAVLINK_MSG_RETURN_uint16_t(msg,  8);
James Goppert's avatar
James Goppert committed
262 263 264
}

/**
265
 * @brief Get field current_battery from sys_status message
James Goppert's avatar
James Goppert committed
266
 *
267
 * @return Battery current, in milliamperes (1 = 1 milliampere)
James Goppert's avatar
James Goppert committed
268
 */
269
static inline uint16_t mavlink_msg_sys_status_get_current_battery(const mavlink_message_t* msg)
James Goppert's avatar
James Goppert committed
270
{
lm's avatar
lm committed
271
	return MAVLINK_MSG_RETURN_uint16_t(msg,  10);
James Goppert's avatar
James Goppert committed
272 273 274
}

/**
275
 * @brief Get field watt from sys_status message
James Goppert's avatar
James Goppert committed
276
 *
277
 * @return Watts consumed from this battery since startup
James Goppert's avatar
James Goppert committed
278
 */
279
static inline uint16_t mavlink_msg_sys_status_get_watt(const mavlink_message_t* msg)
James Goppert's avatar
James Goppert committed
280
{
lm's avatar
lm committed
281
	return MAVLINK_MSG_RETURN_uint16_t(msg,  12);
282 283 284 285 286 287 288 289 290
}

/**
 * @brief Get field battery_percent from sys_status message
 *
 * @return Remaining battery energy: (0%: 0, 100%: 255)
 */
static inline uint8_t mavlink_msg_sys_status_get_battery_percent(const mavlink_message_t* msg)
{
lm's avatar
lm committed
291
	return MAVLINK_MSG_RETURN_uint8_t(msg,  22);
292 293 294 295 296 297 298 299 300
}

/**
 * @brief Get field errors_uart from sys_status message
 *
 * @return Dropped packets on all links (packets that were corrupted on reception on the MAV)
 */
static inline uint16_t mavlink_msg_sys_status_get_errors_uart(const mavlink_message_t* msg)
{
lm's avatar
lm committed
301
	return MAVLINK_MSG_RETURN_uint16_t(msg,  14);
302 303 304 305 306 307 308 309 310
}

/**
 * @brief Get field errors_i2c from sys_status message
 *
 * @return Dropped packets on all links (packets that were corrupted on reception)
 */
static inline uint16_t mavlink_msg_sys_status_get_errors_i2c(const mavlink_message_t* msg)
{
lm's avatar
lm committed
311
	return MAVLINK_MSG_RETURN_uint16_t(msg,  16);
312 313 314 315 316 317 318 319 320
}

/**
 * @brief Get field errors_spi from sys_status message
 *
 * @return Dropped packets on all links (packets that were corrupted on reception)
 */
static inline uint16_t mavlink_msg_sys_status_get_errors_spi(const mavlink_message_t* msg)
{
lm's avatar
lm committed
321
	return MAVLINK_MSG_RETURN_uint16_t(msg,  18);
322 323 324 325 326 327 328 329 330
}

/**
 * @brief Get field errors_can from sys_status message
 *
 * @return Dropped packets on all links (packets that were corrupted on reception)
 */
static inline uint16_t mavlink_msg_sys_status_get_errors_can(const mavlink_message_t* msg)
{
lm's avatar
lm committed
331
	return MAVLINK_MSG_RETURN_uint16_t(msg,  20);
James Goppert's avatar
James Goppert committed
332 333 334 335 336 337 338 339 340 341
}

/**
 * @brief Decode a sys_status message into a struct
 *
 * @param msg The message to decode
 * @param sys_status C-struct to decode the message contents into
 */
static inline void mavlink_msg_sys_status_decode(const mavlink_message_t* msg, mavlink_sys_status_t* sys_status)
{
lm's avatar
lm committed
342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357
#if MAVLINK_NEED_BYTE_SWAP
	sys_status->onboard_control_sensors_present = mavlink_msg_sys_status_get_onboard_control_sensors_present(msg);
	sys_status->onboard_control_sensors_enabled = mavlink_msg_sys_status_get_onboard_control_sensors_enabled(msg);
	sys_status->onboard_control_sensors_health = mavlink_msg_sys_status_get_onboard_control_sensors_health(msg);
	sys_status->load = mavlink_msg_sys_status_get_load(msg);
	sys_status->voltage_battery = mavlink_msg_sys_status_get_voltage_battery(msg);
	sys_status->current_battery = mavlink_msg_sys_status_get_current_battery(msg);
	sys_status->watt = mavlink_msg_sys_status_get_watt(msg);
	sys_status->errors_uart = mavlink_msg_sys_status_get_errors_uart(msg);
	sys_status->errors_i2c = mavlink_msg_sys_status_get_errors_i2c(msg);
	sys_status->errors_spi = mavlink_msg_sys_status_get_errors_spi(msg);
	sys_status->errors_can = mavlink_msg_sys_status_get_errors_can(msg);
	sys_status->battery_percent = mavlink_msg_sys_status_get_battery_percent(msg);
#else
	memcpy(sys_status, MAVLINK_PAYLOAD(msg), 23);
#endif
James Goppert's avatar
James Goppert committed
358
}