Enable echo frames in PCAN driver if receive_own_messages is set#1723
Merged
zariiii9003 merged 3 commits intohardbyte:mainfrom Jan 20, 2024
Merged
Enable echo frames in PCAN driver if receive_own_messages is set#1723zariiii9003 merged 3 commits intohardbyte:mainfrom
zariiii9003 merged 3 commits intohardbyte:mainfrom
Conversation
Collaborator
|
Run |
Collaborator
|
This looks nice. I can test it next week. |
lumagi
approved these changes
Jan 17, 2024
Collaborator
lumagi
left a comment
There was a problem hiding this comment.
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.
Collaborator
|
Is it possible to detect the message direction to set the |
Contributor
Author
I will check. |
Contributor
Author
|
Works :) |
Collaborator
|
Same here: |
Contributor
Author
|
Thank you for your efforts and keep up the great work :) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This allows the reception of messages sent over the interface. Before, setting the parameter receive_own_messages did not have any effect for the PCAN interface.
Tested with PEAK PCAN-USB FD dongle, Firmware version 3.2.0