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
//! The VESC® firmware is an open source motor controller firmware, and this
//! library implements the necessary structures and functions to [`encode`]
//! commands and [`decode`] replies.
//!
//! # Examples
//!
//! ## Encoding a Command
//!
//! ```no_run
//! use vesc::{Command, ValuesMask};
//!
//! let mut buf = [0u8; 64];
//! let command = Command::GetValuesSelective(ValuesMask::RPM | ValuesMask::VOLTAGE_IN);
//! let frame_len = vesc::encode(command, &mut buf).unwrap();
//! let frame = &buf[..frame_len];
//! ```
//!
//! ## Decoding a Reply
//!
//! ```no_run
//! use vesc::CommandReply;
//!
//! match vesc::decode(&[2, 7, 50, 0, 0, 1, 128, 0, 0, 4, 210, 1, 176, 254, 22, 3]) {
//! Ok((_, CommandReply::GetValuesSelective(values))) => {
//! let rpm = values.rpm;
//! let voltage_in = values.voltage_in;
//! },
//! _ => (),
//! }
//! ```
//!
//! ## Decoding a Stream
//!
//! ```no_run
//! use vesc::{Decoder, CommandReply};
//!
//! let mut decoder = Decoder::default();
//! decoder.feed(&[2, 7, 50, 0, 0, 1, 128, 0, 0, 4, 210, 1, 176, 254, 22, 3]);
//!
//! for reply in decoder.by_ref() {
//! match reply {
//! CommandReply::GetValuesSelective(values) => {
//! let rpm = values.rpm;
//! let voltage_in = values.voltage_in;
//! },
//! _ => (),
//! }
//! }
//! ```
pub use ;
pub use Decoder;