# canlib.kvlclib

Wrapper module for the Kvaser converter library kvlclib.

This module wraps the Kvaser kvlclib dll. For more info, see the kvlclib help files which are availible in the CANlib SDK. https://www.kvaser.com/developer/canlib-sdk/

class `canlib.kvlclib.``ChannelMask`(*args, **kwds)

  Bases: `canlib.cenum.CFlag`

  Masking channels

  The `ChannelMask` is used in `Converter.addDatabaseFile` to indicate which channels to use.

  `FIVE` = <ChannelMask.FIVE: 16>
  `FOUR` = <ChannelMask.FOUR: 8>
  `ONE` = <ChannelMask.ONE: 1>
  `THREE` = <ChannelMask.THREE: 4>
  `TWO` = <ChannelMask.TWO: 2>

class `canlib.kvlclib.``Converter`(filename, file_format)

  Bases: `object`

  A kvlclib converter

  This class wraps all kvlclib functions related to converters, and saves you from keeping track of a handle and passing that to the functions.

  `kvlcCreateConverter` and `kvlcDeleteConverter` are not wrapped as they are called when Converter objects are created and deleted, respectively. However, if it is necessary to force the converter to write its files, `flush` can be used to simulate destroying and recreating the converter object.

  Note

  No more than 128 converters can be open at the same time.

  `addDatabaseFile`(filename, channel_mask)

    Add a database file.

    Converters with the property PROPERTY_SIGNAL_BASED will match events against all entries in the database and write signals to the output file.

  `attachFile`(filename)

    Attach file to be included in the output file.

    E.g. used to add a database or a movie to the output.

    Note that the output format must support the property PROPERTY_ATTACHMENTS.

  `convertEvent`()

    Convert next event.

    Convert one event from input file and write it to output file.

  `eventCount`()

    Get extimated number of events left.

    Get the estimated number of remaining events in the input file. This can be useful for displaying progress during conversion.

  `flush`()

    Recreate the converter so changes are saved to disk

    Converters do not write changes to disk until they are deleted. This method deletes and recreates the underlying C converter, without needing to recreate the Python object.

  `getOutputFilename`()

    Get the filename of the current output file.

  `getProperty`(wr_property)

    Get current value for a writer property.

  `getPropertyDefault`

    Get default value for a writer property.

  `isDataTruncated`()

    Get truncation status.

    Truncation occurs when the selected output converter can’t write all bytes in a data frame to file. This can happen if CAN FD data is extracted to a format that only supports up to 8 data bytes, e.g. FILE_FORMAT_KME40.

    Truncation can also happen if PROPERTY_LIMIT_DATA_BYTES is set to limit the number of data bytes in output.

    Returns True if data has been truncated

  `isOutputFilenameNew`()

    Check if the converter has created a new file.

    This is only true once after a a new file has been created. Used when splitting output into multiple files.

  `isOverrunActive`()

    Get overrun status.

    Overruns can occur during logging with a Memorator if the bus load exceeds the logging capacity. This is very unusual, but can occur if a Memorator runs complex scripts and triggers.

  `isPropertySupported`

    Check if specified wr_property is supported by the current format.

    Retuns True if the property is supported by the current format.

    Parameters: | wr_property (int) – Any one of the defined PROPERTY_xxx

  `nextInputFile`(filename)

    Select next input file.

  `resetOverrunActive`()

    Reset overrun status.

  `resetStatusTruncated`()

    Reset data trunctation status.

  `setInputFile`(filename, file_format)

    Select input file.

    Parameters: | filename (string) – Name of input file file_format (int) – Any of the supported input FILE_FORMAT_xxx

  `setProperty`(wr_property, value)

    Set a property value.

    Parameters: | wr_property (int) – Any one of the defined PROPERTY_xxx

class `canlib.kvlclib.``Error`

  Bases: `canlib.cenum.CEnum`

  `BUFFER_SIZE` = -15
  `CONVERTING` = -14
  `EOF` = -3
  `FAIL` = -1
  `FILE_ERROR` = -5
  `FILE_EXISTS` = -6
  `FILE_TOO_LARGE` = -10
  `INTERNAL_ERROR` = -7
  `INVALID_LOG_EVENT` = -30
  `MIXED_ENDIANESS` = -33
  `NOT_IMPLEMENTED` = -4
  `NO_FREE_HANDLES` = -12
  `NO_INPUT_SELECTED` = -13
  `NO_TIME_REFERENCE` = -31
  `NULL_POINTER` = -8
  `PARAM` = -2
  `TIME_DECREASING` = -32
  `TYPE_MISMATCH` = -11

class `canlib.kvlclib.``FileFormat`

  Bases: `canlib.cenum.CEnum`

  FILE_FORMAT_xxx

  Format used for input and output, used in kvlcSetInputFile(), kvlcFeedSelectFormat().

  Note

  Not all formats are valid as both output and input format.

  `CSV` = 4
  `CSV_SIGNAL` = 100
  `DEBUG` = 1000
  `FAMOS` = 105
  `FAMOS_XCP` = 201
  `INVALID` = 0
  `J1587` = 103
  `J1587_ALT` = 104
  `KME24` = 1
  `KME25` = 2
  `KME40` = 7
  `KME50` = 9
  `MATLAB` = 102
  `MDF` = 101
  `MDF_4X` = 107
  `MDF_4X_SIGNAL` = 108
  `MDF_SIGNAL` = 106
  `MEMO_LOG` = 6
  `PLAIN_ASC` = 5
  `VECTOR_ASC` = 3
  `VECTOR_BLF` = 8
  `XCP` = 200

exception `canlib.kvlclib.``KvlcEndOfFile`

  Bases: `canlib.kvlclib.exceptions.KvlcError`

  Exception used when EOF is reached on input file.

  `status` = -3

exception `canlib.kvlclib.``KvlcError`

  Bases: `canlib.exceptions.DllException`

  Base class for exceptions raised by the Kvlclib class.

  Looks up the error text in the kvlclib dll and presents it together with the error code and the wrapper function that triggered the exception.

class `canlib.kvlclib.``KvlcLib`(filename, file_format)

  Bases: `canlib.kvlclib.converter.Converter`

  Deprecated wrapper class for the Kvaser converter library kvlclib.

  Deprecated since version 1.5.

  Most functionality of this class has been moved to kvlclib.Converter:

      # deprecated
      from canlib import kvlclib
      lc = kvlclib.KvlcLib("filename", WriterFormat(kvlclib.FileFormat.KME24))
      lc.functionName()

      # use this instead
      from canlib import kvlclib
      converter = kvlclib.Converter("filename", WriterFormat(kvlclib.FileFormat.KME24))
      converter.functionName()

  `deleteConverter()` has been deprecated, converters are automatically deleted when garbage collected. Also see the new `Converter.flush()`

  `getVersion()` is now a function in kvlclib:

  > # deprecated from canlib import kvlclib lc = kvlclib.KvlcLib(“filename”, WriterFormat(kvlclib.FileFormat.KME24)) lc.getVersion()

  > # use this instead from canlib import kvlclib kvlclib.getVersion()

  `deleteConverter`()

`canlib.kvlclib.``Kvlclib`

  alias of `canlib.kvlclib.deprecated.KvlcLib`

class `canlib.kvlclib.``WriterFormat`(id_)

  Bases: `object`

  Helper class that encapsulates a Writer.

  You may list available Writers, and query properties.

  classmethod `getFirstWriterFormat`()

    Get the first supported output format.

  classmethod `getNextWriterFormat`(previous_id)

    Get the next supported output format.

  `getPropertyDefault`(wr_property)

    Get default value for property.

  `isPropertySupported`(wr_property)

    Check if specified write property is supported.

    Retuns True if the property is supported by output format.

    Parameters: | wr_property (int) – Any one of the defined PROPERTY_xxx

`canlib.kvlclib.``dllversion`()

  Get the kvlclib version number as a `VersionNumber`

`canlib.kvlclib.``getVersion`

  Get the kvlclib version number as a `str`

  Deprecated since version 1.5: Use `dllversion` instead.

Deprecated names

Note

When one of the following deprecated callables/attributes is used, a message saying `A deprecated function was called! Run python with -Wd flag for more information.` will be shown. When python is run with the `-Wd` flag as suggested, you will get more detailed information including which deprecated name was used and what to replaced it with.

`canlib.kvlclib.Converter.``IsDataTruncated`()
`canlib.kvlclib.Converter.``IsOutputFilenameNew`()
`canlib.kvlclib.Converter.``IsOverrunActive`()

  Deprecated since version 1.5.

  These methods have been renamed to remove the initial capital i, they are now called:

  - `canlib.kvlclib.Converter.isDataTruncated`
  - `canlib.kvlclib.Converter.IsOutputFilenameNew`
  - `canlib.kvlclib.Converter.IsOverrunActive`

`canlib.kvlclib.Converter.``getPropertyDefault`()
`canlib.kvlclib.Converter.``isPropertySupported`()

  Deprecated since version 1.5.

  Accessing property support and defaults directly on the `Converter` object is no longer supported, instead explicitly retrieve the converter’s `WriterFormat` with `Converter.format` and use the `WriterFormat.getPropertyDefault` and `WriterFormat.isPropertySupported`.