Enable echo frames in PCAN driver if receive_own_messages is set by tttech-ferdigg · Pull Request #1723 · hardbyte/python-can
import can def main(): bus1 = can.Bus( interface="pcan", channel="PCAN_USBBUS1", bitrate=500000, receive_own_messages=True ) bus2 = can.Bus( interface="pcan", channel="PCAN_USBBUS2", bitrate=500000, receive_own_messages=False ) msg1 = can.Message(arbitration_id=0x123, is_fd=False, data=b'hello') msg2 = can.Message(arbitration_id=0x123, is_fd=False, data=b'world') bus1.send(msg1) print(bus1.recv(0.1)) print(bus1.recv(0.1)) print(bus2.recv(0.1)) print(bus2.recv(0.1)) bus2.send(msg2) print(bus1.recv(0.1)) print(bus1.recv(0.1)) print(bus2.recv(0.1)) print(bus2.recv(0.1)) if __name__ == "__main__": main()
I did a back-to-back test with two PCAN interfaces, and the output I got was the following:
Timestamp: 1705482812.765127 ID: 00000123 X Rx DL: 5 68 65 6c 6c 6f 'hello'
None
Timestamp: 1705482812.765166 ID: 00000123 X Rx DL: 5 68 65 6c 6c 6f 'hello'
None
Timestamp: 1705482812.970332 ID: 00000123 X Rx DL: 5 77 6f 72 6c 64 'world'
None
None
None
So, it looks like it's working as intended.