use super::lib::*;
#[cfg_attr(feature = "serde", derive(serde::Serialize))]
#[derive(Debug, Clone)]
pub struct GnssInputType {
#[cfg_attr(feature = "serde", serde(rename(serialize = "flags")))]
pub flags: u8,
}
impl WireFormat for GnssInputType {
const MIN_LEN: usize = <u8 as WireFormat>::MIN_LEN;
fn len(&self) -> usize {
WireFormat::len(&self.flags)
}
fn write<B: BufMut>(&self, buf: &mut B) {
WireFormat::write(&self.flags, buf);
}
fn parse_unchecked<B: Buf>(buf: &mut B) -> Self {
GnssInputType {
flags: WireFormat::parse_unchecked(buf),
}
}
}
#[cfg_attr(feature = "serde", derive(serde::Serialize))]
#[derive(Debug, Clone)]
pub struct ImuInputType {
#[cfg_attr(feature = "serde", serde(rename(serialize = "flags")))]
pub flags: u8,
}
impl WireFormat for ImuInputType {
const MIN_LEN: usize = <u8 as WireFormat>::MIN_LEN;
fn len(&self) -> usize {
WireFormat::len(&self.flags)
}
fn write<B: BufMut>(&self, buf: &mut B) {
WireFormat::write(&self.flags, buf);
}
fn parse_unchecked<B: Buf>(buf: &mut B) -> Self {
ImuInputType {
flags: WireFormat::parse_unchecked(buf),
}
}
}
#[cfg_attr(feature = "serde", derive(serde::Serialize))]
#[derive(Debug, Clone)]
pub struct MsgSolnMeta {
#[cfg_attr(feature = "serde", serde(skip_serializing))]
pub sender_id: Option<u16>,
#[cfg_attr(feature = "serde", serde(rename(serialize = "tow")))]
pub tow: u32,
#[cfg_attr(feature = "serde", serde(rename(serialize = "pdop")))]
pub pdop: u16,
#[cfg_attr(feature = "serde", serde(rename(serialize = "hdop")))]
pub hdop: u16,
#[cfg_attr(feature = "serde", serde(rename(serialize = "vdop")))]
pub vdop: u16,
#[cfg_attr(feature = "serde", serde(rename(serialize = "age_corrections")))]
pub age_corrections: u16,
#[cfg_attr(feature = "serde", serde(rename(serialize = "age_gnss")))]
pub age_gnss: u32,
#[cfg_attr(feature = "serde", serde(rename(serialize = "sol_in")))]
pub sol_in: Vec<SolutionInputType>,
}
impl ConcreteMessage for MsgSolnMeta {
const MESSAGE_TYPE: u16 = 65294;
const MESSAGE_NAME: &'static str = "MSG_SOLN_META";
}
impl SbpMessage for MsgSolnMeta {
fn message_name(&self) -> &'static str {
<Self as ConcreteMessage>::MESSAGE_NAME
}
fn message_type(&self) -> u16 {
<Self as ConcreteMessage>::MESSAGE_TYPE
}
fn sender_id(&self) -> Option<u16> {
self.sender_id
}
fn set_sender_id(&mut self, new_id: u16) {
self.sender_id = Some(new_id);
}
fn encoded_len(&self) -> usize {
WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN
}
#[cfg(feature = "swiftnav")]
fn gps_time(&self) -> Option<std::result::Result<time::MessageTime, time::GpsTimeError>> {
let tow_s = (self.tow as f64) / 1000.0;
let gps_time = match time::GpsTime::new(0, tow_s) {
Ok(gps_time) => gps_time.tow(),
Err(e) => return Some(Err(e.into())),
};
Some(Ok(time::MessageTime::Rover(gps_time.into())))
}
}
impl TryFrom<Sbp> for MsgSolnMeta {
type Error = TryFromSbpError;
fn try_from(msg: Sbp) -> Result<Self, Self::Error> {
match msg {
Sbp::MsgSolnMeta(m) => Ok(m),
_ => Err(TryFromSbpError),
}
}
}
impl WireFormat for MsgSolnMeta {
const MIN_LEN: usize = <u32 as WireFormat>::MIN_LEN
+ <u16 as WireFormat>::MIN_LEN
+ <u16 as WireFormat>::MIN_LEN
+ <u16 as WireFormat>::MIN_LEN
+ <u16 as WireFormat>::MIN_LEN
+ <u32 as WireFormat>::MIN_LEN
+ <Vec<SolutionInputType> as WireFormat>::MIN_LEN;
fn len(&self) -> usize {
WireFormat::len(&self.tow)
+ WireFormat::len(&self.pdop)
+ WireFormat::len(&self.hdop)
+ WireFormat::len(&self.vdop)
+ WireFormat::len(&self.age_corrections)
+ WireFormat::len(&self.age_gnss)
+ WireFormat::len(&self.sol_in)
}
fn write<B: BufMut>(&self, buf: &mut B) {
WireFormat::write(&self.tow, buf);
WireFormat::write(&self.pdop, buf);
WireFormat::write(&self.hdop, buf);
WireFormat::write(&self.vdop, buf);
WireFormat::write(&self.age_corrections, buf);
WireFormat::write(&self.age_gnss, buf);
WireFormat::write(&self.sol_in, buf);
}
fn parse_unchecked<B: Buf>(buf: &mut B) -> Self {
MsgSolnMeta {
sender_id: None,
tow: WireFormat::parse_unchecked(buf),
pdop: WireFormat::parse_unchecked(buf),
hdop: WireFormat::parse_unchecked(buf),
vdop: WireFormat::parse_unchecked(buf),
age_corrections: WireFormat::parse_unchecked(buf),
age_gnss: WireFormat::parse_unchecked(buf),
sol_in: WireFormat::parse_unchecked(buf),
}
}
}
#[cfg_attr(feature = "serde", derive(serde::Serialize))]
#[derive(Debug, Clone)]
pub struct MsgSolnMetaDepA {
#[cfg_attr(feature = "serde", serde(skip_serializing))]
pub sender_id: Option<u16>,
#[cfg_attr(feature = "serde", serde(rename(serialize = "pdop")))]
pub pdop: u16,
#[cfg_attr(feature = "serde", serde(rename(serialize = "hdop")))]
pub hdop: u16,
#[cfg_attr(feature = "serde", serde(rename(serialize = "vdop")))]
pub vdop: u16,
#[cfg_attr(feature = "serde", serde(rename(serialize = "n_sats")))]
pub n_sats: u8,
#[cfg_attr(feature = "serde", serde(rename(serialize = "age_corrections")))]
pub age_corrections: u16,
#[cfg_attr(feature = "serde", serde(rename(serialize = "alignment_status")))]
pub alignment_status: u8,
#[cfg_attr(feature = "serde", serde(rename(serialize = "last_used_gnss_pos_tow")))]
pub last_used_gnss_pos_tow: u32,
#[cfg_attr(feature = "serde", serde(rename(serialize = "last_used_gnss_vel_tow")))]
pub last_used_gnss_vel_tow: u32,
#[cfg_attr(feature = "serde", serde(rename(serialize = "sol_in")))]
pub sol_in: Vec<SolutionInputType>,
}
impl ConcreteMessage for MsgSolnMetaDepA {
const MESSAGE_TYPE: u16 = 65295;
const MESSAGE_NAME: &'static str = "MSG_SOLN_META_DEP_A";
}
impl SbpMessage for MsgSolnMetaDepA {
fn message_name(&self) -> &'static str {
<Self as ConcreteMessage>::MESSAGE_NAME
}
fn message_type(&self) -> u16 {
<Self as ConcreteMessage>::MESSAGE_TYPE
}
fn sender_id(&self) -> Option<u16> {
self.sender_id
}
fn set_sender_id(&mut self, new_id: u16) {
self.sender_id = Some(new_id);
}
fn encoded_len(&self) -> usize {
WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN
}
}
impl TryFrom<Sbp> for MsgSolnMetaDepA {
type Error = TryFromSbpError;
fn try_from(msg: Sbp) -> Result<Self, Self::Error> {
match msg {
Sbp::MsgSolnMetaDepA(m) => Ok(m),
_ => Err(TryFromSbpError),
}
}
}
impl WireFormat for MsgSolnMetaDepA {
const MIN_LEN: usize = <u16 as WireFormat>::MIN_LEN
+ <u16 as WireFormat>::MIN_LEN
+ <u16 as WireFormat>::MIN_LEN
+ <u8 as WireFormat>::MIN_LEN
+ <u16 as WireFormat>::MIN_LEN
+ <u8 as WireFormat>::MIN_LEN
+ <u32 as WireFormat>::MIN_LEN
+ <u32 as WireFormat>::MIN_LEN
+ <Vec<SolutionInputType> as WireFormat>::MIN_LEN;
fn len(&self) -> usize {
WireFormat::len(&self.pdop)
+ WireFormat::len(&self.hdop)
+ WireFormat::len(&self.vdop)
+ WireFormat::len(&self.n_sats)
+ WireFormat::len(&self.age_corrections)
+ WireFormat::len(&self.alignment_status)
+ WireFormat::len(&self.last_used_gnss_pos_tow)
+ WireFormat::len(&self.last_used_gnss_vel_tow)
+ WireFormat::len(&self.sol_in)
}
fn write<B: BufMut>(&self, buf: &mut B) {
WireFormat::write(&self.pdop, buf);
WireFormat::write(&self.hdop, buf);
WireFormat::write(&self.vdop, buf);
WireFormat::write(&self.n_sats, buf);
WireFormat::write(&self.age_corrections, buf);
WireFormat::write(&self.alignment_status, buf);
WireFormat::write(&self.last_used_gnss_pos_tow, buf);
WireFormat::write(&self.last_used_gnss_vel_tow, buf);
WireFormat::write(&self.sol_in, buf);
}
fn parse_unchecked<B: Buf>(buf: &mut B) -> Self {
MsgSolnMetaDepA {
sender_id: None,
pdop: WireFormat::parse_unchecked(buf),
hdop: WireFormat::parse_unchecked(buf),
vdop: WireFormat::parse_unchecked(buf),
n_sats: WireFormat::parse_unchecked(buf),
age_corrections: WireFormat::parse_unchecked(buf),
alignment_status: WireFormat::parse_unchecked(buf),
last_used_gnss_pos_tow: WireFormat::parse_unchecked(buf),
last_used_gnss_vel_tow: WireFormat::parse_unchecked(buf),
sol_in: WireFormat::parse_unchecked(buf),
}
}
}
#[cfg_attr(feature = "serde", derive(serde::Serialize))]
#[derive(Debug, Clone)]
pub struct OdoInputType {
#[cfg_attr(feature = "serde", serde(rename(serialize = "flags")))]
pub flags: u8,
}
impl WireFormat for OdoInputType {
const MIN_LEN: usize = <u8 as WireFormat>::MIN_LEN;
fn len(&self) -> usize {
WireFormat::len(&self.flags)
}
fn write<B: BufMut>(&self, buf: &mut B) {
WireFormat::write(&self.flags, buf);
}
fn parse_unchecked<B: Buf>(buf: &mut B) -> Self {
OdoInputType {
flags: WireFormat::parse_unchecked(buf),
}
}
}
#[cfg_attr(feature = "serde", derive(serde::Serialize))]
#[derive(Debug, Clone)]
pub struct SolutionInputType {
#[cfg_attr(feature = "serde", serde(rename(serialize = "sensor_type")))]
pub sensor_type: u8,
#[cfg_attr(feature = "serde", serde(rename(serialize = "flags")))]
pub flags: u8,
}
impl WireFormat for SolutionInputType {
const MIN_LEN: usize = <u8 as WireFormat>::MIN_LEN + <u8 as WireFormat>::MIN_LEN;
fn len(&self) -> usize {
WireFormat::len(&self.sensor_type) + WireFormat::len(&self.flags)
}
fn write<B: BufMut>(&self, buf: &mut B) {
WireFormat::write(&self.sensor_type, buf);
WireFormat::write(&self.flags, buf);
}
fn parse_unchecked<B: Buf>(buf: &mut B) -> Self {
SolutionInputType {
sensor_type: WireFormat::parse_unchecked(buf),
flags: WireFormat::parse_unchecked(buf),
}
}
}