Open johanbrus opened 4 years ago
I ran into this same issue recently.
I believe that send
is overridden by j1939.Bus
but send_periodic
is not.
I ended up writing a function that polls for received messages using something along the lines of:
MSG_POLL_TIMEOUT_SEC = 0.025
def update(bus):
"""
Messages are read via polling with timeout MSG_POLL_TIMEOUT_SEC.
"""
assert isinstance(bus, j1939.Bus)
recv_msg = lambda: bus.recv(MSG_POLL_TIMEOUT_SEC)
msg = recv_msg()
while msg:
logging.debug(f"Received message:\n\t{str(msg)}")
msg = recv_msg()
It's a bodge, but it worked for me. ¯\_(ツ)_/¯
I observed that although the send() command from the python-can library handles the 'pdu' message from the python-J1939 library fine, the send_periodic() command is gives the following error message:
Which is understandable as the arbitration_id argument which is found in the can.Message object is done differently in the python-j1939 way. However, I don't understand why the normal send() function seems to work fine.
Is this intended (maybe there is another way to send periodic messages with python-j1939?) or am I missing something?
Code for error reproduction: