|
16 | 16 | from threading import Event
|
17 | 17 | from warnings import warn
|
18 | 18 |
|
19 |
| -from can import Message, BusABC |
| 19 | +from can import Message, BusABC, CanProtocol |
20 | 20 | from ...exceptions import (
|
21 | 21 | CanError,
|
22 | 22 | CanTimeoutError,
|
@@ -169,7 +169,14 @@ def __init__(self, channel, can_filters=None, **kwargs):
|
169 | 169 | if ics is None:
|
170 | 170 | raise ImportError("Please install python-ics")
|
171 | 171 |
|
172 |
| - super().__init__(channel=channel, can_filters=can_filters, **kwargs) |
| 172 | + is_fd = kwargs.get("fd", False) |
| 173 | + |
| 174 | + super().__init__( |
| 175 | + channel=channel, |
| 176 | + can_filters=can_filters, |
| 177 | + protocol=CanProtocol.CAN_FD if is_fd else CanProtocol.CAN_20, |
| 178 | + **kwargs, |
| 179 | + ) |
173 | 180 |
|
174 | 181 | logger.info(f"CAN Filters: {can_filters}")
|
175 | 182 | logger.info(f"Got configuration of: {kwargs}")
|
@@ -198,7 +205,7 @@ def __init__(self, channel, can_filters=None, **kwargs):
|
198 | 205 | for channel in self.channels:
|
199 | 206 | ics.set_bit_rate(self.dev, kwargs.get("bitrate"), channel)
|
200 | 207 |
|
201 |
| - if kwargs.get("fd", False): |
| 208 | + if is_fd: |
202 | 209 | if "data_bitrate" in kwargs:
|
203 | 210 | for channel in self.channels:
|
204 | 211 | ics.set_fd_bit_rate(
|
|
0 commit comments