diff --git a/can/bus.py b/can/bus.py index c3a906757..b10bb01b9 100644 --- a/can/bus.py +++ b/can/bus.py @@ -44,7 +44,8 @@ class CanProtocol(Enum): """The CAN protocol type supported by a :class:`can.BusABC` instance""" CAN_20 = auto() - CAN_FD = auto() + CAN_FD = auto() # ISO Mode + CAN_FD_NON_ISO = auto() CAN_XL = auto() diff --git a/can/interfaces/kvaser/canlib.py b/can/interfaces/kvaser/canlib.py index 4c621ecf4..85bcac28f 100644 --- a/can/interfaces/kvaser/canlib.py +++ b/can/interfaces/kvaser/canlib.py @@ -429,6 +429,10 @@ def __init__( computer, set this to True or set single_handle to True. :param bool fd: If CAN-FD frames should be supported. + :param bool fd_non_iso: + Open the channel in Non-ISO (Bosch) FD mode. Only applies for FD buses. + This changes the handling of the stuff-bit counter and the CRC. Defaults + to False (ISO mode) :param bool exclusive: Don't allow sharing of this CANlib channel. :param bool override_exclusive: @@ -454,6 +458,7 @@ def __init__( accept_virtual = kwargs.get("accept_virtual", True) fd = isinstance(timing, BitTimingFd) if timing else kwargs.get("fd", False) data_bitrate = kwargs.get("data_bitrate", None) + fd_non_iso = kwargs.get("fd_non_iso", False) try: channel = int(channel) @@ -462,7 +467,11 @@ def __init__( self.channel = channel self.single_handle = single_handle - self._can_protocol = CanProtocol.CAN_FD if fd else CanProtocol.CAN_20 + self._can_protocol = CanProtocol.CAN_20 + if fd_non_iso: + self._can_protocol = CanProtocol.CAN_FD_NON_ISO + elif fd: + self._can_protocol = CanProtocol.CAN_FD log.debug("Initialising bus instance") num_channels = ctypes.c_int(0) @@ -483,7 +492,10 @@ def __init__( if accept_virtual: flags |= canstat.canOPEN_ACCEPT_VIRTUAL if fd: - flags |= canstat.canOPEN_CAN_FD + if fd_non_iso: + flags |= canstat.canOPEN_CAN_FD_NONISO + else: + flags |= canstat.canOPEN_CAN_FD log.debug("Creating read handle to bus channel: %s", channel) self._read_handle = canOpenChannel(channel, flags) diff --git a/doc/interfaces/pcan.rst b/doc/interfaces/pcan.rst index 790264627..88ab6838d 100644 --- a/doc/interfaces/pcan.rst +++ b/doc/interfaces/pcan.rst @@ -37,7 +37,14 @@ Here is an example configuration file for using `PCAN-USB