Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion can/interfaces/etas/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ def _apply_filters(self, filters: can.typechecking.CanFilters | None) -> None:

for i, filter_ in enumerate(filters):
f = OCI_CANRxFilterEx()
f.frameIDValue = filter_["can_id"]
f.frameIDValue = filter_["can_id"] & filter_["can_mask"]
f.frameIDMask = filter_["can_mask"]
f.tag = 0
f.flagsValue = 0
Expand Down
1 change: 1 addition & 0 deletions doc/changelog.d/+etas-filter-id-mask.fixed.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixed ``EtasBus`` receiving no frames through a filter whose ``can_id`` sets bits above the 11-bit (standard) or 29-bit (extended) identifier range outside ``can_mask``.
25 changes: 25 additions & 0 deletions test/test_etas.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,31 @@ def test_extended_false_filter_rejects_extended_frames(self):
[(0x123, 0x7FF, 0, selfreception | extended)],
)

def test_filter_id_bits_outside_mask_are_ignored(self):
"""
Test Scope:
A standard-ID filter whose can_id has bits outside can_mask and
above the 11-bit identifier range installs a BOA filter whose
frameIDValue holds only the bits covered by can_mask.
Preconditions:
An EtasBus created with the filter can_id=0x18FF0123,
can_mask=0x7FF, "extended": False.
Events:
The constructor installs the filter.
Evaluate:
The installed frameIDValue is 0x123 and has no bits above the
11-bit range, which BOA documents as a filter that passes no frames.
"""
selfreception = self.etas.OCI_CAN_MSG_FLAG_SELFRECEPTION
extended = self.etas.OCI_CAN_MSG_FLAG_EXTENDED
self._bus(
can_filters=[{"can_id": 0x18FF0123, "can_mask": 0x7FF, "extended": False}]
)
self.assertEqual(
self.installed,
[(0x123, 0x7FF, 0, selfreception | extended)],
)


if __name__ == "__main__":
unittest.main()
Loading