Example Code does not Filter Messages

The free CAN Software API (Application Programming Interface) for Windows®
Post Reply
amyers
Posts: 2
Joined: Tue 20. Jun 2017, 20:33

Example Code does not Filter Messages

Post by amyers » Tue 20. Jun 2017, 20:43

I am using PCAN Basic for python.

I could not get the FilterMessages to work correctly with my code, so I tried to use the example code to test it out and see if I was doing something wrong. When I used the example code, it also did not filter messages.

I initialized the CAN, then closed the message filter, then customized the message filter to accept only one ID (From and To are the same ID), and then I read the messages manually and none of them had the ID I filtered for.

I attached the log to demonstrate the issue. Am I missing something?

Thanks
Attachments
PCANBasic.log
(5.12 KiB) Downloaded 209 times

amyers
Posts: 2
Joined: Tue 20. Jun 2017, 20:33

Re: Example Code does not Filter Messages

Post by amyers » Tue 20. Jun 2017, 21:14

Ok, I found out that you have to call Reset() in order to flush the un-filtered messages out of the receive queue after filtering messages.

sergio.bobillier
Posts: 2
Joined: Mon 21. Oct 2019, 09:07

Re: Example Code does not Filter Messages

Post by sergio.bobillier » Wed 1. Apr 2020, 15:17

Thanks, after hours of debugging and unfruitfully tweaking the filters and what not this is what worked for me.

But the documentation says exactly the opposite:
Take in account that configuring the message filter cause the CAN controller to enter the Reset state. This will affect other applications that communicate with the same PCAN hardware.
Please guys update the documentation to include this. It would save a lot of time.

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

Re: Example Code does not Filter Messages

Post by K.Wagner » Wed 1. Apr 2020, 15:59

Hello,

please don't mixup apples and pears. The user amyers wanted to clear the message queues of a connection. This is done using the function CAN_Reset() as stated in the help:
"Resets the receive and transmit queues of a PCAN Channel."
Now, you are here quoting a remark of the function CAN_FilterMessages, which configures the acceptance mask and code registers of the CAN controller. As the help states, this causes the CAN controller to enter the "Reset state" (it has nothing to do with the CAN_Reset function, but with the behavior in the CAN controller). What do you mean with
sergio.bobillier wrote:
Wed 1. Apr 2020, 15:17
But the documentation says exactly the opposite
The only thing that is not correct is that the word "Reset" from "Reset state" was automatically interpreted by the help compiler as a link to the CAN_Reset function, what is wrong. This was already fixed and will be available by the next release of the library.
Best regards,
Keneth

Post Reply