11
11
import logging
12
12
import os
13
13
import time
14
+ import warnings
14
15
from queue import SimpleQueue
15
16
from types import ModuleType
16
17
from typing import Optional , List , Union , Tuple , Any
17
18
18
19
import can .typechecking
19
- from can import BusABC , Message , BitTiming , BitTimingFd
20
+ from can import BusABC , Message , BitTiming , BitTimingFd , CanProtocol
20
21
from can .exceptions import (
21
22
CanInitializationError ,
22
23
CanOperationError ,
@@ -103,10 +104,10 @@ def __init__(
103
104
104
105
self .poll_interval = poll_interval
105
106
106
- self . fd = isinstance (timing , BitTimingFd ) if timing else fd
107
+ is_fd = isinstance (timing , BitTimingFd ) if timing else fd
107
108
108
109
# Set database for the initialization
109
- database_name = ":can_fd_brs:" if self . fd else ":memory:"
110
+ database_name = ":can_fd_brs:" if is_fd else ":memory:"
110
111
111
112
try :
112
113
# We need two sessions for this application,
@@ -158,7 +159,7 @@ def __init__(
158
159
if bitrate :
159
160
self ._interface .baud_rate = bitrate
160
161
161
- if self . fd :
162
+ if is_fd :
162
163
# See page 951 of NI-XNET Hardware and Software Manual
163
164
# to set custom can configuration
164
165
self ._interface .can_fd_baud_rate = fd_bitrate or bitrate
@@ -185,9 +186,19 @@ def __init__(
185
186
channel = channel ,
186
187
can_filters = can_filters ,
187
188
bitrate = bitrate ,
189
+ protocol = CanProtocol .CAN_FD if is_fd else CanProtocol .CAN_20 ,
188
190
** kwargs ,
189
191
)
190
192
193
+ @property
194
+ def fd (self ) -> bool :
195
+ warnings .warn (
196
+ "The NiXNETcanBus.fd property is deprecated and superseded by "
197
+ "BusABC.protocol. It is scheduled for removal in version 5.0." ,
198
+ DeprecationWarning ,
199
+ )
200
+ return self .protocol == CanProtocol .CAN_FD
201
+
191
202
def _recv_internal (
192
203
self , timeout : Optional [float ]
193
204
) -> Tuple [Optional [Message ], bool ]:
0 commit comments