pub struct RomCode(/* private fields */);Expand description
The 64-bit identity every 1-Wire device carries: family, serial, and CRC.
The bytes are in bus order: the family code first, six serial bytes, then the CRC-8 over the first seven.
§Examples
use pamoja_hal::onewire::RomCode;
let rom = RomCode::new(0x28, 0x0000_05E2_FDC3).expect("a 48-bit serial");
assert_eq!(rom.family(), 0x28);
assert_eq!(rom.serial(), 0x0000_05E2_FDC3);
assert_eq!(RomCode::from_bytes(rom.bytes())?, rom);Implementations§
Source§impl RomCode
impl RomCode
Sourcepub fn from_bytes<E>(bytes: [u8; 8]) -> Result<RomCode, OneWireError<E>>
pub fn from_bytes<E>(bytes: [u8; 8]) -> Result<RomCode, OneWireError<E>>
Checks the CRC of eight bytes read off the bus and keeps them as a ROM code.
§Arguments
bytes- the eight bytes in bus order.
§Returns
The ROM code.
§Errors
Returns OneWireError::Crc if the last byte is not the CRC-8 of the first
seven.
Trait Implementations§
impl Copy for RomCode
impl Eq for RomCode
impl StructuralPartialEq for RomCode
Auto Trait Implementations§
impl Freeze for RomCode
impl RefUnwindSafe for RomCode
impl Send for RomCode
impl Sync for RomCode
impl Unpin for RomCode
impl UnsafeUnpin for RomCode
impl UnwindSafe for RomCode
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