1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
// This file was automatically generated, do not edit
use crate::MavlinkVersion;
#[allow(unused_imports)]
use crate::{};
use crate::{error::*, Message};
#[cfg(not(feature = "std"))]
use alloc::string::ToString;
#[cfg(not(feature = "std"))]
use alloc::vec::Vec;
#[allow(unused_imports)]
use bitflags::bitflags;
#[allow(unused_imports)]
use bytes::{Buf, BufMut, Bytes, BytesMut};
#[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 IcarousTrackBandTypes {
    ICAROUS_TRACK_BAND_TYPE_NONE = 0,
    ICAROUS_TRACK_BAND_TYPE_NEAR = 1,
    ICAROUS_TRACK_BAND_TYPE_RECOVERY = 2,
}
impl Default for IcarousTrackBandTypes {
    fn default() -> Self {
        IcarousTrackBandTypes::ICAROUS_TRACK_BAND_TYPE_NONE
    }
}
#[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 Default for IcarousFmsState {
    fn default() -> Self {
        IcarousFmsState::ICAROUS_FMS_STATE_IDLE
    }
}
#[derive(Debug, Clone, PartialEq, Default)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct ICAROUS_HEARTBEAT_DATA {
    pub status: IcarousFmsState,
}
impl ICAROUS_HEARTBEAT_DATA {
    pub const ENCODED_LEN: usize = 1usize;
    pub fn deser(version: MavlinkVersion, _input: &[u8]) -> Result<Self, ParserError> {
        let avail_len = _input.len();
        let mut buf = BytesMut::from(_input);
        if avail_len < ICAROUS_HEARTBEAT_DATA::ENCODED_LEN {
            let mut payload_buf = [0; ICAROUS_HEARTBEAT_DATA::ENCODED_LEN];
            payload_buf[0..avail_len].copy_from_slice(_input);
            buf = BytesMut::from(&payload_buf[..]);
        }
        let mut _struct = Self::default();
        let tmp = buf.get_u8();
        _struct.status = FromPrimitive::from_u8(tmp).ok_or(ParserError::InvalidEnum {
            enum_type: "IcarousFmsState".to_string(),
            value: tmp as u32,
        })?;
        Ok(_struct)
    }
    pub fn ser(&self) -> Vec<u8> {
        let mut _tmp = Vec::new();
        _tmp.put_u8(self.status as u8);
        _tmp
    }
}
#[derive(Debug, Clone, PartialEq, Default)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct ICAROUS_KINEMATIC_BANDS_DATA {
    pub min1: f32,
    pub max1: f32,
    pub min2: f32,
    pub max2: f32,
    pub min3: f32,
    pub max3: f32,
    pub min4: f32,
    pub max4: f32,
    pub min5: f32,
    pub max5: f32,
    pub numBands: i8,
    pub type1: IcarousTrackBandTypes,
    pub type2: IcarousTrackBandTypes,
    pub type3: IcarousTrackBandTypes,
    pub type4: IcarousTrackBandTypes,
    pub type5: IcarousTrackBandTypes,
}
impl ICAROUS_KINEMATIC_BANDS_DATA {
    pub const ENCODED_LEN: usize = 46usize;
    pub fn deser(version: MavlinkVersion, _input: &[u8]) -> Result<Self, ParserError> {
        let avail_len = _input.len();
        let mut buf = BytesMut::from(_input);
        if avail_len < ICAROUS_KINEMATIC_BANDS_DATA::ENCODED_LEN {
            let mut payload_buf = [0; ICAROUS_KINEMATIC_BANDS_DATA::ENCODED_LEN];
            payload_buf[0..avail_len].copy_from_slice(_input);
            buf = BytesMut::from(&payload_buf[..]);
        }
        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".to_string(),
            value: tmp as u32,
        })?;
        let tmp = buf.get_u8();
        _struct.type2 = FromPrimitive::from_u8(tmp).ok_or(ParserError::InvalidEnum {
            enum_type: "IcarousTrackBandTypes".to_string(),
            value: tmp as u32,
        })?;
        let tmp = buf.get_u8();
        _struct.type3 = FromPrimitive::from_u8(tmp).ok_or(ParserError::InvalidEnum {
            enum_type: "IcarousTrackBandTypes".to_string(),
            value: tmp as u32,
        })?;
        let tmp = buf.get_u8();
        _struct.type4 = FromPrimitive::from_u8(tmp).ok_or(ParserError::InvalidEnum {
            enum_type: "IcarousTrackBandTypes".to_string(),
            value: tmp as u32,
        })?;
        let tmp = buf.get_u8();
        _struct.type5 = FromPrimitive::from_u8(tmp).ok_or(ParserError::InvalidEnum {
            enum_type: "IcarousTrackBandTypes".to_string(),
            value: tmp as u32,
        })?;
        Ok(_struct)
    }
    pub fn ser(&self) -> Vec<u8> {
        let mut _tmp = Vec::new();
        _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);
        _tmp
    }
}
#[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<MavMessage, ParserError> {
        match id {
            42000 => ICAROUS_HEARTBEAT_DATA::deser(version, payload)
                .map(|s| MavMessage::ICAROUS_HEARTBEAT(s)),
            42001 => ICAROUS_KINEMATIC_BANDS_DATA::deser(version, payload)
                .map(|s| MavMessage::ICAROUS_KINEMATIC_BANDS(s)),
            _ => Err(ParserError::UnknownMessage { id }),
        }
    }
    fn message_name(&self) -> &'static str {
        match self {
            MavMessage::ICAROUS_HEARTBEAT(..) => "ICAROUS_HEARTBEAT",
            MavMessage::ICAROUS_KINEMATIC_BANDS(..) => "ICAROUS_KINEMATIC_BANDS",
        }
    }
    fn message_id(&self) -> u32 {
        match self {
            MavMessage::ICAROUS_HEARTBEAT(..) => 42000,
            MavMessage::ICAROUS_KINEMATIC_BANDS(..) => 42001,
        }
    }
    fn message_id_from_name(name: &str) -> Result<u32, &'static str> {
        match name {
            "ICAROUS_HEARTBEAT" => Ok(42000),
            "ICAROUS_KINEMATIC_BANDS" => Ok(42001),
            _ => Err("Invalid message name."),
        }
    }
    fn default_message_from_id(id: u32) -> Result<MavMessage, &'static str> {
        match id {
            42000 => Ok(MavMessage::ICAROUS_HEARTBEAT(
                ICAROUS_HEARTBEAT_DATA::default(),
            )),
            42001 => Ok(MavMessage::ICAROUS_KINEMATIC_BANDS(
                ICAROUS_KINEMATIC_BANDS_DATA::default(),
            )),
            _ => {
                return Err("Invalid message id.");
            }
        }
    }
    fn ser(&self) -> Vec<u8> {
        match self {
            &MavMessage::ICAROUS_HEARTBEAT(ref body) => body.ser(),
            &MavMessage::ICAROUS_KINEMATIC_BANDS(ref body) => body.ser(),
        }
    }
    fn extra_crc(id: u32) -> u8 {
        match id {
            42000 => 227,
            42001 => 239,
            _ => 0,
        }
    }
}