Problems with filters

The free CAN Software API (Application Programming Interface) for Windows®
Post Reply
vasensio
Posts: 4
Joined: Wed 17. Apr 2019, 08:10

Problems with filters

Post by vasensio » Thu 25. Apr 2019, 14:40

Hello everybody,

I am working to implement a code to receive and send some messages but when I try to apply more than two filters, the application allows to receive IDs out the range. I will explain an example and show you how I have implemented this part.

This code is not exactly my code it's an approximation, but I don't put redundancies things like getting errors and things like that.

Code: Select all

// close the filter
iBuffer = PCAN_FILTER_CLOSE;
gFilter = CAN_SetValue(PCAN_USBBUS1, PCAN_MESSAGE_FILTER, &iBuffer, sizeof(iBuffer));

gFilter = CAN_FilterMessages(PCAN_USBBUS1, 36, 36, PCAN_MODE_EXTENDED);
gFilter = CAN_FilterMessages(PCAN_USBBUS1, 170, 170, PCAN_MODE_EXTENDED);
gFilter = CAN_FilterMessages(PCAN_USBBUS1, 180, 180, PCAN_MODE_EXTENDED);
gFilter = CAN_FilterMessages(PCAN_USBBUS1, 1056, 1056, PCAN_MODE_EXTENDED);

// Reading part
gStatus = CAN_ReadFD(m_devValue, &msgFD, &timestampFD);
My problem is that I am putting these filters but I can receive for example 174, 176, 1058 messages which are outside of those ranges.

I was reading that you can receive messages out of those ranges that you set because https://www.nxp.com/docs/en/application ... N97076.pdf and I saw this point on the help manual:
It is not guaranteed that an application only receives CAN messages in the range of FromID to ToID. This is caused by the operating principle of the SJA1000's acceptance filter. See also Philips Data Sheet "SJA1000 Stand-alone CAN-controller".
I would like to know if you know some solution to avoid this behavior.

Thanks for advance.

Víctor

K.Wagner
Software Development
Software Development
Posts: 1082
Joined: Wed 22. Sep 2010, 13:36

Re: Problems with filters

Post by K.Wagner » Thu 25. Apr 2019, 15:23

Hello,

as you self explain, this is a problem, which unfortunately you have to live with. Many applications today just implement filtering theyselft. You could also implement an extra filter in your application, so that additional received frames can be discarded.

If you want more information on this, you may be interested to check the CAN_SetValue parameters PCAN_ACCEPTANCE_FILTER_11BIT and PCAN_ACCEPTANCE_FILTER_29BIT. With those you can set the filter mask and filter code directly, as used in the SJA1000 CAN controller. You can read more about this within the pdf "PCAN-Parameter Documentation" (pages 44 to 48). Who knows, maybe using this way you can enhance your filter and get better results.
Best regards,
Keneth

vasensio
Posts: 4
Joined: Wed 17. Apr 2019, 08:10

Re: Problems with filters

Post by vasensio » Thu 25. Apr 2019, 15:41

Hi Wagner,

Thanks for your answer I will have in mind the options that you said to me.

Best regards,

Víctor

Post Reply