Skip to content

Commit 9fb3c23

Browse files
committed
Backport accepting bitrate instead of baud in CANalystIIBus
Backported from #617
1 parent ba4c676 commit 9fb3c23

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

can/interfaces/canalystii.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import warnings
12
from ctypes import *
23
import logging
34
import platform
@@ -67,13 +68,13 @@ class VCI_CAN_OBJ(Structure):
6768

6869
class CANalystIIBus(BusABC):
6970
def __init__(
70-
self, channel, device=0, baud=None, Timing0=None, Timing1=None, can_filters=None, **kwargs
71+
self, channel, device=0, bitrate=None, baud=None, Timing0=None, Timing1=None, can_filters=None, **kwargs
7172
):
7273
"""
7374
7475
:param channel: channel number
7576
:param device: device number
76-
:param baud: baud rate
77+
:param baud: baud rate. Renamed to bitrate in next release.
7778
:param Timing0: customize the timing register if baudrate is not specified
7879
:param Timing1:
7980
:param can_filters: filters for packet
@@ -93,10 +94,15 @@ def __init__(
9394
self.channel_info = "CANalyst-II: device {}, channels {}".format(self.device, self.channels)
9495

9596
if baud is not None:
97+
warnings.warn('Argument baud will be deprecated in version 4, use bitrate instead',
98+
PendingDeprecationWarning)
99+
bitrate = baud
100+
101+
if bitrate is not None:
96102
try:
97-
Timing0, Timing1 = TIMING_DICT[baud]
103+
Timing0, Timing1 = TIMING_DICT[bitrate]
98104
except KeyError:
99-
raise ValueError("Baudrate is not supported")
105+
raise ValueError("Bitrate is not supported")
100106

101107
if Timing0 is None or Timing1 is None:
102108
raise ValueError("Timing registers are not set")

0 commit comments

Comments
 (0)