From 96611a5483abc257d9b79cfc7c87d72950280bcc Mon Sep 17 00:00:00 2001 From: Duncan Bristow Date: Thu, 14 Mar 2024 10:44:42 -0600 Subject: [PATCH 1/2] Add ability to pass explicit dlc value to SYSTEC interface when sending a message (closes #1755) --- can/interfaces/systec/structures.py | 5 +++-- can/interfaces/systec/ucanbus.py | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/can/interfaces/systec/structures.py b/can/interfaces/systec/structures.py index 9acc34c2c..3493cadff 100644 --- a/can/interfaces/systec/structures.py +++ b/can/interfaces/systec/structures.py @@ -52,9 +52,10 @@ class CanMsg(Structure): ), # Receive time stamp in ms (for transmit messages no meaning) ] - def __init__(self, id_=0, frame_format=MsgFrameFormat.MSG_FF_STD, data=None): + def __init__(self, id_=0, frame_format=MsgFrameFormat.MSG_FF_STD, data=None, dlc=None): data = [] if data is None else data - super().__init__(id_, frame_format, len(data), (BYTE * 8)(*data), 0) + dlc = len(data) if dlc is None else dlc + super().__init__(id_, frame_format, dlc, (BYTE * 8)(*data), 0) def __eq__(self, other): if not isinstance(other, CanMsg): diff --git a/can/interfaces/systec/ucanbus.py b/can/interfaces/systec/ucanbus.py index cb0dcc39e..3b13c8a06 100644 --- a/can/interfaces/systec/ucanbus.py +++ b/can/interfaces/systec/ucanbus.py @@ -207,6 +207,7 @@ def send(self, msg, timeout=None): | (MsgFrameFormat.MSG_FF_EXT if msg.is_extended_id else 0) | (MsgFrameFormat.MSG_FF_RTR if msg.is_remote_frame else 0), msg.data, + msg.dlc ) self._ucan.write_can_msg(self.channel, [message]) except UcanException as exception: From 89a1cf6fc10e1d1e372504d6c1effead5c022ad4 Mon Sep 17 00:00:00 2001 From: Duncan Bristow Date: Fri, 15 Mar 2024 07:57:48 -0600 Subject: [PATCH 2/2] run linter --- can/interfaces/systec/structures.py | 4 +++- can/interfaces/systec/ucanbus.py | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/can/interfaces/systec/structures.py b/can/interfaces/systec/structures.py index 3493cadff..c80f21d44 100644 --- a/can/interfaces/systec/structures.py +++ b/can/interfaces/systec/structures.py @@ -52,7 +52,9 @@ class CanMsg(Structure): ), # Receive time stamp in ms (for transmit messages no meaning) ] - def __init__(self, id_=0, frame_format=MsgFrameFormat.MSG_FF_STD, data=None, dlc=None): + def __init__( + self, id_=0, frame_format=MsgFrameFormat.MSG_FF_STD, data=None, dlc=None + ): data = [] if data is None else data dlc = len(data) if dlc is None else dlc super().__init__(id_, frame_format, dlc, (BYTE * 8)(*data), 0) diff --git a/can/interfaces/systec/ucanbus.py b/can/interfaces/systec/ucanbus.py index 3b13c8a06..3dff7fda5 100644 --- a/can/interfaces/systec/ucanbus.py +++ b/can/interfaces/systec/ucanbus.py @@ -207,7 +207,7 @@ def send(self, msg, timeout=None): | (MsgFrameFormat.MSG_FF_EXT if msg.is_extended_id else 0) | (MsgFrameFormat.MSG_FF_RTR if msg.is_remote_frame else 0), msg.data, - msg.dlc + msg.dlc, ) self._ucan.write_can_msg(self.channel, [message]) except UcanException as exception: