Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
10 years, 3 months ago.
CAN filter from mbed API
It appears that the mbed API has acceptance filter support (at least for the LPC1549). documentation seems sparse on how to use this appropriately.
I have found examples like this
handle = can.filter(0x100, 0xff, CANStandard);
But many thread I find say it does not work and they have to work on a lower level (at least on the LPC1768/9) and use something like this.
h1 = can->filter(0x100, 0x700, CANStandard); // Accept standard messages with id 0x100-0x1FF
The LPC1549 (I believe the 11C24) have a different CAN peripheral than the LPC1768/9 so not much carries over on the low level.
Assuming filtering works on the LPC1549, how is it intended to be used? It appears that you create filters, then you run a "read" command for each filter you created (handle?) which searches the hardware buffer and returns a message if there is one that fits the filter. This is what I gather from the samples I can find using filters.
Is this correct usage?
Thanks
Assigned to
10 years, 3 months ago.This means that the question has been accepted and is being worked on.
Hello Toyomasa Watarai, I see you assigned to this question. I was wondering if you had any updates?
posted by Travis Travelstead 08 Aug 2014I have read more about the ID and masking when building the filters. I think I understand that well enough, it would still be nice to get some more information, but what I am still not sure of is how the filters should be implemented.
It appears you create message filter handles which I am guessing are sent to the peripheral in order to filter the incoming messages once they are created. It then appears use the read function (depending on API) to read from the buffer with the "handle" or filter passed with it so you only read the next available packet that passes that filter.
The best example I could find is using CMSIS, but is easy enough to read and compare to the mbed API.
From this it appears I can make several "handles" and when reading I use them to filter the one or more messages I want to get during that reading.
Without testing this should work to read only the ID 270, correct?
It's not working... :-(
posted by Shimon S. 20 Nov 2016I'd be very interested to see an answer (I'm using LPC1768)...
posted by Chris Mabey 17 Oct 2017It might be worth posting a new question to help get it noticed. I am surprised that the CAN interface does not have a clean
Here is a reference to somebody that coded their own way of adding filters. Looks a little complex, but at least it is a reference to a working method.
https://os.mbed.com/users/ym1784/code/CAN_MONITOR/file/fe1f886dff76/main.cpp
Looking at the documentation it looks like there might be a filter interface now. Not sure when this was added. https://docs.mbed.com/docs/mbed-os-api-reference/en/5.1/APIs/interfaces/digital/CAN/#api