107-systems / 107-Arduino-MCP2515

Arduino library for controlling the MCP2515 in order to receive/transmit CAN frames.
https://107-systems.org
MIT License
88 stars 14 forks source link

[Support] Filters not acting the way I assume they would #88

Closed EliotRossRob closed 1 year ago

EliotRossRob commented 1 year ago

I am trying to use the 107-Arduino-MCP2515 library along with the 107-Arduino-Cyphal library in to communicate CAN messages to and from a CCU from multiple pico pi's. I want to be able to filter out the messages coming from the other picos on each of the pico so that only the ccu is received on any of the picos. I have managed to successfully get this working although i'm unsure as to why it works this way as i expect from my research into masking and filtering bits that the setup should be different, so an insight as to why this occurs would be great. Current Setup of filters: uint32_t const RXMB0_MASK = 0x000000FF; uint32_t const RXMB1_MASK = 0x0000000F; uint32_t const YAKUT_NODE_ID = 0xFFFFFF2A; uint32_t const CYPHAL_NODE_ID = 0xFFFFFF02; uint32_t const NODE_ID_RANGE = 0x01FFFFFF;

`size_t const RXMB0_FILTER_SIZE = 1; // Can only be up to 2 uint32_t const RXMB0_FILTER[RXMB0_FILTER_SIZE] = { NODE_ID_RANGE }; mcp2515.enableFilter(MCP2515::RxB::RxB0, RXMB0_MASK, RXMB0_FILTER, RXMB0_FILTER_SIZE);

size_t const RXMB1_FILTER_SIZE = 2; // Can be up to 4 uint32_t const RXMB1_FILTER[RXMB1_FILTER_SIZE] = { YAKUT_NODE_ID, CYPHAL_NODE_ID }; mcp2515.enableFilter(MCP2515::RxB::RxB1, RXMB1_MASK, RXMB1_FILTER, RXMB1_FILTER_SIZE);`

As I understand masking, when it is a zero in binary that byte can be whatever it wants, but when its a 1 then it must match that of the filters.

I have attempted to remove the first filter and just have the RxB1 but this then starts letting everything through, (or at least the node with id 6 that i am testing with) after remove i also changed 'RXMB1_MASK' to '0x000000FF' and the same occurs.

Any insight would be much appreciated, Can also provide more details if necessary

aentinger commented 1 year ago

I suggest you take a look at this here ;)

Btw. priority support is available on a contract basis ;)