Skip to content

Support CANdapter extended length arbitration ID #1528

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion can/interfaces/slcan.py

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@BroderickJack example comment
elif string[0] == "T" or string[0] == "x": # x is an alternative extended message identifier from the CANDapter

Copy link

@NoahMaceri NoahMaceri Apr 2, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also in test_slcan.py you can insert this test after line 40 for a test

# Ewert Energy Systems CANDapter specific
self.serial.write(b"x12ABCDEF2AA55\r")
msg = self.bus.recv(TIMEOUT)
self.assertIsNotNone(msg)
self.assertEqual(msg.arbitration_id, 0x12ABCDEF)
self.assertEqual(msg.is_extended_id, True)
self.assertEqual(msg.is_remote_frame, False)
self.assertEqual(msg.dlc, 2)
self.assertSequenceEqual(msg.data, [0xAA, 0x55])

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it, thank you!

Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,10 @@ def _recv_internal(

if not string:
pass
elif string[0] == "T":
elif string[0] in (
"T",
"x", # x is an alternative extended message identifier for CANDapter
):
# extended frame
canId = int(string[1:9], 16)
dlc = int(string[9])
Expand Down
10 changes: 10 additions & 0 deletions test/test_slcan.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,16 @@ def test_recv_extended(self):
self.assertEqual(msg.dlc, 2)
self.assertSequenceEqual(msg.data, [0xAA, 0x55])

# Ewert Energy Systems CANDapter specific
self.serial.write(b"x12ABCDEF2AA55\r")
msg = self.bus.recv(TIMEOUT)
self.assertIsNotNone(msg)
self.assertEqual(msg.arbitration_id, 0x12ABCDEF)
self.assertEqual(msg.is_extended_id, True)
self.assertEqual(msg.is_remote_frame, False)
self.assertEqual(msg.dlc, 2)
self.assertSequenceEqual(msg.data, [0xAA, 0x55])

def test_send_extended(self):
msg = can.Message(
arbitration_id=0x12ABCDEF, is_extended_id=True, data=[0xAA, 0x55]
Expand Down