-
Notifications
You must be signed in to change notification settings - Fork 654
SeedBus: Added can_filters parameter in SeedBus.__init__ method #1999
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SeedBus: Added can_filters parameter in SeedBus.__init__ method #1999
Conversation
| if can_filters is None: | ||
| can_filters = [{"can_id": 0x00, "can_mask": 0x00}] | ||
|
|
||
| if len(can_filters) > 1: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could use the software fallback of python-can if the user passes multiple filters. Check the implementation in BusABC.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good Idea will implement it
- Updated the __init__ function in SeedBus - Implemented software fallback, if the user passes multiple filters in can_filters dict.
|
I have completed the re-implementation of the can_filters for SeeedBus, incorporating the software fallback mechanism. |
|
Also updated the changelog and done all the tox tests |
|
The Line 169 in efd4de5
If you are using hardware filtering, you should return |
|
Ignore the pylint errors, i assume they are caused by the new |
- updated _recv_internal method of SeedBus to return also the Boolean value based on whether hw filter is enabled or not
Sorry, I haven't observed this, now i also updated the _recv_internal method of SeedBus to return the boolean of whether message i already filtered by hardware or to be filtered by software |
|
Again, except that lint error all the tests were passed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, thank you 👍
This pull request resolves issue #1995 by adding support for configuring the hardware acceptance filter and mask during SeeedBus initialization.
Previously, setting a hardware filter was not possible directly through the init call of SeedBus. Users had to use a workaround by manually overwriting internal attributes (filter_id, mask_id) and re-calling the internal init_frame() method after the bus was already created. This process was unintuitive, broke encapsulation, and was prone to errors.
This PR implements the standard can_filters parameter in the SeeedBus.init method, adhering to the BusABC interface. This allows users to set a hardware filter cleanly in a single step upon bus creation.
Key Changes:
SeeedBus.__init__.Note: This change is fully backward-compatible. If can_filters is not provided or None, the bus defaults to the previous behavior of accepting all messages.
Testing
I have personally tested this feature on a Waveshare USB to CAN Adapter (Model A), which uses the same serial protocol, and can confirm that it works as expected for both default (no filter) and filtered modes.