Miscellaneous

dllversion()

canlib.canlib.dllversion()[source]

Get the CANlib DLL version number

Parameters:

None

Returns a canlib.BetaVersionNumber if the CANlib DLL is marked as beta (preview), otherwise returns canlib.VersionNumber.

Changed in version 1.6.

getErrorText()

canlib.canlib.getErrorText(error_code)[source]

Return error text for supplied error_code

getNumberOfChannels()

canlib.canlib.getNumberOfChannels(driver=False)[source]

Get number of available CAN channels.

Returns the number of available CAN channels in the computer. The virtual channels are included in this number.

In order to manually re-enumerate connected devices when a device has been added or removed, use enumerate_hardware.

Parameters:

None

Returns:

chanCount (int) – Number of available CAN channels

getVersion()

canlib.canlib.getVersion()[source]

Get the CANlib DLL version number as a str

Deprecated since version 1.5: Use dllversion instead.

prodversion()

canlib.canlib.prodversion()[source]

Get the CANlib Product version number

Parameters:

None

Returns a canlib.BetaVersionNumber if the CANlib driver/DLL is marked as beta (preview), otherwise returns canlib.VersionNumber.

New in version 1.6.

initializeLibrary()

canlib.canlib.initializeLibrary()[source]

Initialize CANlib library

Note

This initializes the driver and must be called before any other function in the CANlib DLL is used. This is handled in most cases by the Python wrapper. If you want to trigger a re-enumeration of connected devices, you should call enumerate_hardware instead.

Any errors encountered during library initialization will be “silent” and an appropriate error code will be returned later on when an API call that requires initialization is called.

reinitializeLibrary()

canlib.canlib.reinitializeLibrary()[source]

Reinitializes the CANlib driver.

Convenience function that calls unloadLibrary and initializeLibrary in succession.

Warning

Calling reinitializeLibrary invalidates every canlib-object. Use at your own risk. You most likely would like to call enumerate_hardware() instead.

enumerate_hardware()

canlib.canlib.enumerate_hardware()[source]

Enumerate connected Kvaser devices and rebuild list of available channels

Returns:

The number of CAN channels enumerated.

New in version 1.13.

ScriptText

class canlib.canlib.ScriptText(text, slot, time, flags)[source]

Text returned by Channel.scriptGetText

Subclass of built-in str, so it can be used just like a normal string.

It also has the following attributes:

Parameters:
  • text (str) – Text content.

  • slot (int) – Which script-slot the text came from.

  • time (int) – Timestamp of when the text was printed.

  • flags (Stat) – Any status flags associated with the text.

New in version 1.7.

translateBaud()

canlib.canlib.translateBaud(freq)[source]

Translate bitrate constant

This function translates the canlib.Bitrate and canlib.BitrateFD enums to their corresponding bus parameter values.

Parameters:

freq – Any of the predefined canlib.Bitrate or canlib.BitrateFD.

Returns:

A BitrateSetting object containing the actual values of frequency, tseg1, tseg2 etc.

unloadLibrary()

canlib.canlib.unloadLibrary()[source]

Unload CANlib

Unload canlib and release all internal handles.

Warning

Calling unloadLibrary invalidates every canlib-object. Use at your own risk.