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
use super::gnss::*;
use super::lib::*;
#[cfg_attr(feature = "serde", derive(serde::Serialize))]
#[derive(Debug, Clone)]
pub struct MsgNdbEvent {
#[cfg_attr(feature = "serde", serde(skip_serializing))]
pub sender_id: Option<u16>,
#[cfg_attr(feature = "serde", serde(rename(serialize = "recv_time")))]
pub recv_time: u64,
#[cfg_attr(feature = "serde", serde(rename(serialize = "event")))]
pub event: u8,
#[cfg_attr(feature = "serde", serde(rename(serialize = "object_type")))]
pub object_type: u8,
#[cfg_attr(feature = "serde", serde(rename(serialize = "result")))]
pub result: u8,
#[cfg_attr(feature = "serde", serde(rename(serialize = "data_source")))]
pub data_source: u8,
#[cfg_attr(feature = "serde", serde(rename(serialize = "object_sid")))]
pub object_sid: GnssSignal,
#[cfg_attr(feature = "serde", serde(rename(serialize = "src_sid")))]
pub src_sid: GnssSignal,
#[cfg_attr(feature = "serde", serde(rename(serialize = "original_sender")))]
pub original_sender: u16,
}
impl ConcreteMessage for MsgNdbEvent {
const MESSAGE_TYPE: u16 = 1024;
const MESSAGE_NAME: &'static str = "MSG_NDB_EVENT";
}
impl SbpMessage for MsgNdbEvent {
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 MsgNdbEvent {
type Error = TryFromSbpError;
fn try_from(msg: Sbp) -> Result<Self, Self::Error> {
match msg {
Sbp::MsgNdbEvent(m) => Ok(m),
_ => Err(TryFromSbpError),
}
}
}
impl WireFormat for MsgNdbEvent {
const MIN_LEN: usize = <u64 as WireFormat>::MIN_LEN
+ <u8 as WireFormat>::MIN_LEN
+ <u8 as WireFormat>::MIN_LEN
+ <u8 as WireFormat>::MIN_LEN
+ <u8 as WireFormat>::MIN_LEN
+ <GnssSignal as WireFormat>::MIN_LEN
+ <GnssSignal as WireFormat>::MIN_LEN
+ <u16 as WireFormat>::MIN_LEN;
fn len(&self) -> usize {
WireFormat::len(&self.recv_time)
+ WireFormat::len(&self.event)
+ WireFormat::len(&self.object_type)
+ WireFormat::len(&self.result)
+ WireFormat::len(&self.data_source)
+ WireFormat::len(&self.object_sid)
+ WireFormat::len(&self.src_sid)
+ WireFormat::len(&self.original_sender)
}
fn write<B: BufMut>(&self, buf: &mut B) {
WireFormat::write(&self.recv_time, buf);
WireFormat::write(&self.event, buf);
WireFormat::write(&self.object_type, buf);
WireFormat::write(&self.result, buf);
WireFormat::write(&self.data_source, buf);
WireFormat::write(&self.object_sid, buf);
WireFormat::write(&self.src_sid, buf);
WireFormat::write(&self.original_sender, buf);
}
fn parse_unchecked<B: Buf>(buf: &mut B) -> Self {
MsgNdbEvent {
sender_id: None,
recv_time: WireFormat::parse_unchecked(buf),
event: WireFormat::parse_unchecked(buf),
object_type: WireFormat::parse_unchecked(buf),
result: WireFormat::parse_unchecked(buf),
data_source: WireFormat::parse_unchecked(buf),
object_sid: WireFormat::parse_unchecked(buf),
src_sid: WireFormat::parse_unchecked(buf),
original_sender: WireFormat::parse_unchecked(buf),
}
}
}