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
5 changes: 3 additions & 2 deletions can/interfaces/etas/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,9 +240,10 @@ def _apply_filters(self, filters: can.typechecking.CanFilters | None) -> None:
else:
# enable the SR bit in the mask. since the bit is 0 in flagsValue -> do not self-receive
f.flagsMask = OCI_CAN_MSG_FLAG_SELFRECEPTION
if filter_.get("extended"):
f.flagsValue |= OCI_CAN_MSG_FLAG_EXTENDED
if "extended" in filter_:
f.flagsMask |= OCI_CAN_MSG_FLAG_EXTENDED
if filter_["extended"]:
f.flagsValue |= OCI_CAN_MSG_FLAG_EXTENDED
self._oci_filters[i] = ctypes.pointer(f)

OCI_AddCANFrameFilterEx(self.rxQueue, self._oci_filters, len(self._oci_filters))
Expand Down
1 change: 1 addition & 0 deletions doc/changelog.d/2177.fixed.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixed ``EtasBus`` ignoring ``"extended": False`` in a receive filter, so extended frames whose ID matched ``can_id`` and ``can_mask`` were still received.
21 changes: 21 additions & 0 deletions test/test_etas.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,27 @@ def test_set_filters_replaces_constructor_filters(self):
[(0x456, 0x7FF, 0, self.etas.OCI_CAN_MSG_FLAG_SELFRECEPTION)],
)

def test_extended_false_filter_rejects_extended_frames(self):
"""
Test Scope:
A filter with "extended": False installs a BOA filter that
requires the extended flag to be clear.
Preconditions:
An EtasBus created with a standard-ID filter that sets "extended": False.
Events:
The constructor installs the filter.
Evaluate:
The extended flag is in flagsMask and not in flagsValue, so the
controller drops extended frames whose ID matches can_id and can_mask.
"""
selfreception = self.etas.OCI_CAN_MSG_FLAG_SELFRECEPTION
extended = self.etas.OCI_CAN_MSG_FLAG_EXTENDED
self._bus(can_filters=[{"can_id": 0x123, "can_mask": 0x7FF, "extended": False}])
self.assertEqual(
self.installed,
[(0x123, 0x7FF, 0, selfreception | extended)],
)


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