From 29b920d0d8a85694fdb183b2d85584ac2c3da57e Mon Sep 17 00:00:00 2001 From: Kjetil Kjeka Date: Thu, 19 Apr 2018 19:46:56 +0200 Subject: [PATCH 01/12] Added CAN hal --- src/can.rs | 113 +++++++++++++++++++++++++++++++++++++++++++++++++++++ src/lib.rs | 1 + 2 files changed, 114 insertions(+) create mode 100644 src/can.rs diff --git a/src/can.rs b/src/can.rs new file mode 100644 index 000000000..799e41182 --- /dev/null +++ b/src/can.rs @@ -0,0 +1,113 @@ +//! Controller Area Network + +use core::convert::TryInto; +use core::convert::TryFrom; + +use nb; + +/// A type that can either be `BaseId` or `ExtendedId` +#[cfg(feature = "unproven")] +pub trait Id: Sized { + /// The BaseId variant + type BaseId: BaseId + Into + TryFrom; + + /// The ExtendedId variant + type ExtendedId: ExtendedId + Into + TryFrom; +} + +/// A Can (11-bit) ID +#[cfg(feature = "unproven")] +pub trait BaseId: Sized { + /// A generic ID type that encapsulate this type + type Id: Id + From + TryInto; +} + +/// A Can Extended (28-bit) ID +#[cfg(feature = "unproven")] +pub trait ExtendedId: Sized { + /// A generic ID type that encapsulate this type + type Id: Id + From + TryInto; +} + +/// A Can Frame +#[cfg(feature = "unproven")] +pub trait Frame { + /// The Id type of this Frame + type Id: Id; + + /// Returns the Can-ID + fn id(&self) -> Self::Id; + + /// Returns `Some(Data)` if data frame. + /// Returns `None` if remote frame. + fn data(&self) -> Option<&[u8]>; +} + +/// A Can-FD Frame +#[cfg(feature = "unproven")] +pub trait FdFrame { + /// The Id type of this Frame + type Id: Id; + + /// Returns the Can-ID + fn id(&self) -> Self::Id; + + /// Returns `Some(Data)` if data frame. + /// Returns `None` if remote frame. + fn data(&self) -> Option<&[u8]>; +} + + +/// A CAN interface +#[cfg(feature = "unproven")] +pub trait Interface { + /// The Can Frame this Interface operates on + type Frame: Frame; + + /// The Interface Error type + type Error; + + /// Read the available `Frame` with the highest priority (lowest ID). + /// + /// NOTE: Can-FD Frames will not be received using this function. + fn receive(&mut self) -> nb::Result; + + /// Put a `Frame` in the transmit buffer (or a free mailbox). + /// + /// If the buffer is full, this function will try to replace a lower priority `Frame` + /// and return it. + fn transmit(&mut self, frame: &Self::Frame) -> nb::Result, Self::Error>; + + /// Put a `Frame` in the transmit buffer (or a free mailbox). + /// + /// A high priority `Frame` is prone to being blocked when this function is used. + fn transmit_without_priority(&mut self, frame: &Self::Frame) -> nb::Result<(), Self::Error>; + +} + +/// A CAN-FD interface +#[cfg(feature = "unproven")] +pub trait FdInterface { + /// The Can Frame this Interface operates on + type Frame: FdFrame; + + /// The Interface Error type + type Error; + + /// Read the available `FdFrame` with the highest priority (lowest ID). + /// + /// NOTE: ordinary Can Frames will not be received using this function. + fn receive_fd(&mut self) -> nb::Result; + + /// Put a `FdFrame` in the transmit buffer (or a free mailbox). + /// + /// If the buffer is full, this function will try to replace a lower priority `FdFrame` + /// and return it. + fn transmit_fd(&mut self, frame: &Self::Frame) -> nb::Result, Self::Error>; + + /// Put a `FdFrame` in the transmit buffer (or a free mailbox). + /// + /// A high priority `FdFrame` is prone to being blocked when this function is used. + fn transmit_fd_without_priority(&mut self, frame: &Self::Frame) -> nb::Result<(), Self::Error>; + +} \ No newline at end of file diff --git a/src/lib.rs b/src/lib.rs index 1f933295c..c1679d47c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -695,6 +695,7 @@ pub mod prelude; pub mod serial; pub mod spi; pub mod timer; +pub mod can; /// Input capture /// From 09887a02533c650657217ccf4c002cf2c0b81b9a Mon Sep 17 00:00:00 2001 From: Kjetil Kjeka Date: Fri, 20 Apr 2018 11:07:13 +0200 Subject: [PATCH 02/12] Removed weirdness in can interface - removed weird transmit function - Allow one function to receive all kinds of can frames --- src/can.rs | 42 ++++++++++++++++++++---------------------- 1 file changed, 20 insertions(+), 22 deletions(-) diff --git a/src/can.rs b/src/can.rs index 799e41182..65c9e8fc0 100644 --- a/src/can.rs +++ b/src/can.rs @@ -44,11 +44,17 @@ pub trait Frame { } /// A Can-FD Frame +/// +/// A "ordinary" Can-Frame must also be representable by this type. #[cfg(feature = "unproven")] pub trait FdFrame { /// The Id type of this Frame type Id: Id; + /// Returns true if this frame would/has be(en) transmitted as a Can-Fd frame. + /// Returns false if this frame would/has be(en) transmitted as a "ordinary" Can frame. + fn is_fd_frame(&self) -> bool; + /// Returns the Can-ID fn id(&self) -> Self::Id; @@ -67,7 +73,7 @@ pub trait Interface { /// The Interface Error type type Error; - /// Read the available `Frame` with the highest priority (lowest ID). + /// Return the available `Frame` with the highest priority (lowest ID). /// /// NOTE: Can-FD Frames will not be received using this function. fn receive(&mut self) -> nb::Result; @@ -75,39 +81,31 @@ pub trait Interface { /// Put a `Frame` in the transmit buffer (or a free mailbox). /// /// If the buffer is full, this function will try to replace a lower priority `Frame` - /// and return it. + /// and return it. This is to avoid the priority inversion problem. fn transmit(&mut self, frame: &Self::Frame) -> nb::Result, Self::Error>; - /// Put a `Frame` in the transmit buffer (or a free mailbox). - /// - /// A high priority `Frame` is prone to being blocked when this function is used. - fn transmit_without_priority(&mut self, frame: &Self::Frame) -> nb::Result<(), Self::Error>; + /// Returns true if a call to `transmit(frame)` (and if the interface supports Can-FD) + /// `transmit_fd(fd_frame)` would return a `Frame` or `WouldBlock`. + fn transmit_buffer_full(&self) -> bool; } -/// A CAN-FD interface +/// A CAN interface also supporting Can-FD #[cfg(feature = "unproven")] -pub trait FdInterface { +pub trait FdInterface: Interface { /// The Can Frame this Interface operates on - type Frame: FdFrame; - - /// The Interface Error type - type Error; + type FdFrame: FdFrame; /// Read the available `FdFrame` with the highest priority (lowest ID). - /// - /// NOTE: ordinary Can Frames will not be received using this function. - fn receive_fd(&mut self) -> nb::Result; + fn receive(&mut self) -> nb::Result; /// Put a `FdFrame` in the transmit buffer (or a free mailbox). /// /// If the buffer is full, this function will try to replace a lower priority `FdFrame` - /// and return it. - fn transmit_fd(&mut self, frame: &Self::Frame) -> nb::Result, Self::Error>; - - /// Put a `FdFrame` in the transmit buffer (or a free mailbox). - /// - /// A high priority `FdFrame` is prone to being blocked when this function is used. - fn transmit_fd_without_priority(&mut self, frame: &Self::Frame) -> nb::Result<(), Self::Error>; + /// and return it. This is to avoid the priority inversion problem. + fn transmit(&mut self, frame: &Self::FdFrame) -> nb::Result, Self::Error>; + /// Returns true if a call to `transmit(frame)` or `transmit_fd(fd_frame)` + /// would return a `FdFrame` or `WouldBlock`. + fn transmit_buffer_full(&self) -> bool; } \ No newline at end of file From 78b641c1682da468287f982356a69c12f8f0b25c Mon Sep 17 00:00:00 2001 From: Kjetil Kjeka Date: Sun, 22 Apr 2018 11:36:48 +0200 Subject: [PATCH 03/12] Rewrote Id trait to make it work with a wider range of representations --- src/can.rs | 64 +++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 44 insertions(+), 20 deletions(-) diff --git a/src/can.rs b/src/can.rs index 65c9e8fc0..8a9e189d4 100644 --- a/src/can.rs +++ b/src/can.rs @@ -1,40 +1,48 @@ //! Controller Area Network -use core::convert::TryInto; -use core::convert::TryFrom; - use nb; /// A type that can either be `BaseId` or `ExtendedId` #[cfg(feature = "unproven")] -pub trait Id: Sized { - /// The BaseId variant - type BaseId: BaseId + Into + TryFrom; +pub trait Id { + /// The (11-bit) BaseId variant. + type BaseId; - /// The ExtendedId variant - type ExtendedId: ExtendedId + Into + TryFrom; -} + /// The (29-bit) ExtendedId variant. + type ExtendedId; -/// A Can (11-bit) ID -#[cfg(feature = "unproven")] -pub trait BaseId: Sized { - /// A generic ID type that encapsulate this type - type Id: Id + From + TryInto; -} + /// Returns `Some(base_id)` if this Can-ID is 11-bit. + /// Returns `None` if this Can-ID is 29-bit. + fn base_id(&self) -> Option; -/// A Can Extended (28-bit) ID -#[cfg(feature = "unproven")] -pub trait ExtendedId: Sized { - /// A generic ID type that encapsulate this type - type Id: Id + From + TryInto; + /// Returns `Some(extended_id)` if this Can-ID is 29-bit. + /// Returns `None` if this Can-ID is 11-bit. + fn extended_id(&self) -> Option; } + /// A Can Frame #[cfg(feature = "unproven")] pub trait Frame { /// The Id type of this Frame type Id: Id; + /// Returns true if this `Frame` is a remote frame + fn is_remote_frame(&self) -> bool; + + /// Returns true if this `Frame` is a data frame + fn is_data_frame(&self) -> bool; + + /// Returns true if this `Frame` is a extended id frame + fn is_base_id_frame(&self) -> bool { + self.id().base_id().is_some() + } + + /// Returns true if this `Frame` is a extended id frame + fn is_extended_id_frame(&self) -> bool { + self.id().extended_id().is_some() + } + /// Returns the Can-ID fn id(&self) -> Self::Id; @@ -55,6 +63,22 @@ pub trait FdFrame { /// Returns false if this frame would/has be(en) transmitted as a "ordinary" Can frame. fn is_fd_frame(&self) -> bool; + /// Returns true if this `Frame` is a remote frame + fn is_remote_frame(&self) -> bool; + + /// Returns true if this `Frame` is a data frame + fn is_data_frame(&self) -> bool; + + /// Returns true if this `Frame` is a extended id frame + fn is_base_id_frame(&self) -> bool { + self.id().base_id().is_some() + } + + /// Returns true if this `Frame` is a extended id frame + fn is_extended_id_frame(&self) -> bool { + self.id().extended_id().is_some() + } + /// Returns the Can-ID fn id(&self) -> Self::Id; From c9a4f592116f51e86a53c521763ea161435661f6 Mon Sep 17 00:00:00 2001 From: Kjetil Kjeka Date: Tue, 24 Apr 2018 15:23:57 +0200 Subject: [PATCH 04/12] First take on filters --- src/can.rs | 68 +++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 67 insertions(+), 1 deletion(-) diff --git a/src/can.rs b/src/can.rs index 8a9e189d4..68a56cb42 100644 --- a/src/can.rs +++ b/src/can.rs @@ -20,6 +20,55 @@ pub trait Id { fn extended_id(&self) -> Option; } +/// A type that will either accept or filter a `Frame`. +/// The filtering is done solely on the `ID` of the `Frame`. +#[cfg(feature = "unproven")] +pub trait Filter { + /// The Id type this filter works on + type Id: Id; + + /// Constructs a filter that only accepts `Frame`s with the provided identifier. + fn from_id(id: Self::Id) -> Self; + + /// Constructs a filter that will accept any `Frame`. + fn accept_all() -> Self; + + /// Constructs a filter that will accept any `Frame` with extended `Id`. + fn accept_extended_id() -> Self; + + /// Constructs a filter that will accept any `Frame` with base`Id`. + fn accept_base_id() -> Self; + + /// Create a `Filter` from a filter/mask combination. + /// + /// *Note: When filtering base id any rule put on `bit_pos >= 11` will (for implementers: must) be ignored* + /// + /// ### Panic + /// (for implementers: must) panic if mask have bits equal to `1` for bit_position `>= 29`. + fn from_mask(mask: u32, filter: u32, accept_base_id: bool, accept_extended_id: bool) -> Self; + + /// Apply a filter rule on a specific bit. + /// + /// *Note: When filtering base id any rule put on `bit_pos >= 11` will (for implementers: must) be ignored* + /// + /// ### Panic + /// (for implementers: must) panic if `bit_pos >= 29`. + fn set_filter_bit(&mut self, bit_pos: u8, bit_state: bool); + + /// Apply a filter rule on a specific bit. + /// + /// *Note: When filtering base id any rule put on `bit_pos >= 11` will (for implementers: must) be ignored* + /// + /// ### Panic + /// (for implementers: must) panic if `bit_pos >= 29`. + fn clear_filter_bit(&mut self, bit_pos: u8); + + /// Returns `true` if the `Frame` would have been accepted by this filter. + /// Returns `false` if the `Frame` would have been filtered by this filter. + fn accept>(&self, frame: T) -> bool; + +} + /// A Can Frame #[cfg(feature = "unproven")] @@ -91,8 +140,14 @@ pub trait FdFrame { /// A CAN interface #[cfg(feature = "unproven")] pub trait Interface { + /// The Id type that works with this `Interface` + type Id: Id; + /// The Can Frame this Interface operates on - type Frame: Frame; + type Frame: Frame; + + /// The Filter type used in this `Interface` + type Filter: Filter; /// The Interface Error type type Error; @@ -112,6 +167,17 @@ pub trait Interface { /// `transmit_fd(fd_frame)` would return a `Frame` or `WouldBlock`. fn transmit_buffer_full(&self) -> bool; + /// Set the can controller in a mode where it only accept frames matching the given filter. + /// + /// If there exists several receive buffers, this filter will be applied for all of them. + /// + /// *Note: Even after this method has been called, there may still be `Frame`s in the receive buffer with + /// identifiers that would not been received with this `Filter`.* + fn set_filter(&mut self, filter: Self::Filter); + + /// Set the can controller in a mode where it will accept all frames. + fn clear_filter(&mut self); + } /// A CAN interface also supporting Can-FD From 99bf19385ae28b3b4e57fa678fe988af83109564 Mon Sep 17 00:00:00 2001 From: Kjetil Kjeka Date: Mon, 21 May 2018 15:23:03 +0200 Subject: [PATCH 05/12] Split Interface into Transmitter and Receiver --- src/can.rs | 41 +++++++++++++++++++++++++++++------------ 1 file changed, 29 insertions(+), 12 deletions(-) diff --git a/src/can.rs b/src/can.rs index 68a56cb42..a07be66f1 100644 --- a/src/can.rs +++ b/src/can.rs @@ -138,6 +138,8 @@ pub trait FdFrame { /// A CAN interface +/// +/// May be a `Transmitter`, `Receiver` or both. #[cfg(feature = "unproven")] pub trait Interface { /// The Id type that works with this `Interface` @@ -146,17 +148,16 @@ pub trait Interface { /// The Can Frame this Interface operates on type Frame: Frame; - /// The Filter type used in this `Interface` - type Filter: Filter; - /// The Interface Error type type Error; - /// Return the available `Frame` with the highest priority (lowest ID). - /// - /// NOTE: Can-FD Frames will not be received using this function. - fn receive(&mut self) -> nb::Result; + /// The Filter type used in this `Interface` + type Filter: Filter; +} +/// A CAN interface that is able to transmit frames. +#[cfg(feature = "unproven")] +pub trait Transmitter: Interface { /// Put a `Frame` in the transmit buffer (or a free mailbox). /// /// If the buffer is full, this function will try to replace a lower priority `Frame` @@ -166,6 +167,14 @@ pub trait Interface { /// Returns true if a call to `transmit(frame)` (and if the interface supports Can-FD) /// `transmit_fd(fd_frame)` would return a `Frame` or `WouldBlock`. fn transmit_buffer_full(&self) -> bool; +} + +/// A CAN interface that is able to receive frames. +pub trait Receiver: Interface { + /// Return the available `Frame` with the highest priority (lowest ID). + /// + /// NOTE: Can-FD Frames will not be received using this function. + fn receive(&mut self) -> nb::Result; /// Set the can controller in a mode where it only accept frames matching the given filter. /// @@ -177,18 +186,20 @@ pub trait Interface { /// Set the can controller in a mode where it will accept all frames. fn clear_filter(&mut self); - } /// A CAN interface also supporting Can-FD +/// +/// May be a `FdTransmitter`, `FdReceiver` or both. #[cfg(feature = "unproven")] pub trait FdInterface: Interface { /// The Can Frame this Interface operates on type FdFrame: FdFrame; +} - /// Read the available `FdFrame` with the highest priority (lowest ID). - fn receive(&mut self) -> nb::Result; - +/// A CAN-FD interface that is able to transmit frames. +#[cfg(feature = "unproven")] +pub trait FdTransmitter: FdInterface + Receiver { /// Put a `FdFrame` in the transmit buffer (or a free mailbox). /// /// If the buffer is full, this function will try to replace a lower priority `FdFrame` @@ -198,4 +209,10 @@ pub trait FdInterface: Interface { /// Returns true if a call to `transmit(frame)` or `transmit_fd(fd_frame)` /// would return a `FdFrame` or `WouldBlock`. fn transmit_buffer_full(&self) -> bool; -} \ No newline at end of file +} + +/// A CAN-FD interface that is able to receive frames. +pub trait FdReceiver: FdInterface + Transmitter { + /// Read the available `FdFrame` with the highest priority (lowest ID). + fn receive(&mut self) -> nb::Result; +} From c9c4f385b46be05eccc33c6fd4fbf04c4fe485cf Mon Sep 17 00:00:00 2001 From: Kjetil Kjeka Date: Mon, 21 May 2018 15:33:24 +0200 Subject: [PATCH 06/12] Remove method from FdInterface that have a redundant method in Interface --- src/can.rs | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/can.rs b/src/can.rs index a07be66f1..eeffbf19f 100644 --- a/src/can.rs +++ b/src/can.rs @@ -205,10 +205,6 @@ pub trait FdTransmitter: FdInterface + Receiver { /// If the buffer is full, this function will try to replace a lower priority `FdFrame` /// and return it. This is to avoid the priority inversion problem. fn transmit(&mut self, frame: &Self::FdFrame) -> nb::Result, Self::Error>; - - /// Returns true if a call to `transmit(frame)` or `transmit_fd(fd_frame)` - /// would return a `FdFrame` or `WouldBlock`. - fn transmit_buffer_full(&self) -> bool; } /// A CAN-FD interface that is able to receive frames. From 8099f74ca977ab44139549ad878aab376d171059 Mon Sep 17 00:00:00 2001 From: Kjetil Kjeka Date: Mon, 21 May 2018 15:44:11 +0200 Subject: [PATCH 07/12] Added a method that allows to check if there are pending transmits with a given ID --- src/can.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/can.rs b/src/can.rs index eeffbf19f..0154f2e04 100644 --- a/src/can.rs +++ b/src/can.rs @@ -164,6 +164,9 @@ pub trait Transmitter: Interface { /// and return it. This is to avoid the priority inversion problem. fn transmit(&mut self, frame: &Self::Frame) -> nb::Result, Self::Error>; + /// Returns true if there exists a pending transmit matching this filter. + fn pending_transmit(&self, filter: &Self::Filter) -> bool; + /// Returns true if a call to `transmit(frame)` (and if the interface supports Can-FD) /// `transmit_fd(fd_frame)` would return a `Frame` or `WouldBlock`. fn transmit_buffer_full(&self) -> bool; From 07904708aca767683094db3ad001c78f28869540 Mon Sep 17 00:00:00 2001 From: Kjetil Kjeka Date: Mon, 21 May 2018 15:44:23 +0200 Subject: [PATCH 08/12] typo --- src/can.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/can.rs b/src/can.rs index 0154f2e04..2f12eeac2 100644 --- a/src/can.rs +++ b/src/can.rs @@ -65,8 +65,7 @@ pub trait Filter { /// Returns `true` if the `Frame` would have been accepted by this filter. /// Returns `false` if the `Frame` would have been filtered by this filter. - fn accept>(&self, frame: T) -> bool; - + fn accepts>(&self, frame: T) -> bool; } From 2200dbe2702428c28323a48401a421b99d55c38b Mon Sep 17 00:00:00 2001 From: Kjetil Kjeka Date: Mon, 21 May 2018 16:41:02 +0200 Subject: [PATCH 09/12] added some missing unproven --- src/can.rs | 2 ++ src/lib.rs | 1 + 2 files changed, 3 insertions(+) diff --git a/src/can.rs b/src/can.rs index 2f12eeac2..98e1d7b1c 100644 --- a/src/can.rs +++ b/src/can.rs @@ -172,6 +172,7 @@ pub trait Transmitter: Interface { } /// A CAN interface that is able to receive frames. +#[cfg(feature = "unproven")] pub trait Receiver: Interface { /// Return the available `Frame` with the highest priority (lowest ID). /// @@ -210,6 +211,7 @@ pub trait FdTransmitter: FdInterface + Receiver { } /// A CAN-FD interface that is able to receive frames. +#[cfg(feature = "unproven")] pub trait FdReceiver: FdInterface + Transmitter { /// Read the available `FdFrame` with the highest priority (lowest ID). fn receive(&mut self) -> nb::Result; diff --git a/src/lib.rs b/src/lib.rs index c1679d47c..1917b846a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -695,6 +695,7 @@ pub mod prelude; pub mod serial; pub mod spi; pub mod timer; +#[cfg(feature = "unproven")] pub mod can; /// Input capture From a96e361ab6952c2580e43eb5867660693dffbd0a Mon Sep 17 00:00:00 2001 From: Kjetil Kjeka Date: Tue, 22 May 2018 13:54:22 +0200 Subject: [PATCH 10/12] Removed redundant methods in Filter interface annoying for implementors --- src/can.rs | 33 ++++++--------------------------- 1 file changed, 6 insertions(+), 27 deletions(-) diff --git a/src/can.rs b/src/can.rs index 98e1d7b1c..81607ea07 100644 --- a/src/can.rs +++ b/src/can.rs @@ -33,39 +33,18 @@ pub trait Filter { /// Constructs a filter that will accept any `Frame`. fn accept_all() -> Self; - /// Constructs a filter that will accept any `Frame` with extended `Id`. - fn accept_extended_id() -> Self; - - /// Constructs a filter that will accept any `Frame` with base`Id`. - fn accept_base_id() -> Self; - /// Create a `Filter` from a filter/mask combination. /// - /// *Note: When filtering base id any rule put on `bit_pos >= 11` will (for implementers: must) be ignored* - /// - /// ### Panic - /// (for implementers: must) panic if mask have bits equal to `1` for bit_position `>= 29`. - fn from_mask(mask: u32, filter: u32, accept_base_id: bool, accept_extended_id: bool) -> Self; - - /// Apply a filter rule on a specific bit. - /// - /// *Note: When filtering base id any rule put on `bit_pos >= 11` will (for implementers: must) be ignored* - /// - /// ### Panic - /// (for implementers: must) panic if `bit_pos >= 29`. - fn set_filter_bit(&mut self, bit_pos: u8, bit_state: bool); - - /// Apply a filter rule on a specific bit. + /// - Bit 0..11 is used when matching against base id + /// - Bit 0..29 is used when matching against extended_id + /// - Bit 29 matches the extended frame flag (can be used for only matching against base/extended ids) + /// - Bit 30..32 *must* be `0` /// /// *Note: When filtering base id any rule put on `bit_pos >= 11` will (for implementers: must) be ignored* /// /// ### Panic - /// (for implementers: must) panic if `bit_pos >= 29`. - fn clear_filter_bit(&mut self, bit_pos: u8); - - /// Returns `true` if the `Frame` would have been accepted by this filter. - /// Returns `false` if the `Frame` would have been filtered by this filter. - fn accepts>(&self, frame: T) -> bool; + /// (for implementers: must) panic if mask have bits equal to `1` for bit_position `>= 30`. + fn from_mask(mask: u32, filter: u32) -> Self; } From de0768afaa699cd73f9f892c4649f3b8a15b338c Mon Sep 17 00:00:00 2001 From: Kjetil Kjeka Date: Tue, 22 May 2018 17:28:56 +0200 Subject: [PATCH 11/12] Removed method for tracking transmits (since this is an impossible/unecessary feat) --- src/can.rs | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/can.rs b/src/can.rs index 81607ea07..c94feca00 100644 --- a/src/can.rs +++ b/src/can.rs @@ -142,9 +142,6 @@ pub trait Transmitter: Interface { /// and return it. This is to avoid the priority inversion problem. fn transmit(&mut self, frame: &Self::Frame) -> nb::Result, Self::Error>; - /// Returns true if there exists a pending transmit matching this filter. - fn pending_transmit(&self, filter: &Self::Filter) -> bool; - /// Returns true if a call to `transmit(frame)` (and if the interface supports Can-FD) /// `transmit_fd(fd_frame)` would return a `Frame` or `WouldBlock`. fn transmit_buffer_full(&self) -> bool; From b21991f23cf5d3804c79b266e5f1172ddca56673 Mon Sep 17 00:00:00 2001 From: Kjetil Kjeka Date: Tue, 22 May 2018 17:45:43 +0200 Subject: [PATCH 12/12] Removed redundant method as it's not trivial to implement for socketcan. Can add it later on if it is highly convinient --- src/can.rs | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/can.rs b/src/can.rs index c94feca00..47ed7ba49 100644 --- a/src/can.rs +++ b/src/can.rs @@ -141,10 +141,6 @@ pub trait Transmitter: Interface { /// If the buffer is full, this function will try to replace a lower priority `Frame` /// and return it. This is to avoid the priority inversion problem. fn transmit(&mut self, frame: &Self::Frame) -> nb::Result, Self::Error>; - - /// Returns true if a call to `transmit(frame)` (and if the interface supports Can-FD) - /// `transmit_fd(fd_frame)` would return a `Frame` or `WouldBlock`. - fn transmit_buffer_full(&self) -> bool; } /// A CAN interface that is able to receive frames.