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

Making full use of all hardware masks and filters #19

Open
xyx0826 opened this issue Apr 6, 2023 · 0 comments
Open

Making full use of all hardware masks and filters #19

xyx0826 opened this issue Apr 6, 2023 · 0 comments

Comments

@xyx0826
Copy link

xyx0826 commented Apr 6, 2023

It appears that the current behavior of calling listen with Matches will assign one (unused) mask and one (unused) filter for each Match provided, regardless if masks can be shared across multiple filters. This means the user can only utilize up to two filters out of the MCP2515's six. An improved behavior might roughly look like this:

MASKS = {
    _RXM0SIDH: None
    _RXM1SIDH: None
}

FILTERS = {
    _RXM0SIDH: {
        _RXF0SIDH: None
        _RXF1SIDH: None
    }
    # mask 1 ...
}

def listen(matches):
    for match in matches:
        mask_id = self._get_or_create_mask(match)
        # create filter ...

def _get_or_create_mask(match):
    mask_id = 0
    for reg, value in MASKS.values():
        if match.mask == value and has_free_filters:
            break # mask already exists, has free filters

        if value is None:
            break # otherwise use first available mask

If this looks good, I can help updating the current implementation.

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

No branches or pull requests

1 participant