diff --git a/src/message.rs b/src/message.rs index cfffb32..d594f3f 100644 --- a/src/message.rs +++ b/src/message.rs @@ -202,53 +202,3 @@ impl RxHeader { } } } - -/// Receive message object header -#[bitfield(bits = 64)] -#[derive(Default, PartialEq, Eq, Debug)] -#[repr(u64)] -pub struct RxHeader { - // R0 - #[skip] - __: B2, - sid11: bool, - extended_identifier: B18, - standard_identifier: B11, - #[skip] - __: B16, - filter_hit: B5, - #[skip] - __: B2, - error_status_indicator: bool, - fd_frame: bool, - bit_rate_switch: bool, - remote_transmission_request: bool, - identifier_extension_flag: bool, - data_length_code: DLC, -} - -impl RxHeader { - fn get_id(&self) -> Id { - if self.identifier_extension_flag() { - let id = ((self.standard_identifier() as u32) << 18) | (self.extended_identifier()); - let extended_id = ExtendedId::new(id); - Id::Extended(extended_id.unwrap()) - } else { - let id = StandardId::new(self.standard_identifier()); - Id::Standard(id.unwrap()) - } - } - #[cfg(test)] - pub fn new_test_cfg(identifier: Id) -> Self { - match identifier { - Id::Extended(eid) => Self::new() - .with_data_length_code(DLC::Eight) - .with_standard_identifier((eid.as_raw() >> 18) as u16 & STANDARD_IDENTIFIER_MASK) - .with_extended_identifier(eid.as_raw() & EXTENDED_IDENTIFIER_MASK) - .with_identifier_extension_flag(true), - Id::Standard(sid) => Self::new() - .with_data_length_code(DLC::Eight) - .with_standard_identifier(sid.as_raw()), - } - } -} diff --git a/src/registers.rs b/src/registers.rs index 82976b6..434003d 100644 --- a/src/registers.rs +++ b/src/registers.rs @@ -1,4 +1,5 @@ use modular_bitfield_msb::prelude::*; + /// Fourth byte of FIFO Control register #[bitfield] #[derive(Default)] diff --git a/src/tests/can.rs b/src/tests/can.rs index 15ac759..e61f18f 100644 --- a/src/tests/can.rs +++ b/src/tests/can.rs @@ -276,6 +276,7 @@ fn test_transmit() { fn test_receive() { let mut mocks = Mocks::default(); + let mut seq = Sequence::new(); let id = ExtendedId::new(EXTENDED_ID).unwrap(); // custom Rx message header for testing @@ -284,10 +285,10 @@ fn test_receive() { let mut message_buff = [0u8; 16]; // status register read - mocks.mock_register_read::<0b0000_0001>([0x30, 0x60]); + mocks.mock_register_read::<0b0000_0001>([0x30, 0x60], &mut seq); // user address register read - mocks.mock_read32::<0x00_00_04_7C>([0x30, 0x64]); + mocks.mock_read32::<0x00_00_04_7C>([0x30, 0x64], &mut seq); // Message read from RAM address 0x47C //transfer cmd+address