@@ -140,7 +140,7 @@ def __init__(
140
140
141
141
:raise ~can.exceptions.CanInterfaceNotImplementedError:
142
142
If the current operating system is not supported or the driver could not be loaded.
143
- :raise ~ can.exceptions.CanInitializationError:
143
+ :raise can.exceptions.CanInitializationError:
144
144
If the bus could not be set up.
145
145
This may or may not be a :class:`~can.interfaces.vector.VectorInitializationError`.
146
146
"""
@@ -218,17 +218,15 @@ def __init__(
218
218
interface_version ,
219
219
xldefine .XL_BusTypes .XL_BUS_TYPE_CAN ,
220
220
)
221
- self .permission_mask = permission_mask .value
222
221
223
222
LOG .debug (
224
223
"Open Port: PortHandle: %d, PermissionMask: 0x%X" ,
225
224
self .port_handle .value ,
226
225
permission_mask .value ,
227
226
)
228
227
229
- # set CAN settings
230
228
for channel in self .channels :
231
- if self ._has_init_access ( channel ) :
229
+ if permission_mask . value & self .channel_masks [ channel ] :
232
230
if fd :
233
231
self ._set_bitrate_canfd (
234
232
channel = channel ,
@@ -244,51 +242,6 @@ def __init__(
244
242
elif bitrate :
245
243
self ._set_bitrate_can (channel = channel , bitrate = bitrate )
246
244
247
- # Check CAN settings
248
- for channel in self .channels :
249
- if kwargs .get ("_testing" , False ):
250
- # avoid check if xldriver is mocked for testing
251
- break
252
-
253
- bus_params = self ._read_bus_params (channel )
254
- if fd :
255
- _canfd = bus_params .canfd
256
- if not all (
257
- [
258
- bus_params .bus_type is xldefine .XL_BusTypes .XL_BUS_TYPE_CAN ,
259
- _canfd .can_op_mode
260
- & xldefine .XL_CANFD_BusParams_CanOpMode .XL_BUS_PARAMS_CANOPMODE_CANFD ,
261
- _canfd .bitrate == bitrate if bitrate else True ,
262
- _canfd .sjw_abr == sjw_abr if bitrate else True ,
263
- _canfd .tseg1_abr == tseg1_abr if bitrate else True ,
264
- _canfd .tseg2_abr == tseg2_abr if bitrate else True ,
265
- _canfd .data_bitrate == data_bitrate if data_bitrate else True ,
266
- _canfd .sjw_dbr == sjw_dbr if data_bitrate else True ,
267
- _canfd .tseg1_dbr == tseg1_dbr if data_bitrate else True ,
268
- _canfd .tseg2_dbr == tseg2_dbr if data_bitrate else True ,
269
- ]
270
- ):
271
- raise CanInitializationError (
272
- f"The requested CAN FD settings could not be set for channel { channel } . "
273
- f"Another application might have set incompatible settings. "
274
- f"These are the currently active settings: { _canfd ._asdict ()} "
275
- )
276
- else :
277
- _can = bus_params .can
278
- if not all (
279
- [
280
- bus_params .bus_type is xldefine .XL_BusTypes .XL_BUS_TYPE_CAN ,
281
- _can .can_op_mode
282
- & xldefine .XL_CANFD_BusParams_CanOpMode .XL_BUS_PARAMS_CANOPMODE_CAN20 ,
283
- _can .bitrate == bitrate if bitrate else True ,
284
- ]
285
- ):
286
- raise CanInitializationError (
287
- f"The requested CAN settings could not be set for channel { channel } . "
288
- f"Another application might have set incompatible settings. "
289
- f"These are the currently active settings: { _can ._asdict ()} "
290
- )
291
-
292
245
# Enable/disable TX receipts
293
246
tx_receipts = 1 if receive_own_messages else 0
294
247
self .xldriver .xlCanSetChannelMode (self .port_handle , self .mask , tx_receipts , 0 )
@@ -387,21 +340,6 @@ def _find_global_channel_idx(
387
340
error_code = xldefine .XL_Status .XL_ERR_HW_NOT_PRESENT ,
388
341
)
389
342
390
- def _has_init_access (self , channel : int ) -> bool :
391
- return bool (self .permission_mask & self .channel_masks [channel ])
392
-
393
- def _read_bus_params (self , channel : int ) -> "VectorBusParams" :
394
- channel_mask = self .channel_masks [channel ]
395
-
396
- vcc_list = get_channel_configs ()
397
- for vcc in vcc_list :
398
- if vcc .channel_mask == channel_mask :
399
- return vcc .bus_params
400
-
401
- raise CanInitializationError (
402
- f"Channel configuration for channel { channel } not found."
403
- )
404
-
405
343
def _set_bitrate_can (
406
344
self ,
407
345
channel : int ,
0 commit comments