Skip to content

Commit

Permalink
Support CANdapter extended length arbitration ID (#1528)
Browse files Browse the repository at this point in the history
* Support CANdapter extended length arbitration ID

* Update can/interfaces/slcan.py

More efficient check of arbitration ID

Co-authored-by: zariiii9003 <52598363+zariiii9003@users.noreply.github.com>

* Add description of x extended arbitration identifier

* Add test for CANDapter extended arbitration ID

* Update test/test_slcan.py

Type fix in slcan test

Co-authored-by: zariiii9003 <52598363+zariiii9003@users.noreply.github.com>

* format black

---------

Co-authored-by: zariiii9003 <52598363+zariiii9003@users.noreply.github.com>
  • Loading branch information
BroderickJack and zariiii9003 authored Jun 22, 2024
1 parent 70901ea commit 0de8ca8
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
5 changes: 4 additions & 1 deletion can/interfaces/slcan.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,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

0 comments on commit 0de8ca8

Please sign in to comment.