MCP_CAN Problem

If someone could explain how these CAN IDS are getting through my mask & filter combination.
i am trying only receive certain can ids to capture messages at the highest frequency possible

binary

i have included the filter set up and an image of how i believe the filters work (a bitwise comparison) but for the highlighted position i belive the filter should not allow the message 202 through but yet it does

Hi @monitoroneuser I have not worked with CAN in some time, but is it possible that you're seeing 0x00000202 pass through the filter when you're expecting to filter out 0x02020000?

it was my understanding that that part of the mask filter is the data in a standard filter but i could be wrong

@monitoroneuser Just as a test, try replacing lines 61-63 with the following and see if you still are seeing 0x0202 make it through the filter.

canInterface.init_Mask(0, 0, 0x07FF0000);
canInterface.init_Filt(0, 0, 0x04820000);
canInterface.init_Filt(1, 0, 0x01820000);

it lets different messages in to compensate haha

these are the messages i am sending and obviously i only want the ones i am filtering for to show up on my bus

Very strange. Can you share more of your code (in text format) so we can see if anything else stands out?

In the meantime, it might be worth testing a simple version of your code (that reproduces this issue) on an Arduino compatible controller using the upstream library: GitHub - coryjfowler/MCP_CAN_lib: MCP_CAN Library

Then we might be able to isolate it to the Particle port of the library or something else.

I am using mcp_can.h (#include "mcp_can.h") I believe that is what is recommend for the monitor one. correct?

MCP_CAN canInterface(CAN_CS, SPI1);
 canInterface.init_Mask(0, 1, 0x1FFFFFFF);
    canInterface.init_Filt(0, 1, 0x0C0401FE);
    canInterface.init_Filt(1, 1, 0x0C0401FE);
    //canInterface.init_Filt(1, 1, 0x1800FEEE);
    //for some reason rectifyer temp and generator temp
    // is sent to frequently and breaks the whole thing

    canInterface.init_Mask(1, 0, 0x07FF0000);
    canInterface.init_Filt(2, 0, 0x04820000);
    canInterface.init_Filt(3, 0, 0x01820000);
    canInterface.init_Filt(4, 0, 0x06820000);
    canInterface.init_Filt(5, 0, 0x06820000);

 status = canInterface.begin(MCP_RX_STDEXT, BAUD_RATE, MCP_20MHZ);
        manualCANFilters(canInterface);
        canInterface.readMsgBufID(&rxId, &can_len, rxBuf);

I might try to create a new project with the minimum code required to reproduce the issue.

Here is the library recommend for CAN interface: GitHub - rickkas7/MCP_CAN_RK: MCP_CAN Library

One thing that I just noticed from the library's read me. I don't think this should impact filtering, but might be worth considering:

thanks yeah as far as I can tell 20 Mhz is correct.

I am using the monitor one. I believe that linked repo is for device other than monitor and tracker one, is that correct?

The Monitor One uses the same microcontroller under the hood as many other Particle devices. There should not be much of a difference with how the library behaves.

But, if you have another development board available, it might be useful to test your setup with different hardware.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.