Skip to content

Commit 2c935c1

Browse files
committed
can: Clarify matching logic for filters
The logic for the RTR bit was inverted
1 parent 24abc70 commit 2c935c1

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

src/can.rs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -136,26 +136,28 @@ pub trait Filter {
136136

137137
/// Applies a mask to the filter.
138138
///
139+
/// A filter matches when: `<ReceiveID> & Mask == FilterID & Mask`
140+
///
139141
/// # Example
140142
///
141-
/// Filter ID: 0b100110111
142-
/// Mask: 0b000001111
143+
/// FilterID: 0b100110111
144+
/// Mask: 0b000001111
143145
///
144-
/// Receive ID: 0b100110011
145-
/// \----> Not accepted (bit 3 did not match)
146+
/// ReceiveID: 0b100110011
147+
/// \----> Not accepted (3rd bit did not match)
146148
///
147-
/// Receive ID: 0b000000111 -> accepted
149+
/// ReceiveID: 0b000000111 -> accepted
148150
fn with_mask(&mut self, mask: u32) -> &mut Self;
149151

150152
/// Makes the filter acccept both data and remote frames.
151153
///
152-
/// Sets the RTR bit in the filter mask.
154+
/// Clears the RTR bit in the filter mask.
153155
/// Only available for filters with `RtrFilterBehavior::Configurable`.
154156
fn allow_remote(&mut self) -> &mut Self;
155157

156158
/// Makes the filter acccept remote frames only.
157159
///
158-
/// Sets the RTR bit in the filter and clears it in the mask (if available).
160+
/// Sets the RTR bit in both the filter and the mask (if available).
159161
/// Only available for filters with `RtrFilterBehavior::Configurable` or
160162
/// `RtrFilterBehavior::ConfigurableEitherDataOrRemote`.
161163
fn remote_only(&mut self) -> &mut Self;

0 commit comments

Comments
 (0)