diff --git a/can/interfaces/pcan/pcan.py b/can/interfaces/pcan/pcan.py index a2f5f361f..c2f4b8ab1 100644 --- a/can/interfaces/pcan/pcan.py +++ b/can/interfaces/pcan/pcan.py @@ -273,6 +273,19 @@ def __init__( else: raise ValueError("BusState must be Active or Passive") + + # Check if the user provided parameters to build a BitTiming object + timing_keys = {"f_clock", "brp", "tseg1", "tseg2", "sjw"} + if timing is None and not is_fd and timing_keys.issubset(kwargs.keys()): + timing = BitTiming( + f_clock=kwargs.get("f_clock"), + brp=kwargs.get("brp"), + tseg1=kwargs.get("tseg1"), + tseg2=kwargs.get("tseg2"), + sjw=kwargs.get("sjw"), + ) + + if isinstance(timing, BitTiming): timing = check_or_adjust_timing_clock(timing, VALID_PCAN_CAN_CLOCKS) pcan_bitrate = TPCANBaudrate(timing.btr0 << 8 | timing.btr1) diff --git a/doc/changelog.d/2069.support_timing_can_ini_pcan.rst b/doc/changelog.d/2069.support_timing_can_ini_pcan.rst new file mode 100644 index 000000000..eae71926d --- /dev/null +++ b/doc/changelog.d/2069.support_timing_can_ini_pcan.rst @@ -0,0 +1 @@ +Add support for bit CAN timing parameters in can.ini for pcan interface.