Hello I have a Raspberry with an MCP2515 CAN bus device, for read entire values of broadcasting it's only this source in Python with use of python-can:
import can
bus = can.interface.Bus(channel='can0', bustype='socketcan_native')
notifier = can.Notifier(bus, [can.Printer()])
I need to filter that result for id, how it work? Can anybody make an example of it's possible make a filter? I watched on website of library and this is the web page of filtering: https://python-can.readthedocs.io/en/stable/bus.html#filtering
How it work? Thanks a lot for reply.
You should set the filter using the set_filters()
method of your instance of the Bus
class. The argument is an iterable of dictionaries each containing a can_id
, a can_mask
, and an optional extended
key.
bus.set_filters([{"can_id": 0x11, "can_mask": 0x21, "extended": False}])
Check out the internal api docs for more detailed information.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With