Good morning,
I would like to have a filter for only certain CAN IDs instead of using an "allowed" range. We have a CAN device from a different vendor that allows for simply adding and removing CAN Ids from the filter, without having to provide a full range.
Is this somehow possible with the PCAN Basic API? I checked the documentation, but it looks like PCAN_MESSAGE_FILTER doesnt allow for that.
Thank you in advance,
BR
Filter for only specific IDs in PCAN Basic API
-
- Sales & Support
- Posts: 1083
- Joined: Fri 20. Sep 2019, 13:31
Re: Filter for only specific IDs in PCAN Basic API
Hello,
You can push individual IDs to the hardware-filter by only giving
the same ID when calling "FilterMessages":
Beware: The SJA1000-hardware filter has its quirks.
Sometimes messages still make it through (depending on the underlying bitmask, for more info see PCANBasic docs)
You cannot mix Standard and Extended IDs as it makes this more likely to happen.
Alternatively you can also use a software-filter (using if-conditions) or use a combination of the hardware-filter and a software-implementation to catch any unexpcted id coming through.
For further questions feel free to contact us again.
Best Regards
Marvin
You can push individual IDs to the hardware-filter by only giving
the same ID when calling "FilterMessages":
Code: Select all
## Set cascading filters:
stsResult = self.m_objPCANBasic.FilterMessages(self.PcanHandle, 0x102, 0x102, PCAN_MESSAGE_STANDARD)
if stsResult != PCAN_ERROR_OK and stsResult != PCAN_ERROR_QRCVEMPTY:
self.ShowStatus(stsResult)
stsResult = self.m_objPCANBasic.FilterMessages(self.PcanHandle, 0x108, 0x108, PCAN_MESSAGE_STANDARD)
if stsResult != PCAN_ERROR_OK and stsResult != PCAN_ERROR_QRCVEMPTY:
self.ShowStatus(stsResult)
stsResult = self.m_objPCANBasic.FilterMessages(self.PcanHandle, 0x131, 0x131, PCAN_MESSAGE_STANDARD)
if stsResult != PCAN_ERROR_OK and stsResult != PCAN_ERROR_QRCVEMPTY:
self.ShowStatus(stsResult)
Beware: The SJA1000-hardware filter has its quirks.
Sometimes messages still make it through (depending on the underlying bitmask, for more info see PCANBasic docs)
You cannot mix Standard and Extended IDs as it makes this more likely to happen.
Alternatively you can also use a software-filter (using if-conditions) or use a combination of the hardware-filter and a software-implementation to catch any unexpcted id coming through.
For further questions feel free to contact us again.
Best Regards
Marvin
---
Marvin Heidemann
PEAK-Support Team
Marvin Heidemann
PEAK-Support Team
Re: Filter for only specific IDs in PCAN Basic API
Thank you very much, that is exactly what I needed.