Skip to content

Commit ad11bf9

Browse files
cowo78Giuseppe Corbelli
authored and
Giuseppe Corbelli
committed
Try to dlsym() the required functions only if the canlib has been loaded
1 parent 71580d8 commit ad11bf9

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

can/interfaces/kvaser/canlib.py

+21
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,17 @@ def __check_bus_handle_validity(handle, function, arguments):
319319
errcheck=__check_status_operation,
320320
)
321321

322+
kvFlashLeds = __get_canlib_function("kvFlashLeds",
323+
argtypes=[c_canHandle, ctypes.c_int,
324+
ctypes.c_int],
325+
restype=ctypes.c_short,
326+
errcheck=__check_status)
327+
328+
if sys.platform == "win32":
329+
canGetVersionEx = __get_canlib_function("canGetVersionEx",
330+
argtypes=[ctypes.c_uint],
331+
restype=ctypes.c_uint,
332+
errcheck=__check_status)
322333

323334
def init_kvaser_library():
324335
if __canlib is not None:
@@ -330,6 +341,16 @@ def init_kvaser_library():
330341
log.warning("Kvaser canlib could not be initialized.")
331342

332343

344+
def init_kvaser_library():
345+
if __canlib is not None:
346+
try:
347+
log.debug("Initializing Kvaser CAN library")
348+
canInitializeLibrary()
349+
log.debug("CAN library initialized")
350+
except:
351+
log.warning("Kvaser canlib could not be initialized.")
352+
353+
333354
DRIVER_MODE_SILENT = False
334355
DRIVER_MODE_NORMAL = True
335356

0 commit comments

Comments
 (0)