From 74b48c74cd5dd24a2cdf7b20f7cb9b447d3e470e Mon Sep 17 00:00:00 2001 From: zariiii9003 <52598363+zariiii9003@users.noreply.github.com> Date: Sat, 28 Jan 2023 12:14:45 +0100 Subject: [PATCH] remove btr argument, rename ttyBaudrate --- can/interfaces/slcan.py | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/can/interfaces/slcan.py b/can/interfaces/slcan.py index 3254816de..f8aade47f 100644 --- a/can/interfaces/slcan.py +++ b/can/interfaces/slcan.py @@ -15,7 +15,7 @@ CanOperationError, error_check, ) -from can.util import check_or_adjust_timing_clock +from can.util import check_or_adjust_timing_clock, deprecated_args_alias logger = logging.getLogger(__name__) @@ -55,13 +55,17 @@ class slcanBus(BusABC): LINE_TERMINATOR = b"\r" + @deprecated_args_alias( + deprecation_start="4.2.0", + deprecation_end="5.0.0", + ttyBaudrate="tty_baudrate", + ) def __init__( self, channel: typechecking.ChannelStr, - ttyBaudrate: int = 115200, + tty_baudrate: int = 115200, bitrate: Optional[int] = None, timing: Optional[Union[BitTiming, BitTimingFd]] = None, - btr: Optional[str] = None, sleep_after_open: float = _SLEEP_AFTER_SERIAL_OPEN, rtscts: bool = False, timeout: float = 0.001, @@ -81,8 +85,6 @@ def __init__( `f_clock` value of the timing instance must be set to 8_000_000 (8MHz) for standard CAN. CAN FD and the :class:`~can.BitTimingFd` class are not supported. - :param btr: - BTR register value to set custom can speed :param poll_interval: Poll interval in seconds when reading messages :param sleep_after_open: @@ -98,6 +100,7 @@ def __init__( if serial is None: raise CanInterfaceNotImplementedError("The serial module is not installed") + btr: Optional[str] = kwargs.get("btr", None) if btr is not None: warnings.warn( "The 'btr' argument is deprecated since python-can v4.2.0 " @@ -110,12 +113,12 @@ def __init__( raise ValueError("Must specify a serial port.") if "@" in channel: (channel, baudrate) = channel.split("@") - ttyBaudrate = int(baudrate) + tty_baudrate = int(baudrate) with error_check(exception_type=CanInitializationError): self.serialPortOrig = serial.serial_for_url( channel, - baudrate=ttyBaudrate, + baudrate=tty_baudrate, rtscts=rtscts, timeout=timeout, ) @@ -163,7 +166,8 @@ def set_bitrate(self, bitrate: int) -> None: def set_bitrate_reg(self, btr: str) -> None: """ :param btr: - BTR register value to set custom can speed + BTR register value to set custom can speed as a string `xxyy` where + xx is the BTR0 value in hex and yy is the BTR1 value in hex. """ self.close() self._write("s" + btr)