#![doc = "This file was automatically generated, do not edit"]
use crate::MavlinkVersion;
use crate::{bytes::Bytes, bytes_mut::BytesMut, error::*, Message, MessageData};
#[allow(unused_imports)]
use bitflags::bitflags;
#[allow(unused_imports)]
use num_derive::FromPrimitive;
#[allow(unused_imports)]
use num_derive::ToPrimitive;
#[allow(unused_imports)]
use num_traits::FromPrimitive;
#[allow(unused_imports)]
use num_traits::ToPrimitive;
#[cfg(feature = "serde")]
use serde::{Deserialize, Serialize};
#[derive(Debug, Copy, Clone, PartialEq, FromPrimitive, ToPrimitive)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "serde", serde(tag = "type"))]
pub enum IcarousFmsState {
ICAROUS_FMS_STATE_IDLE = 0,
ICAROUS_FMS_STATE_TAKEOFF = 1,
ICAROUS_FMS_STATE_CLIMB = 2,
ICAROUS_FMS_STATE_CRUISE = 3,
ICAROUS_FMS_STATE_APPROACH = 4,
ICAROUS_FMS_STATE_LAND = 5,
}
impl IcarousFmsState {
pub const DEFAULT: Self = Self::ICAROUS_FMS_STATE_IDLE;
}
impl Default for IcarousFmsState {
fn default() -> Self {
Self::DEFAULT
}
}
#[derive(Debug, Copy, Clone, PartialEq, FromPrimitive, ToPrimitive)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "serde", serde(tag = "type"))]
pub enum IcarousTrackBandTypes {
ICAROUS_TRACK_BAND_TYPE_NONE = 0,
ICAROUS_TRACK_BAND_TYPE_NEAR = 1,
ICAROUS_TRACK_BAND_TYPE_RECOVERY = 2,
}
impl IcarousTrackBandTypes {
pub const DEFAULT: Self = Self::ICAROUS_TRACK_BAND_TYPE_NONE;
}
impl Default for IcarousTrackBandTypes {
fn default() -> Self {
Self::DEFAULT
}
}
#[doc = "id: 42000"]
#[doc = "ICAROUS heartbeat."]
#[derive(Debug, Clone, PartialEq)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct ICAROUS_HEARTBEAT_DATA {
#[doc = "See the FMS_STATE enum.."]
pub status: IcarousFmsState,
}
impl ICAROUS_HEARTBEAT_DATA {
pub const ENCODED_LEN: usize = 1usize;
pub const DEFAULT: Self = Self {
status: IcarousFmsState::DEFAULT,
};
}
impl Default for ICAROUS_HEARTBEAT_DATA {
fn default() -> Self {
Self::DEFAULT.clone()
}
}
impl MessageData for ICAROUS_HEARTBEAT_DATA {
type Message = MavMessage;
const ID: u32 = 42000u32;
const NAME: &'static str = "ICAROUS_HEARTBEAT";
const EXTRA_CRC: u8 = 227u8;
const ENCODED_LEN: usize = 1usize;
fn deser(_version: MavlinkVersion, __input: &[u8]) -> Result<Self, ParserError> {
let avail_len = __input.len();
let mut payload_buf = [0; Self::ENCODED_LEN];
let mut buf = if avail_len < Self::ENCODED_LEN {
payload_buf[0..avail_len].copy_from_slice(__input);
Bytes::new(&payload_buf)
} else {
Bytes::new(__input)
};
let mut __struct = Self::default();
let tmp = buf.get_u8();
__struct.status = FromPrimitive::from_u8(tmp).ok_or(ParserError::InvalidEnum {
enum_type: "IcarousFmsState",
value: tmp as u32,
})?;
Ok(__struct)
}
fn ser(&self, version: MavlinkVersion, bytes: &mut [u8]) -> usize {
let mut __tmp = BytesMut::new(bytes);
__tmp.put_u8(self.status as u8);
if matches!(version, MavlinkVersion::V2) {
let len = __tmp.len();
crate::remove_trailing_zeroes(&bytes[..len])
} else {
__tmp.len()
}
}
}
#[doc = "id: 42001"]
#[doc = "Kinematic multi bands (track) output from Daidalus."]
#[derive(Debug, Clone, PartialEq)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct ICAROUS_KINEMATIC_BANDS_DATA {
#[doc = "min angle (degrees)."]
pub min1: f32,
#[doc = "max angle (degrees)."]
pub max1: f32,
#[doc = "min angle (degrees)."]
pub min2: f32,
#[doc = "max angle (degrees)."]
pub max2: f32,
#[doc = "min angle (degrees)."]
pub min3: f32,
#[doc = "max angle (degrees)."]
pub max3: f32,
#[doc = "min angle (degrees)."]
pub min4: f32,
#[doc = "max angle (degrees)."]
pub max4: f32,
#[doc = "min angle (degrees)."]
pub min5: f32,
#[doc = "max angle (degrees)."]
pub max5: f32,
#[doc = "Number of track bands."]
pub numBands: i8,
#[doc = "See the TRACK_BAND_TYPES enum.."]
pub type1: IcarousTrackBandTypes,
#[doc = "See the TRACK_BAND_TYPES enum.."]
pub type2: IcarousTrackBandTypes,
#[doc = "See the TRACK_BAND_TYPES enum.."]
pub type3: IcarousTrackBandTypes,
#[doc = "See the TRACK_BAND_TYPES enum.."]
pub type4: IcarousTrackBandTypes,
#[doc = "See the TRACK_BAND_TYPES enum.."]
pub type5: IcarousTrackBandTypes,
}
impl ICAROUS_KINEMATIC_BANDS_DATA {
pub const ENCODED_LEN: usize = 46usize;
pub const DEFAULT: Self = Self {
min1: 0.0_f32,
max1: 0.0_f32,
min2: 0.0_f32,
max2: 0.0_f32,
min3: 0.0_f32,
max3: 0.0_f32,
min4: 0.0_f32,
max4: 0.0_f32,
min5: 0.0_f32,
max5: 0.0_f32,
numBands: 0_i8,
type1: IcarousTrackBandTypes::DEFAULT,
type2: IcarousTrackBandTypes::DEFAULT,
type3: IcarousTrackBandTypes::DEFAULT,
type4: IcarousTrackBandTypes::DEFAULT,
type5: IcarousTrackBandTypes::DEFAULT,
};
}
impl Default for ICAROUS_KINEMATIC_BANDS_DATA {
fn default() -> Self {
Self::DEFAULT.clone()
}
}
impl MessageData for ICAROUS_KINEMATIC_BANDS_DATA {
type Message = MavMessage;
const ID: u32 = 42001u32;
const NAME: &'static str = "ICAROUS_KINEMATIC_BANDS";
const EXTRA_CRC: u8 = 239u8;
const ENCODED_LEN: usize = 46usize;
fn deser(_version: MavlinkVersion, __input: &[u8]) -> Result<Self, ParserError> {
let avail_len = __input.len();
let mut payload_buf = [0; Self::ENCODED_LEN];
let mut buf = if avail_len < Self::ENCODED_LEN {
payload_buf[0..avail_len].copy_from_slice(__input);
Bytes::new(&payload_buf)
} else {
Bytes::new(__input)
};
let mut __struct = Self::default();
__struct.min1 = buf.get_f32_le();
__struct.max1 = buf.get_f32_le();
__struct.min2 = buf.get_f32_le();
__struct.max2 = buf.get_f32_le();
__struct.min3 = buf.get_f32_le();
__struct.max3 = buf.get_f32_le();
__struct.min4 = buf.get_f32_le();
__struct.max4 = buf.get_f32_le();
__struct.min5 = buf.get_f32_le();
__struct.max5 = buf.get_f32_le();
__struct.numBands = buf.get_i8();
let tmp = buf.get_u8();
__struct.type1 = FromPrimitive::from_u8(tmp).ok_or(ParserError::InvalidEnum {
enum_type: "IcarousTrackBandTypes",
value: tmp as u32,
})?;
let tmp = buf.get_u8();
__struct.type2 = FromPrimitive::from_u8(tmp).ok_or(ParserError::InvalidEnum {
enum_type: "IcarousTrackBandTypes",
value: tmp as u32,
})?;
let tmp = buf.get_u8();
__struct.type3 = FromPrimitive::from_u8(tmp).ok_or(ParserError::InvalidEnum {
enum_type: "IcarousTrackBandTypes",
value: tmp as u32,
})?;
let tmp = buf.get_u8();
__struct.type4 = FromPrimitive::from_u8(tmp).ok_or(ParserError::InvalidEnum {
enum_type: "IcarousTrackBandTypes",
value: tmp as u32,
})?;
let tmp = buf.get_u8();
__struct.type5 = FromPrimitive::from_u8(tmp).ok_or(ParserError::InvalidEnum {
enum_type: "IcarousTrackBandTypes",
value: tmp as u32,
})?;
Ok(__struct)
}
fn ser(&self, version: MavlinkVersion, bytes: &mut [u8]) -> usize {
let mut __tmp = BytesMut::new(bytes);
__tmp.put_f32_le(self.min1);
__tmp.put_f32_le(self.max1);
__tmp.put_f32_le(self.min2);
__tmp.put_f32_le(self.max2);
__tmp.put_f32_le(self.min3);
__tmp.put_f32_le(self.max3);
__tmp.put_f32_le(self.min4);
__tmp.put_f32_le(self.max4);
__tmp.put_f32_le(self.min5);
__tmp.put_f32_le(self.max5);
__tmp.put_i8(self.numBands);
__tmp.put_u8(self.type1 as u8);
__tmp.put_u8(self.type2 as u8);
__tmp.put_u8(self.type3 as u8);
__tmp.put_u8(self.type4 as u8);
__tmp.put_u8(self.type5 as u8);
if matches!(version, MavlinkVersion::V2) {
let len = __tmp.len();
crate::remove_trailing_zeroes(&bytes[..len])
} else {
__tmp.len()
}
}
}
#[derive(Clone, PartialEq, Debug)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "serde", serde(tag = "type"))]
pub enum MavMessage {
ICAROUS_HEARTBEAT(ICAROUS_HEARTBEAT_DATA),
ICAROUS_KINEMATIC_BANDS(ICAROUS_KINEMATIC_BANDS_DATA),
}
impl Message for MavMessage {
fn parse(version: MavlinkVersion, id: u32, payload: &[u8]) -> Result<Self, ParserError> {
match id {
ICAROUS_HEARTBEAT_DATA::ID => {
ICAROUS_HEARTBEAT_DATA::deser(version, payload).map(Self::ICAROUS_HEARTBEAT)
}
ICAROUS_KINEMATIC_BANDS_DATA::ID => {
ICAROUS_KINEMATIC_BANDS_DATA::deser(version, payload)
.map(Self::ICAROUS_KINEMATIC_BANDS)
}
_ => Err(ParserError::UnknownMessage { id }),
}
}
fn message_name(&self) -> &'static str {
match self {
Self::ICAROUS_HEARTBEAT(..) => ICAROUS_HEARTBEAT_DATA::NAME,
Self::ICAROUS_KINEMATIC_BANDS(..) => ICAROUS_KINEMATIC_BANDS_DATA::NAME,
}
}
fn message_id(&self) -> u32 {
match self {
Self::ICAROUS_HEARTBEAT(..) => ICAROUS_HEARTBEAT_DATA::ID,
Self::ICAROUS_KINEMATIC_BANDS(..) => ICAROUS_KINEMATIC_BANDS_DATA::ID,
}
}
fn message_id_from_name(name: &str) -> Result<u32, &'static str> {
match name {
ICAROUS_HEARTBEAT_DATA::NAME => Ok(ICAROUS_HEARTBEAT_DATA::ID),
ICAROUS_KINEMATIC_BANDS_DATA::NAME => Ok(ICAROUS_KINEMATIC_BANDS_DATA::ID),
_ => Err("Invalid message name."),
}
}
fn default_message_from_id(id: u32) -> Result<Self, &'static str> {
match id {
ICAROUS_HEARTBEAT_DATA::ID => {
Ok(Self::ICAROUS_HEARTBEAT(ICAROUS_HEARTBEAT_DATA::default()))
}
ICAROUS_KINEMATIC_BANDS_DATA::ID => Ok(Self::ICAROUS_KINEMATIC_BANDS(
ICAROUS_KINEMATIC_BANDS_DATA::default(),
)),
_ => Err("Invalid message id."),
}
}
fn ser(&self, version: MavlinkVersion, bytes: &mut [u8]) -> usize {
match self {
Self::ICAROUS_HEARTBEAT(body) => body.ser(version, bytes),
Self::ICAROUS_KINEMATIC_BANDS(body) => body.ser(version, bytes),
}
}
fn extra_crc(id: u32) -> u8 {
match id {
ICAROUS_HEARTBEAT_DATA::ID => ICAROUS_HEARTBEAT_DATA::EXTRA_CRC,
ICAROUS_KINEMATIC_BANDS_DATA::ID => ICAROUS_KINEMATIC_BANDS_DATA::EXTRA_CRC,
_ => 0,
}
}
}