Mavlink Messages for Emaxx Nav Board

Dependents:   Madpulse_Speed_Control_temp Madpulse_Speed_Control_Students

Committer:
jdawkins
Date:
Fri Jan 20 13:20:58 2017 +0000
Revision:
0:bb2cacd02294
Initial Commit of Mavlink Messages for Emaxx Board custom messages for decawave ranging and bno055;

Who changed what in which revision?

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