# Converter

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

  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.

  `IsDataTruncated`
  `IsOutputFilenameNew`
  `IsOverrunActive`
  `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 `canlib.kvlclib.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.

  `getDlcMismatch`()

    Return a dictionary with id, DLC with number of mismatched messages

    If any DLC mismatch occurred during conversion (which can be seen using `isDlcMismatch`) this function returns a dictonary with the tuple message id and message DLC as key, and the number of times that triggered the mismatch as value.

  `getOutputFilename`()

    Get the filename of the current output file.

  `getProperty`(wr_property)

    Get current value for a writer property.

    Parameters: | wr_property (`canlib.kvlclib.Property`) – Writer property to be set

  `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. `canlib.kvlclib.FileFormat.KME40`.

    Truncation can also happen if `kvlclib.Property.LIMIT_DATA_BYTES` is set to limit the number of data bytes in output.

    Returns True if data has been truncated

  `isDlcMismatch`()

    Get DLC mismatch status.

    DLC mismatch occurs when a CAN id is found in the database but the DLC differs from the DLC in the message.

  `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.

  `resetDlcMismatch`()

    Reset DLC mismatch status.

  `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 (`canlib.kvlclib.FileFormat`) – A supported input format

  `setProperty`(wr_property, value)

    Set a property value.

    Parameters: | wr_property (`canlib.kvlclib.Property`) – Writer property to be set