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

Implement filtering for multiple CAN ids #20

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

M4GNV5
Copy link

@M4GNV5 M4GNV5 commented May 31, 2019

i tried to keep the interface simple for the user, you simply specify a list of CAN ids you are interrested in and the library handles when the hardware does not have enough filter registers.

int MCP2515Class::multiFilter(int *ids, unsigned count)

ref #19

@t-c-o-d-e
Copy link

Hi,

is this ever implemented?

Thank you for this beautiful and simple for use library!

@ghost
Copy link

ghost commented May 30, 2020

@sandeepmistry Do you think this could be merged? I have a requirement to filter for two IDs, currently this does need to be done in the MCU, while with this PR it could be done natively in the CAN controller (if you have enough filter registers).


// normal mode
writeRegister(REG_CANCTRL, 0x00);
if (readRegister(REG_CANCTRL) != 0x00) {
Copy link

Choose a reason for hiding this comment

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

You should probably put this into the same mode as it previously was (read mode before setting to config?). Or document that this function explicitely puts the controller into normal mode, so users are not surprised.

Copy link

@timurrrr timurrrr Jul 29, 2020

Choose a reason for hiding this comment

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

The datasheet says

In Listen-Only mode, both valid and invalid messages will
be received, regardless of filters and masks or the
Receive Buffer Operating Mode bits, RXMn.

This code matches the existing behavior implemented in filter() that resets the mode to "normal" on lines 307-311.

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.

3 participants