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
//! Native implementation of decoding of SBP (Swift Binary Protocol) used by products
//! made by Swift Navigation. For language agnostic description of the protocol please
//! see the [protocol specification documentation](https://github.com/swift-nav/libsbp/tree/master/docs).
//!
//! # Example: Print log messages
//!
//! This example shows how to read messages from stdin and print the contents
//! of each message `MsgLog` to stderr.
//!
//! ```no_run
//! use std::convert::TryFrom;
//! use std::error::Error;
//! use std::io;
//! use std::process;
//!
//! use sbp::messages::logging::MsgLog;
//!
//! fn example() -> Result<(), Box<dyn Error>> {
//! let messages = sbp::iter_messages(io::stdin());
//! for msg in messages {
//! // The iterator yields Result<Sbp, Error>, so we check the error here.
//! let msg = msg?;
//! match MsgLog::try_from(msg) {
//! Ok(msg) => eprintln!("{}", msg.text),
//! _ => {}
//! }
//! }
//! Ok(())
//! }
//!
//! fn main() {
//! if let Err(err) = example() {
//! eprintln!("error: {}", err);
//! process::exit(1);
//! }
//! }
//! ```
//!
//! # Example: Filter by sender id and write to stdout
//!
//! This example shows how to read messages from stdin and forward messages with a matching
//! sender_id to stdout.
//!
//! ```no_run
//! use std::error::Error;
//! use std::io;
//! use std::process;
//!
//! use sbp::{SbpEncoder, SbpMessage};
//!
//! fn example(sender_id: u16) -> Result<(), Box<dyn Error>> {
//! let messages = sbp::iter_messages(io::stdin());
//! let messages = messages.filter_map(|msg| match msg {
//! Ok(msg) if msg.sender_id() == Some(sender_id) => Some(msg),
//! _ => None,
//! });
//! SbpEncoder::new(io::stdout()).send_all(messages)?;
//! Ok(())
//! }
//!
//! fn main() {
//! if let Err(err) = example(42) {
//! eprintln!("error: {}", err);
//! process::exit(1);
//! }
//! }
//! ```
pub
pub
pub
/// Denotes the start of frame transmission.
pub const PREAMBLE: u8 = 0x55;
/// Length of the header section.
pub const HEADER_LEN: usize = 1 /*preamble*/ + 2 /*msg_type*/ + 2 /*sender_id*/ + 1 /*len*/;
/// Internal buffer length.
pub const BUFLEN: usize = 128;
/// Max length of the variable-sized payload field.
pub const MAX_PAYLOAD_LEN: usize = 255;
/// Length of the crc of the payload.
pub const CRC_LEN: usize = 2;
/// Max length of a frame (header + payload + crc).
pub const MAX_FRAME_LEN: usize = HEADER_LEN + MAX_PAYLOAD_LEN + CRC_LEN;
pub use Sbp;
pub use crateSbpMessage;
pub use ;
pub use ;
pub use stream_messages;
pub use SbpIterExt;
pub use SbpString;