Skip to content

Conversation

varunpenumudi
Copy link
Contributor

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 constructor. 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:

  • Added the can_filters parameter to SeeedBus.__init__.
  • The implementation validates that only one filter is provided, raising a can.CanInitializationError if more are given, in accordance with the Seed Bus protocol limitation.
  • Updated the seeedstudio.rst documentation to reflect the new parameter and its usage
  • Added a news fragment for the changelog.

Note: This change is fully backward-compatible. If can_filters is not provided, 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.

@varunpenumudi varunpenumudi deleted the seedbus-filters-feature branch October 14, 2025 16:45
@varunpenumudi
Copy link
Contributor Author

Dont merge these changes, this PR have some issues

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants