Skip to content

Commit

Permalink
Backport accepting bitrate instead of baud in CANalystIIBus
Browse files Browse the repository at this point in the history
Backported from #617
  • Loading branch information
hardbyte committed Feb 17, 2020
1 parent ba4c676 commit 9fb3c23
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions can/interfaces/canalystii.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import warnings
from ctypes import *
import logging
import platform
Expand Down Expand Up @@ -67,13 +68,13 @@ class VCI_CAN_OBJ(Structure):

class CANalystIIBus(BusABC):
def __init__(
self, channel, device=0, baud=None, Timing0=None, Timing1=None, can_filters=None, **kwargs
self, channel, device=0, bitrate=None, baud=None, Timing0=None, Timing1=None, can_filters=None, **kwargs
):
"""
:param channel: channel number
:param device: device number
:param baud: baud rate
:param baud: baud rate. Renamed to bitrate in next release.
:param Timing0: customize the timing register if baudrate is not specified
:param Timing1:
:param can_filters: filters for packet
Expand All @@ -93,10 +94,15 @@ def __init__(
self.channel_info = "CANalyst-II: device {}, channels {}".format(self.device, self.channels)

if baud is not None:
warnings.warn('Argument baud will be deprecated in version 4, use bitrate instead',
PendingDeprecationWarning)
bitrate = baud

if bitrate is not None:
try:
Timing0, Timing1 = TIMING_DICT[baud]
Timing0, Timing1 = TIMING_DICT[bitrate]
except KeyError:
raise ValueError("Baudrate is not supported")
raise ValueError("Bitrate is not supported")

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

0 comments on commit 9fb3c23

Please sign in to comment.