Skip to content
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

Use all mask filter pairs #25

Merged
merged 3 commits into from
Jun 10, 2024
Merged

Conversation

karlfl
Copy link

@karlfl karlfl commented Apr 24, 2024

Addresses #19

This is a simple approach to fixing the issue of not properly using all of the Masks and Filters available on the MCP2515. This update does the following.

  1. When adding a mask, place the actual mask value in the _masks_in_use array so we can search for it later if is used in another match.
  2. Prior to adding the mask, check to see if it's already in the _masks_in_use array, if so just return that index.

As far as I can tell, the previous code was using the _masks_in_use array to store the mask register being used, not the actual mask value. The only purpose for this array seemed to be for checking the array length to determine how many masks were in use. By placing the actual mask value in the _masks_in_use array, we're able to also search for it so more than one filter can be paired with each mask. This change shouldn't affect the checks used to ensure the max number mask/filter pairs is enforced.

This change also expands the documentation for '.listen()', adding details on how to use the matches array to setup the masks and filters on the MCP2515 using this library.

I've tested this change on an RP2040 CAN Bus Feather

Copy link
Contributor

@FoamyGuy FoamyGuy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes sense and looks good to me. Thank you @karlfl

I do not have necessary hardware for testing.

@FoamyGuy FoamyGuy merged commit dde7f03 into adafruit:main Jun 10, 2024
1 check passed
adafruit-adabot added a commit to adafruit/Adafruit_CircuitPython_Bundle that referenced this pull request Jun 11, 2024
Updating https://github.com/adafruit/Adafruit_CircuitPython_MCP2515 to 1.1.5 from 1.1.4:
  > Merge pull request adafruit/Adafruit_CircuitPython_MCP2515#25 from karlfl/Use_All_Mask_Filter_Pairs

Updating https://github.com/adafruit/Adafruit_CircuitPython_MLX90393 to 2.1.5 from 2.1.4:
  > Merge pull request adafruit/Adafruit_CircuitPython_MLX90393#40 from purepani/add_exit_before_rt

Updating https://github.com/adafruit/Adafruit_CircuitPython_MLX90640 to 1.3.2 from 1.3.1:
  > Merge pull request adafruit/Adafruit_CircuitPython_MLX90640#32 from adafruit/stemma_i2c

Updating https://github.com/adafruit/Adafruit_CircuitPython_AirLift to 1.0.14 from 1.0.13:
  > Merge pull request adafruit/Adafruit_CircuitPython_AirLift#11 from dhalbert/fix-start-wifi

Updating https://github.com/adafruit/Adafruit_CircuitPython_Display_Text to 3.1.1 from 3.1.0:
  > Merge pull request adafruit/Adafruit_CircuitPython_Display_Text#206 from SamantazFox/patch-1

Updating https://github.com/adafruit/Adafruit_CircuitPython_Bundle/circuitpython_library_list.md to NA from NA:
  > Updated download stats for the libraries
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