use super::lib::*;
#[cfg_attr(feature = "serde", derive(serde::Serialize))]
#[derive(Debug, Clone)]
pub struct MsgCsacTelemetry {
#[cfg_attr(feature = "serde", serde(skip_serializing))]
pub sender_id: Option<u16>,
#[cfg_attr(feature = "serde", serde(rename(serialize = "id")))]
pub id: u8,
#[cfg_attr(feature = "serde", serde(rename(serialize = "telemetry")))]
pub telemetry: SbpString<Vec<u8>, Unterminated>,
}
impl ConcreteMessage for MsgCsacTelemetry {
const MESSAGE_TYPE: u16 = 65284;
const MESSAGE_NAME: &'static str = "MSG_CSAC_TELEMETRY";
}
impl SbpMessage for MsgCsacTelemetry {
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 MsgCsacTelemetry {
type Error = TryFromSbpError;
fn try_from(msg: Sbp) -> Result<Self, Self::Error> {
match msg {
Sbp::MsgCsacTelemetry(m) => Ok(m),
_ => Err(TryFromSbpError),
}
}
}
impl WireFormat for MsgCsacTelemetry {
const MIN_LEN: usize =
<u8 as WireFormat>::MIN_LEN + <SbpString<Vec<u8>, Unterminated> as WireFormat>::MIN_LEN;
fn len(&self) -> usize {
WireFormat::len(&self.id) + WireFormat::len(&self.telemetry)
}
fn write<B: BufMut>(&self, buf: &mut B) {
WireFormat::write(&self.id, buf);
WireFormat::write(&self.telemetry, buf);
}
fn parse_unchecked<B: Buf>(buf: &mut B) -> Self {
MsgCsacTelemetry {
sender_id: None,
id: WireFormat::parse_unchecked(buf),
telemetry: WireFormat::parse_unchecked(buf),
}
}
}
#[cfg_attr(feature = "serde", derive(serde::Serialize))]
#[derive(Debug, Clone)]
pub struct MsgCsacTelemetryLabels {
#[cfg_attr(feature = "serde", serde(skip_serializing))]
pub sender_id: Option<u16>,
#[cfg_attr(feature = "serde", serde(rename(serialize = "id")))]
pub id: u8,
#[cfg_attr(feature = "serde", serde(rename(serialize = "telemetry_labels")))]
pub telemetry_labels: SbpString<Vec<u8>, Unterminated>,
}
impl ConcreteMessage for MsgCsacTelemetryLabels {
const MESSAGE_TYPE: u16 = 65285;
const MESSAGE_NAME: &'static str = "MSG_CSAC_TELEMETRY_LABELS";
}
impl SbpMessage for MsgCsacTelemetryLabels {
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 MsgCsacTelemetryLabels {
type Error = TryFromSbpError;
fn try_from(msg: Sbp) -> Result<Self, Self::Error> {
match msg {
Sbp::MsgCsacTelemetryLabels(m) => Ok(m),
_ => Err(TryFromSbpError),
}
}
}
impl WireFormat for MsgCsacTelemetryLabels {
const MIN_LEN: usize =
<u8 as WireFormat>::MIN_LEN + <SbpString<Vec<u8>, Unterminated> as WireFormat>::MIN_LEN;
fn len(&self) -> usize {
WireFormat::len(&self.id) + WireFormat::len(&self.telemetry_labels)
}
fn write<B: BufMut>(&self, buf: &mut B) {
WireFormat::write(&self.id, buf);
WireFormat::write(&self.telemetry_labels, buf);
}
fn parse_unchecked<B: Buf>(buf: &mut B) -> Self {
MsgCsacTelemetryLabels {
sender_id: None,
id: WireFormat::parse_unchecked(buf),
telemetry_labels: WireFormat::parse_unchecked(buf),
}
}
}
#[cfg_attr(feature = "serde", derive(serde::Serialize))]
#[derive(Debug, Clone)]
pub struct MsgDgnssStatus {
#[cfg_attr(feature = "serde", serde(skip_serializing))]
pub sender_id: Option<u16>,
#[cfg_attr(feature = "serde", serde(rename(serialize = "flags")))]
pub flags: u8,
#[cfg_attr(feature = "serde", serde(rename(serialize = "latency")))]
pub latency: u16,
#[cfg_attr(feature = "serde", serde(rename(serialize = "num_signals")))]
pub num_signals: u8,
#[cfg_attr(feature = "serde", serde(rename(serialize = "source")))]
pub source: SbpString<Vec<u8>, Unterminated>,
}
impl ConcreteMessage for MsgDgnssStatus {
const MESSAGE_TYPE: u16 = 65282;
const MESSAGE_NAME: &'static str = "MSG_DGNSS_STATUS";
}
impl SbpMessage for MsgDgnssStatus {
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 MsgDgnssStatus {
type Error = TryFromSbpError;
fn try_from(msg: Sbp) -> Result<Self, Self::Error> {
match msg {
Sbp::MsgDgnssStatus(m) => Ok(m),
_ => Err(TryFromSbpError),
}
}
}
impl WireFormat for MsgDgnssStatus {
const MIN_LEN: usize = <u8 as WireFormat>::MIN_LEN
+ <u16 as WireFormat>::MIN_LEN
+ <u8 as WireFormat>::MIN_LEN
+ <SbpString<Vec<u8>, Unterminated> as WireFormat>::MIN_LEN;
fn len(&self) -> usize {
WireFormat::len(&self.flags)
+ WireFormat::len(&self.latency)
+ WireFormat::len(&self.num_signals)
+ WireFormat::len(&self.source)
}
fn write<B: BufMut>(&self, buf: &mut B) {
WireFormat::write(&self.flags, buf);
WireFormat::write(&self.latency, buf);
WireFormat::write(&self.num_signals, buf);
WireFormat::write(&self.source, buf);
}
fn parse_unchecked<B: Buf>(buf: &mut B) -> Self {
MsgDgnssStatus {
sender_id: None,
flags: WireFormat::parse_unchecked(buf),
latency: WireFormat::parse_unchecked(buf),
num_signals: WireFormat::parse_unchecked(buf),
source: WireFormat::parse_unchecked(buf),
}
}
}
#[cfg_attr(feature = "serde", derive(serde::Serialize))]
#[derive(Debug, Clone)]
pub struct MsgGnssTimeOffset {
#[cfg_attr(feature = "serde", serde(skip_serializing))]
pub sender_id: Option<u16>,
#[cfg_attr(feature = "serde", serde(rename(serialize = "weeks")))]
pub weeks: i16,
#[cfg_attr(feature = "serde", serde(rename(serialize = "milliseconds")))]
pub milliseconds: i32,
#[cfg_attr(feature = "serde", serde(rename(serialize = "microseconds")))]
pub microseconds: i16,
#[cfg_attr(feature = "serde", serde(rename(serialize = "flags")))]
pub flags: u8,
}
impl ConcreteMessage for MsgGnssTimeOffset {
const MESSAGE_TYPE: u16 = 65287;
const MESSAGE_NAME: &'static str = "MSG_GNSS_TIME_OFFSET";
}
impl SbpMessage for MsgGnssTimeOffset {
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 MsgGnssTimeOffset {
type Error = TryFromSbpError;
fn try_from(msg: Sbp) -> Result<Self, Self::Error> {
match msg {
Sbp::MsgGnssTimeOffset(m) => Ok(m),
_ => Err(TryFromSbpError),
}
}
}
impl WireFormat for MsgGnssTimeOffset {
const MIN_LEN: usize = <i16 as WireFormat>::MIN_LEN
+ <i32 as WireFormat>::MIN_LEN
+ <i16 as WireFormat>::MIN_LEN
+ <u8 as WireFormat>::MIN_LEN;
fn len(&self) -> usize {
WireFormat::len(&self.weeks)
+ WireFormat::len(&self.milliseconds)
+ WireFormat::len(&self.microseconds)
+ WireFormat::len(&self.flags)
}
fn write<B: BufMut>(&self, buf: &mut B) {
WireFormat::write(&self.weeks, buf);
WireFormat::write(&self.milliseconds, buf);
WireFormat::write(&self.microseconds, buf);
WireFormat::write(&self.flags, buf);
}
fn parse_unchecked<B: Buf>(buf: &mut B) -> Self {
MsgGnssTimeOffset {
sender_id: None,
weeks: WireFormat::parse_unchecked(buf),
milliseconds: WireFormat::parse_unchecked(buf),
microseconds: WireFormat::parse_unchecked(buf),
flags: WireFormat::parse_unchecked(buf),
}
}
}
#[cfg_attr(feature = "serde", derive(serde::Serialize))]
#[derive(Debug, Clone)]
pub struct MsgGroupMeta {
#[cfg_attr(feature = "serde", serde(skip_serializing))]
pub sender_id: Option<u16>,
#[cfg_attr(feature = "serde", serde(rename(serialize = "group_id")))]
pub group_id: u8,
#[cfg_attr(feature = "serde", serde(rename(serialize = "flags")))]
pub flags: u8,
#[cfg_attr(feature = "serde", serde(rename(serialize = "n_group_msgs")))]
pub n_group_msgs: u8,
#[cfg_attr(feature = "serde", serde(rename(serialize = "group_msgs")))]
pub group_msgs: Vec<u16>,
}
impl ConcreteMessage for MsgGroupMeta {
const MESSAGE_TYPE: u16 = 65290;
const MESSAGE_NAME: &'static str = "MSG_GROUP_META";
}
impl SbpMessage for MsgGroupMeta {
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 MsgGroupMeta {
type Error = TryFromSbpError;
fn try_from(msg: Sbp) -> Result<Self, Self::Error> {
match msg {
Sbp::MsgGroupMeta(m) => Ok(m),
_ => Err(TryFromSbpError),
}
}
}
impl WireFormat for MsgGroupMeta {
const MIN_LEN: usize = <u8 as WireFormat>::MIN_LEN
+ <u8 as WireFormat>::MIN_LEN
+ <u8 as WireFormat>::MIN_LEN
+ <Vec<u16> as WireFormat>::MIN_LEN;
fn len(&self) -> usize {
WireFormat::len(&self.group_id)
+ WireFormat::len(&self.flags)
+ WireFormat::len(&self.n_group_msgs)
+ WireFormat::len(&self.group_msgs)
}
fn write<B: BufMut>(&self, buf: &mut B) {
WireFormat::write(&self.group_id, buf);
WireFormat::write(&self.flags, buf);
WireFormat::write(&self.n_group_msgs, buf);
WireFormat::write(&self.group_msgs, buf);
}
fn parse_unchecked<B: Buf>(buf: &mut B) -> Self {
MsgGroupMeta {
sender_id: None,
group_id: WireFormat::parse_unchecked(buf),
flags: WireFormat::parse_unchecked(buf),
n_group_msgs: WireFormat::parse_unchecked(buf),
group_msgs: WireFormat::parse_unchecked(buf),
}
}
}
#[cfg_attr(feature = "serde", derive(serde::Serialize))]
#[derive(Debug, Clone)]
pub struct MsgHeartbeat {
#[cfg_attr(feature = "serde", serde(skip_serializing))]
pub sender_id: Option<u16>,
#[cfg_attr(feature = "serde", serde(rename(serialize = "flags")))]
pub flags: u32,
}
impl ConcreteMessage for MsgHeartbeat {
const MESSAGE_TYPE: u16 = 65535;
const MESSAGE_NAME: &'static str = "MSG_HEARTBEAT";
}
impl SbpMessage for MsgHeartbeat {
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 MsgHeartbeat {
type Error = TryFromSbpError;
fn try_from(msg: Sbp) -> Result<Self, Self::Error> {
match msg {
Sbp::MsgHeartbeat(m) => Ok(m),
_ => Err(TryFromSbpError),
}
}
}
impl WireFormat for MsgHeartbeat {
const MIN_LEN: usize = <u32 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 {
MsgHeartbeat {
sender_id: None,
flags: WireFormat::parse_unchecked(buf),
}
}
}
#[cfg_attr(feature = "serde", derive(serde::Serialize))]
#[derive(Debug, Clone)]
pub struct MsgInsStatus {
#[cfg_attr(feature = "serde", serde(skip_serializing))]
pub sender_id: Option<u16>,
#[cfg_attr(feature = "serde", serde(rename(serialize = "flags")))]
pub flags: u32,
}
impl ConcreteMessage for MsgInsStatus {
const MESSAGE_TYPE: u16 = 65283;
const MESSAGE_NAME: &'static str = "MSG_INS_STATUS";
}
impl SbpMessage for MsgInsStatus {
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 MsgInsStatus {
type Error = TryFromSbpError;
fn try_from(msg: Sbp) -> Result<Self, Self::Error> {
match msg {
Sbp::MsgInsStatus(m) => Ok(m),
_ => Err(TryFromSbpError),
}
}
}
impl WireFormat for MsgInsStatus {
const MIN_LEN: usize = <u32 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 {
MsgInsStatus {
sender_id: None,
flags: WireFormat::parse_unchecked(buf),
}
}
}
#[cfg_attr(feature = "serde", derive(serde::Serialize))]
#[derive(Debug, Clone)]
pub struct MsgInsUpdates {
#[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 = "gnsspos")))]
pub gnsspos: u8,
#[cfg_attr(feature = "serde", serde(rename(serialize = "gnssvel")))]
pub gnssvel: u8,
#[cfg_attr(feature = "serde", serde(rename(serialize = "wheelticks")))]
pub wheelticks: u8,
#[cfg_attr(feature = "serde", serde(rename(serialize = "speed")))]
pub speed: u8,
#[cfg_attr(feature = "serde", serde(rename(serialize = "nhc")))]
pub nhc: u8,
#[cfg_attr(feature = "serde", serde(rename(serialize = "zerovel")))]
pub zerovel: u8,
}
impl ConcreteMessage for MsgInsUpdates {
const MESSAGE_TYPE: u16 = 65286;
const MESSAGE_NAME: &'static str = "MSG_INS_UPDATES";
}
impl SbpMessage for MsgInsUpdates {
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 MsgInsUpdates {
type Error = TryFromSbpError;
fn try_from(msg: Sbp) -> Result<Self, Self::Error> {
match msg {
Sbp::MsgInsUpdates(m) => Ok(m),
_ => Err(TryFromSbpError),
}
}
}
impl WireFormat for MsgInsUpdates {
const MIN_LEN: usize = <u32 as WireFormat>::MIN_LEN
+ <u8 as WireFormat>::MIN_LEN
+ <u8 as WireFormat>::MIN_LEN
+ <u8 as WireFormat>::MIN_LEN
+ <u8 as WireFormat>::MIN_LEN
+ <u8 as WireFormat>::MIN_LEN
+ <u8 as WireFormat>::MIN_LEN;
fn len(&self) -> usize {
WireFormat::len(&self.tow)
+ WireFormat::len(&self.gnsspos)
+ WireFormat::len(&self.gnssvel)
+ WireFormat::len(&self.wheelticks)
+ WireFormat::len(&self.speed)
+ WireFormat::len(&self.nhc)
+ WireFormat::len(&self.zerovel)
}
fn write<B: BufMut>(&self, buf: &mut B) {
WireFormat::write(&self.tow, buf);
WireFormat::write(&self.gnsspos, buf);
WireFormat::write(&self.gnssvel, buf);
WireFormat::write(&self.wheelticks, buf);
WireFormat::write(&self.speed, buf);
WireFormat::write(&self.nhc, buf);
WireFormat::write(&self.zerovel, buf);
}
fn parse_unchecked<B: Buf>(buf: &mut B) -> Self {
MsgInsUpdates {
sender_id: None,
tow: WireFormat::parse_unchecked(buf),
gnsspos: WireFormat::parse_unchecked(buf),
gnssvel: WireFormat::parse_unchecked(buf),
wheelticks: WireFormat::parse_unchecked(buf),
speed: WireFormat::parse_unchecked(buf),
nhc: WireFormat::parse_unchecked(buf),
zerovel: WireFormat::parse_unchecked(buf),
}
}
}
#[cfg_attr(feature = "serde", derive(serde::Serialize))]
#[derive(Debug, Clone)]
pub struct MsgPpsTime {
#[cfg_attr(feature = "serde", serde(skip_serializing))]
pub sender_id: Option<u16>,
#[cfg_attr(feature = "serde", serde(rename(serialize = "time")))]
pub time: u64,
#[cfg_attr(feature = "serde", serde(rename(serialize = "flags")))]
pub flags: u8,
}
impl ConcreteMessage for MsgPpsTime {
const MESSAGE_TYPE: u16 = 65288;
const MESSAGE_NAME: &'static str = "MSG_PPS_TIME";
}
impl SbpMessage for MsgPpsTime {
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 MsgPpsTime {
type Error = TryFromSbpError;
fn try_from(msg: Sbp) -> Result<Self, Self::Error> {
match msg {
Sbp::MsgPpsTime(m) => Ok(m),
_ => Err(TryFromSbpError),
}
}
}
impl WireFormat for MsgPpsTime {
const MIN_LEN: usize = <u64 as WireFormat>::MIN_LEN + <u8 as WireFormat>::MIN_LEN;
fn len(&self) -> usize {
WireFormat::len(&self.time) + WireFormat::len(&self.flags)
}
fn write<B: BufMut>(&self, buf: &mut B) {
WireFormat::write(&self.time, buf);
WireFormat::write(&self.flags, buf);
}
fn parse_unchecked<B: Buf>(buf: &mut B) -> Self {
MsgPpsTime {
sender_id: None,
time: WireFormat::parse_unchecked(buf),
flags: WireFormat::parse_unchecked(buf),
}
}
}
#[cfg_attr(feature = "serde", derive(serde::Serialize))]
#[derive(Debug, Clone)]
pub struct MsgStartup {
#[cfg_attr(feature = "serde", serde(skip_serializing))]
pub sender_id: Option<u16>,
#[cfg_attr(feature = "serde", serde(rename(serialize = "cause")))]
pub cause: u8,
#[cfg_attr(feature = "serde", serde(rename(serialize = "startup_type")))]
pub startup_type: u8,
#[cfg_attr(feature = "serde", serde(rename(serialize = "reserved")))]
pub reserved: u16,
}
impl ConcreteMessage for MsgStartup {
const MESSAGE_TYPE: u16 = 65280;
const MESSAGE_NAME: &'static str = "MSG_STARTUP";
}
impl SbpMessage for MsgStartup {
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 MsgStartup {
type Error = TryFromSbpError;
fn try_from(msg: Sbp) -> Result<Self, Self::Error> {
match msg {
Sbp::MsgStartup(m) => Ok(m),
_ => Err(TryFromSbpError),
}
}
}
impl WireFormat for MsgStartup {
const MIN_LEN: usize =
<u8 as WireFormat>::MIN_LEN + <u8 as WireFormat>::MIN_LEN + <u16 as WireFormat>::MIN_LEN;
fn len(&self) -> usize {
WireFormat::len(&self.cause)
+ WireFormat::len(&self.startup_type)
+ WireFormat::len(&self.reserved)
}
fn write<B: BufMut>(&self, buf: &mut B) {
WireFormat::write(&self.cause, buf);
WireFormat::write(&self.startup_type, buf);
WireFormat::write(&self.reserved, buf);
}
fn parse_unchecked<B: Buf>(buf: &mut B) -> Self {
MsgStartup {
sender_id: None,
cause: WireFormat::parse_unchecked(buf),
startup_type: WireFormat::parse_unchecked(buf),
reserved: WireFormat::parse_unchecked(buf),
}
}
}
#[cfg_attr(feature = "serde", derive(serde::Serialize))]
#[derive(Debug, Clone)]
pub struct MsgStatusReport {
#[cfg_attr(feature = "serde", serde(skip_serializing))]
pub sender_id: Option<u16>,
#[cfg_attr(feature = "serde", serde(rename(serialize = "reporting_system")))]
pub reporting_system: u16,
#[cfg_attr(feature = "serde", serde(rename(serialize = "sbp_version")))]
pub sbp_version: u16,
#[cfg_attr(feature = "serde", serde(rename(serialize = "sequence")))]
pub sequence: u32,
#[cfg_attr(feature = "serde", serde(rename(serialize = "uptime")))]
pub uptime: u32,
#[cfg_attr(feature = "serde", serde(rename(serialize = "status")))]
pub status: Vec<SubSystemReport>,
}
impl ConcreteMessage for MsgStatusReport {
const MESSAGE_TYPE: u16 = 65534;
const MESSAGE_NAME: &'static str = "MSG_STATUS_REPORT";
}
impl SbpMessage for MsgStatusReport {
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 MsgStatusReport {
type Error = TryFromSbpError;
fn try_from(msg: Sbp) -> Result<Self, Self::Error> {
match msg {
Sbp::MsgStatusReport(m) => Ok(m),
_ => Err(TryFromSbpError),
}
}
}
impl WireFormat for MsgStatusReport {
const MIN_LEN: usize = <u16 as WireFormat>::MIN_LEN
+ <u16 as WireFormat>::MIN_LEN
+ <u32 as WireFormat>::MIN_LEN
+ <u32 as WireFormat>::MIN_LEN
+ <Vec<SubSystemReport> as WireFormat>::MIN_LEN;
fn len(&self) -> usize {
WireFormat::len(&self.reporting_system)
+ WireFormat::len(&self.sbp_version)
+ WireFormat::len(&self.sequence)
+ WireFormat::len(&self.uptime)
+ WireFormat::len(&self.status)
}
fn write<B: BufMut>(&self, buf: &mut B) {
WireFormat::write(&self.reporting_system, buf);
WireFormat::write(&self.sbp_version, buf);
WireFormat::write(&self.sequence, buf);
WireFormat::write(&self.uptime, buf);
WireFormat::write(&self.status, buf);
}
fn parse_unchecked<B: Buf>(buf: &mut B) -> Self {
MsgStatusReport {
sender_id: None,
reporting_system: WireFormat::parse_unchecked(buf),
sbp_version: WireFormat::parse_unchecked(buf),
sequence: WireFormat::parse_unchecked(buf),
uptime: WireFormat::parse_unchecked(buf),
status: WireFormat::parse_unchecked(buf),
}
}
}
#[cfg_attr(feature = "serde", derive(serde::Serialize))]
#[derive(Debug, Clone)]
pub struct SubSystemReport {
#[cfg_attr(feature = "serde", serde(rename(serialize = "component")))]
pub component: u16,
#[cfg_attr(feature = "serde", serde(rename(serialize = "generic")))]
pub generic: u8,
#[cfg_attr(feature = "serde", serde(rename(serialize = "specific")))]
pub specific: u8,
}
impl WireFormat for SubSystemReport {
const MIN_LEN: usize =
<u16 as WireFormat>::MIN_LEN + <u8 as WireFormat>::MIN_LEN + <u8 as WireFormat>::MIN_LEN;
fn len(&self) -> usize {
WireFormat::len(&self.component)
+ WireFormat::len(&self.generic)
+ WireFormat::len(&self.specific)
}
fn write<B: BufMut>(&self, buf: &mut B) {
WireFormat::write(&self.component, buf);
WireFormat::write(&self.generic, buf);
WireFormat::write(&self.specific, buf);
}
fn parse_unchecked<B: Buf>(buf: &mut B) -> Self {
SubSystemReport {
component: WireFormat::parse_unchecked(buf),
generic: WireFormat::parse_unchecked(buf),
specific: WireFormat::parse_unchecked(buf),
}
}
}