Repository navigation
etas: keep the filters passed to the constructor - #2167
Merged
zariiii9003 merged 6 commits intoNov 29, 2026
Merged
Conversation
EtasBus installed can_filters, then called BusABC.__init__ without them, and its set_filters(None) replaced them with an accept-all filter. Pass can_filters to BusABC.__init__, which installs them once.
Codex Review Summary: ❌ FailedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
6 of 10 tasks
3 of 10 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary of Changes
can.Bus(interface="etas", channel=..., can_filters=[...])ends up with an accept-all frame filter (can_id0,can_mask0) on its receive queue, so the receive queue applies no CAN ID restriction and the requested identifier filters have no effect. Opening the bus without filters and callingbus.set_filters(...)afterwards is not affected.In
can/interfaces/etas/__init__.py,EtasBus.__init__installs the filters withself.filters = can_filters. TheBusABC.filterssetter callsset_filters, which callsEtasBus._apply_filters. At the end of the constructor,EtasBus.__init__callssuper().__init__(channel=channel, **kwargs)withoutcan_filters. Becausecan_filtersis a named parameter ofEtasBus.__init__, it is not inkwargs.BusABC.__init__therefore callsself.set_filters(None).EtasBus._apply_filtersthen callsOCI_RemoveCANFrameFilterExon the installed filters andOCI_AddCANFrameFilterExwith an accept-all filter (can_id0,can_mask0).PR #1704 ("Fix initialization order in EtasBus") moved
super().__init__()to the end of the constructor becausesupercallsset_filters. Before that change, the base call ran first. After it, the base call'sset_filters(None)runs after the constructor installscan_filters.This change removes
self.filters = can_filtersand callssuper().__init__(channel=channel, can_filters=can_filters, **kwargs).BusABC.__init__then installs the requested filters once at that point in initialization.self._oci_filters = Nonestays before the base call, so the first_apply_filterscall removes nothing. Withoutcan_filters, the bus installs the same accept-all filter as before.Calling
can.Bus(interface="etas", ...)with requested filters0x123/0x7FFand0x456/0x7FFagainst a stub replacing the BOA libraries (dll-csiBind,dll-ocdProxy) records these frame filter calls:A new test module,
test/test_etas.py, loadscan.interfaces.etaswithctypes.windllpatched to a stub library using thepatch.object(ctypes, "windll", ..., create=True)approach fromtest/test_pcan.py. It runs without the ETAS BOA install and tracks which frame filters are installed on the receive queue.test_constructor_filters_are_installedchecks frame ID, mask and flag values for a filter without theextendedkey and for an extended filter. That test fails onmainand passes with the fix.test_no_constructor_filters_accepts_allandtest_set_filters_replaces_constructor_filterspass on both branches and guard the unchanged paths. The orphan news fragmentdoc/changelog.d/+etas-constructor-filters.fixed.rstrecords the fix.Related Issues / Pull Requests
Type of Change
Checklist
tox).Additional Notes
Behavior is checked at the OCI call boundary without ETAS hardware. The count of 1 in the
mainremoval call is a separate issue left for its own change (a laterset_filters()after a bus opened with several filters leaves all but the first old filter installed). The same holds for a filter with"extended": False, which_apply_filtersinstalls without constraining the extended flag; the new tests do not depend on that.