Skip to content

Commit b2d9f30

Browse files
committed
Implement CanProtocol for IXXATBus
1 parent d6fabc6 commit b2d9f30

File tree

3 files changed

+24
-16
lines changed

3 files changed

+24
-16
lines changed

can/interfaces/ixxat/canlib.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,8 @@ def __init__(
132132
**kwargs
133133
)
134134

135+
super().__init__(channel=channel, protocol=self.bus.protocol)
136+
135137
def flush_tx_buffer(self):
136138
"""Flushes the transmit buffer on the IXXAT"""
137139
return self.bus.flush_tx_buffer()

can/interfaces/ixxat/canlib_vcinpl.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,18 @@
1515
import sys
1616
from typing import Optional, Callable, Tuple
1717

18-
from can import BusABC, Message
19-
from can.bus import BusState
20-
from can.exceptions import CanInterfaceNotImplementedError, CanInitializationError
21-
from can.broadcastmanager import (
18+
from can import (
19+
BusABC,
20+
Message,
21+
BusState,
22+
CanProtocol,
23+
CanInterfaceNotImplementedError,
24+
CanInitializationError,
2225
LimitedDurationCyclicSendTaskABC,
2326
RestartableCyclicTaskABC,
2427
)
2528
from can.ctypesutil import CLibrary, HANDLE, PHANDLE, HRESULT as ctypes_HRESULT
2629
from can.util import deprecated_args_alias
27-
2830
from . import constants, structures
2931
from .exceptions import *
3032

@@ -631,7 +633,9 @@ def __init__(
631633
except (VCITimeout, VCIRxQueueEmptyError):
632634
break
633635

634-
super().__init__(channel=channel, can_filters=None, **kwargs)
636+
super().__init__(
637+
channel=channel, can_filters=None, protocol=CanProtocol.CAN_20, **kwargs
638+
)
635639

636640
def _inWaiting(self):
637641
try:

can/interfaces/ixxat/canlib_vcinpl2.py

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,17 @@
1515
import sys
1616
from typing import Optional, Callable, Tuple
1717

18-
from can import BusABC, Message
19-
from can.exceptions import CanInterfaceNotImplementedError, CanInitializationError
20-
from can.broadcastmanager import (
18+
from can import (
19+
BusABC,
20+
Message,
21+
CanProtocol,
22+
CanInterfaceNotImplementedError,
23+
CanInitializationError,
2124
LimitedDurationCyclicSendTaskABC,
2225
RestartableCyclicTaskABC,
2326
)
2427
from can.ctypesutil import CLibrary, HANDLE, PHANDLE, HRESULT as ctypes_HRESULT
25-
26-
import can.util
27-
from can.util import deprecated_args_alias
28-
28+
from can.util import deprecated_args_alias, dlc2len, len2dlc
2929
from . import constants, structures
3030
from .exceptions import *
3131

@@ -742,7 +742,9 @@ def __init__(
742742
except (VCITimeout, VCIRxQueueEmptyError):
743743
break
744744

745-
super().__init__(channel=channel, can_filters=None, **kwargs)
745+
super().__init__(
746+
channel=channel, can_filters=None, protocol=CanProtocol.CAN_FD, **kwargs
747+
)
746748

747749
@staticmethod
748750
def _canptb_build(defaults, bitrate, tseg1, tseg2, sjw, ssp):
@@ -865,7 +867,7 @@ def _recv_internal(self, timeout):
865867
# Timed out / can message type is not DATA
866868
return None, True
867869

868-
data_len = can.util.dlc2len(self._message.uMsgInfo.Bits.dlc)
870+
data_len = dlc2len(self._message.uMsgInfo.Bits.dlc)
869871
# The _message.dwTime is a 32bit tick value and will overrun,
870872
# so expect to see the value restarting from 0
871873
rx_msg = Message(
@@ -915,7 +917,7 @@ def send(self, msg: Message, timeout: Optional[float] = None) -> None:
915917
message.uMsgInfo.Bits.edl = 1 if msg.is_fd else 0
916918
message.dwMsgId = msg.arbitration_id
917919
if msg.dlc: # this dlc means number of bytes of payload
918-
message.uMsgInfo.Bits.dlc = can.util.len2dlc(msg.dlc)
920+
message.uMsgInfo.Bits.dlc = len2dlc(msg.dlc)
919921
data_len_dif = msg.dlc - len(msg.data)
920922
data = msg.data + bytearray(
921923
[0] * data_len_dif

0 commit comments

Comments
 (0)