pub struct CanFrame {
pub id: u32,
/* private fields */
}Expand description
A CAN 2.0B frame with a 29-bit identifier and up to 8 data bytes.
CanFrame is a small Copy value (no heap allocation), the unit of
exchange between this crate and your I/O layer. Convert to and from
GridConnect text with gridconnect, or map to a
SocketCAN / embedded CAN driver frame using CanFrame::id and
CanFrame::data. Debug prints CanFrame(19490ABC [01 02]);
Display and FromStr use GridConnect text (:X19490ABCN0102;, see
gridconnect).
use rolcb::CanFrame;
let f = CanFrame::new(0x195B_4123, &[5, 1, 1, 1, 0x22, 0, 0, 0x10])?;
assert_eq!(f.data().len(), 8);
assert_eq!(f.src_alias(), 0x123);
assert!(CanFrame::new(0x195B_4123, &[0; 9]).is_err());
assert_eq!(f.to_string(), ":X195B4123N0501010122000010;");
assert_eq!(":X195B4123N0501010122000010;".parse::<CanFrame>()?, f);Fields§
§id: u32The 29-bit extended identifier (upper three bits always zero when
built with CanFrame::new). Decode it with CanFrame::header.
Implementations§
Trait Implementations§
impl Copy for CanFrame
impl Eq for CanFrame
Source§impl FromStr for CanFrame
impl FromStr for CanFrame
Source§fn from_str(s: &str) -> Result<Self, ParseError>
fn from_str(s: &str) -> Result<Self, ParseError>
Parse GridConnect text, as gridconnect::parse.
Source§type Err = ParseError
type Err = ParseError
The associated error which can be returned from parsing.
impl StructuralPartialEq for CanFrame
Auto Trait Implementations§
impl Freeze for CanFrame
impl RefUnwindSafe for CanFrame
impl Send for CanFrame
impl Sync for CanFrame
impl Unpin for CanFrame
impl UnsafeUnpin for CanFrame
impl UnwindSafe for CanFrame
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more