Skip to content

Commit

Permalink
remove btr argument, rename ttyBaudrate
Browse files Browse the repository at this point in the history
  • Loading branch information
zariiii9003 committed Apr 10, 2023
1 parent 54203a4 commit 74b48c7
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions can/interfaces/slcan.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__)

Expand Down Expand Up @@ -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,
Expand All @@ -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:
Expand All @@ -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 "
Expand All @@ -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,
)
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 74b48c7

Please sign in to comment.