I have a python script that has 2 thread to perform CAN TX and CAN RX. I'm more concerned about CAN RX. Right now I run
bus.recv(timeout=)
on my receiver thread. But I feel this is not the smartest way to do it.
Going through the documentation, I came across
can.BufferedReader(*args, **kwargs)
with the class methods,
get_message(timeout=0.5)
on_message_received(msg)
The get_message()
retrives the latest message on the RX buffer and on_message_received()
puts the message to RX Buffer. So I was wondering if there is a way to append the messages to the RX buffer using on_message_received()
and get the messages for further processing.
My question is, how do I get the messages from my RX buffer, as get_message()
only gets the latest message. I want to iterate through all the messages in the RX buffer for my processing. Does anyone have a pseudocode that achieves this functionality.
I tried using my buffered reader along with my notifier. but no luck in achieving this functionality as get_message()
always returns my latest message. But not iterate through the buffer.