Skip to content

[canalyst] get CANalyst-II working through init, once more #617

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jun 12, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CONTRIBUTORS.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,4 @@ Alexander Mueller<XelaRellum@web.de>
Jan Goeteyn
"ykzheng" <wishdo@gmail.com>
Lear Corporation
Nick Black <dank@qemfd.net>
21 changes: 14 additions & 7 deletions can/interfaces/canalystii.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,18 +73,25 @@ class VCI_CAN_OBJ(Structure):

class CANalystIIBus(BusABC):
def __init__(
self, channel, device=0, baud=None, Timing0=None, Timing1=None, can_filters=None
self,
channel,
device=0,
bitrate=None,
Timing0=None,
Timing1=None,
can_filters=None,
**kwargs,
):
"""

:param channel: channel number
:param device: device number
:param baud: baud rate
:param Timing0: customize the timing register if baudrate is not specified
:param bitrate: CAN network bandwidth (bits/s)
:param Timing0: customize the timing register if bitrate is not specified
:param Timing1:
:param can_filters: filters for packet
"""
super().__init__(channel, can_filters)
super().__init__(channel=channel, can_filters=can_filters, **kwargs)

if isinstance(channel, (list, tuple)):
self.channels = channel
Expand All @@ -100,11 +107,11 @@ def __init__(
self.device, self.channels
)

if baud is not None:
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
4 changes: 4 additions & 0 deletions doc/configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -126,3 +126,7 @@ Lookup table of interface names:
+---------------------+-------------------------------------+
| ``"virtual"`` | :doc:`interfaces/virtual` |
+---------------------+-------------------------------------+
| ``"canalystii"`` | :doc:`interfaces/canalystii` |
+---------------------+-------------------------------------+
| ``"systec"`` | :doc:`interfaces/systec` |
+---------------------+-------------------------------------+