File tree Expand file tree Collapse file tree 2 files changed +18
-1
lines changed Expand file tree Collapse file tree 2 files changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -439,7 +439,8 @@ def __init__(
439
439
:param int data_bitrate:
440
440
Which bitrate to use for data phase in CAN FD.
441
441
Defaults to arbitration bitrate.
442
-
442
+ :param bool no_init_access:
443
+ Don't open the handle with init access.
443
444
"""
444
445
445
446
log .info (f"CAN Filters: { can_filters } " )
@@ -455,6 +456,7 @@ def __init__(
455
456
exclusive = kwargs .get ("exclusive" , False )
456
457
override_exclusive = kwargs .get ("override_exclusive" , False )
457
458
accept_virtual = kwargs .get ("accept_virtual" , True )
459
+ no_init_access = kwargs .get ("no_init_access" , False )
458
460
fd = isinstance (timing , BitTimingFd ) if timing else kwargs .get ("fd" , False )
459
461
data_bitrate = kwargs .get ("data_bitrate" , None )
460
462
fd_non_iso = kwargs .get ("fd_non_iso" , False )
@@ -491,6 +493,8 @@ def __init__(
491
493
flags |= canstat .canOPEN_OVERRIDE_EXCLUSIVE
492
494
if accept_virtual :
493
495
flags |= canstat .canOPEN_ACCEPT_VIRTUAL
496
+ if no_init_access :
497
+ flags |= canstat .canOPEN_NO_INIT_ACCESS
494
498
if fd :
495
499
if fd_non_iso :
496
500
flags |= canstat .canOPEN_CAN_FD_NONISO
Original file line number Diff line number Diff line change @@ -277,6 +277,19 @@ def test_bus_get_stats(self):
277
277
self .assertTrue (canlib .canGetBusStatistics .called )
278
278
self .assertIsInstance (stats , canlib .structures .BusStatistics )
279
279
280
+ def test_bus_no_init_access (self ):
281
+ canlib .canOpenChannel .reset_mock ()
282
+ bus = can .Bus (interface = "kvaser" , channel = 0 , no_init_access = True )
283
+
284
+ self .assertGreater (canlib .canOpenChannel .call_count , 0 )
285
+ for call in canlib .canOpenChannel .call_args_list :
286
+ self .assertEqual (
287
+ call [0 ][1 ] & constants .canOPEN_NO_INIT_ACCESS ,
288
+ constants .canOPEN_NO_INIT_ACCESS ,
289
+ )
290
+
291
+ bus .shutdown ()
292
+
280
293
@staticmethod
281
294
def canGetNumberOfChannels (count ):
282
295
count ._obj .value = 2
You can’t perform that action at this time.
0 commit comments