vex_cdc/
lib.rs

1//! Implementation of the VEX Robotics CDC protocol in Rust.
2//!
3//! This crate allows you to encode and decode packets used to communicate
4//! with products sold by [VEX Robotics] using their CDC (**C**ommunications
5//! **D**evice **C**lass) protocol. The protocol can be used to upload programs
6//! and interact with VEX brains and other hardware over USB and bluetooth.
7//!
8//! Currently, most packets supported by the [V5 Brain] and [V5 Controller] are
9//! implemented, though the packets provided by this crate are non-exhaustive.
10//!
11//! [VEX Robotics]: https://www.vexrobotics.com/
12//! [V5 Brain]: https://www.vexrobotics.com/276-4810.html
13//! [V5 Controller]: https://www.vexrobotics.com/276-4820.html
14//!
15//! This crate is used as a backing implementation for vexide's [vex-v5-serial]
16//! library and [cargo-v5].
17//!
18//! [vex-v5-serial]: http://crates.io/crates/vex-v5-serial
19//! [cargo-v5]: https://github.com/vexide/cargo-v5
20
21#![no_std]
22
23extern crate alloc;
24
25pub mod cdc;
26pub mod cdc2;
27
28mod crc;
29mod decode;
30mod encode;
31mod string;
32mod varint;
33mod version;
34
35pub use crc::{VEX_CRC16, VEX_CRC32};
36pub use decode::{Decode, DecodeError, DecodeErrorKind, DecodeWithLength};
37pub use encode::{Encode, MessageEncoder};
38pub use string::{FixedString, FixedStringSizeError};
39pub use varint::{VarU16, VarU16SizeError};
40pub use version::Version;
41
42/// Starting byte sequence for all device-bound CDC packets.
43pub const COMMAND_HEADER: [u8; 4] = [0xC9, 0x36, 0xB8, 0x47];
44
45/// Starting byte sequence used for all host-bound CDC packets.
46pub const REPLY_HEADER: [u8; 2] = [0xAA, 0x55];