From f41d04599b665130236c995fde1761b5b9265e26 Mon Sep 17 00:00:00 2001 From: BroderickJack <39026705+BroderickJack@users.noreply.github.com> Date: Mon, 27 Feb 2023 13:59:31 -0500 Subject: [PATCH 1/6] Support CANdapter extended length arbitration ID --- can/interfaces/slcan.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/can/interfaces/slcan.py b/can/interfaces/slcan.py index 7ff12ce44..e685e318a 100644 --- a/can/interfaces/slcan.py +++ b/can/interfaces/slcan.py @@ -205,7 +205,7 @@ def _recv_internal( if not string: pass - elif string[0] == "T": + elif string[0] == "T" or string[0] == "x": # extended frame canId = int(string[1:9], 16) dlc = int(string[9]) From 25df6bb4ac882d392f25318c5ee5e3cfd77ed82b Mon Sep 17 00:00:00 2001 From: BroderickJack <39026705+BroderickJack@users.noreply.github.com> Date: Sun, 2 Apr 2023 18:14:07 -0400 Subject: [PATCH 2/6] Update can/interfaces/slcan.py More efficient check of arbitration ID Co-authored-by: zariiii9003 <52598363+zariiii9003@users.noreply.github.com> --- can/interfaces/slcan.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/can/interfaces/slcan.py b/can/interfaces/slcan.py index e685e318a..e4e0c3cf2 100644 --- a/can/interfaces/slcan.py +++ b/can/interfaces/slcan.py @@ -205,7 +205,7 @@ def _recv_internal( if not string: pass - elif string[0] == "T" or string[0] == "x": + elif string[0] in ("T", "x"): # extended frame canId = int(string[1:9], 16) dlc = int(string[9]) From 4dd153cd15833e01a341462f90fae137100e9c09 Mon Sep 17 00:00:00 2001 From: BroderickJack Date: Sun, 2 Apr 2023 18:15:15 -0400 Subject: [PATCH 3/6] Add description of x extended arbitration identifier --- can/interfaces/slcan.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/can/interfaces/slcan.py b/can/interfaces/slcan.py index e4e0c3cf2..a8252b931 100644 --- a/can/interfaces/slcan.py +++ b/can/interfaces/slcan.py @@ -205,7 +205,7 @@ def _recv_internal( if not string: pass - elif string[0] in ("T", "x"): + 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]) From 109ecc3ffffdd99bb3f472b00281753c2f0fbc8e Mon Sep 17 00:00:00 2001 From: BroderickJack Date: Sun, 2 Apr 2023 18:21:07 -0400 Subject: [PATCH 4/6] Add test for CANDapter extended arbitration ID --- test/test_slcan.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/test/test_slcan.py b/test/test_slcan.py index f74207b9f..f027af425 100644 --- a/test/test_slcan.py +++ b/test/test_slcan.py @@ -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 + elf.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] From 5796315359cf09148c8b90b347a06cbc18c290d9 Mon Sep 17 00:00:00 2001 From: BroderickJack <39026705+BroderickJack@users.noreply.github.com> Date: Mon, 3 Apr 2023 19:04:44 -0400 Subject: [PATCH 5/6] Update test/test_slcan.py Type fix in slcan test Co-authored-by: zariiii9003 <52598363+zariiii9003@users.noreply.github.com> --- test/test_slcan.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test_slcan.py b/test/test_slcan.py index f027af425..af7ae60c4 100644 --- a/test/test_slcan.py +++ b/test/test_slcan.py @@ -44,7 +44,7 @@ def test_recv_extended(self): self.assertSequenceEqual(msg.data, [0xAA, 0x55]) # Ewert Energy Systems CANDapter specific - elf.serial.write(b"x12ABCDEF2AA55\r") + self.serial.write(b"x12ABCDEF2AA55\r") msg = self.bus.recv(TIMEOUT) self.assertIsNotNone(msg) self.assertEqual(msg.arbitration_id, 0x12ABCDEF) From 90ab7fced59323190541d30eae1103e51c652937 Mon Sep 17 00:00:00 2001 From: zariiii9003 <52598363+zariiii9003@users.noreply.github.com> Date: Tue, 17 Oct 2023 15:32:57 +0200 Subject: [PATCH 6/6] format black --- can/interfaces/slcan.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/can/interfaces/slcan.py b/can/interfaces/slcan.py index a8252b931..153cbd13e 100644 --- a/can/interfaces/slcan.py +++ b/can/interfaces/slcan.py @@ -205,7 +205,10 @@ def _recv_internal( if not string: pass - elif string[0] in ("T", "x"): # x is an alternative extended message identifier for CANDapter + 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])