I have been trying to write a code that would allow me to read all the data on the CAN bus every 0.1 seconds. There are 10 messages on the bus that are being sent every 0.1 seconds from another RPI3. Are there any examples available?
I can read the messages using
import can while True: measurements = get_readings_from_canbus(can) time.sleep(0.1)
Should I use
can. recv() inside get_readings_from_canbus?
I tried to use
can.recv(), but it gets only one message. Using
can.notifier is not very clear to me, since it keeps reading the CAN bus.
This return all the bus messages
import can bus = can.interface.Bus(channel='can0', bustype='socketcan_native') notifier = can.Notifier(bus, [can.Printer()])
can.recv(), it returns only on message
import can bus = can.interface.Bus(channel='can0', bustype='socketcan_native') notifier = bus.recv()