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__(
439439 :param int data_bitrate:
440440 Which bitrate to use for data phase in CAN FD.
441441 Defaults to arbitration bitrate.
442-
442+ :param bool no_init_access:
443+ Don't open the handle with init access.
443444 """
444445
445446 log .info (f"CAN Filters: { can_filters } " )
@@ -455,6 +456,7 @@ def __init__(
455456 exclusive = kwargs .get ("exclusive" , False )
456457 override_exclusive = kwargs .get ("override_exclusive" , False )
457458 accept_virtual = kwargs .get ("accept_virtual" , True )
459+ no_init_access = kwargs .get ("no_init_access" , False )
458460 fd = isinstance (timing , BitTimingFd ) if timing else kwargs .get ("fd" , False )
459461 data_bitrate = kwargs .get ("data_bitrate" , None )
460462 fd_non_iso = kwargs .get ("fd_non_iso" , False )
@@ -491,6 +493,8 @@ def __init__(
491493 flags |= canstat .canOPEN_OVERRIDE_EXCLUSIVE
492494 if accept_virtual :
493495 flags |= canstat .canOPEN_ACCEPT_VIRTUAL
496+ if no_init_access :
497+ flags |= canstat .canOPEN_NO_INIT_ACCESS
494498 if fd :
495499 if fd_non_iso :
496500 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):
277277 self .assertTrue (canlib .canGetBusStatistics .called )
278278 self .assertIsInstance (stats , canlib .structures .BusStatistics )
279279
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+
280293 @staticmethod
281294 def canGetNumberOfChannels (count ):
282295 count ._obj .value = 2
You can’t perform that action at this time.
0 commit comments