Skip to content

Making full use of all hardware masks and filters #19

Open
@xyx0826

Description

@xyx0826

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions