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

  Parameters

    - filename (`str`) – Name of output file

    - file_format (`FileFormat` | `WriterFormat`) – A supported output format

  Note

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

  Changed in version 1.18: The `file_format` parameter now accepts `WriterFormat` as well.

  IsDataTruncated()

    Get truncation status.

    Deprecated since version 1.5: Use `isDataTruncated` instead.

  IsOutputFilenameNew()

    Check if the converter has created a new file.

    Deprecated since version 1.5: Use `isOutputFilenameNew` instead.

  IsOverrunActive()

    Get overrun status.

    Deprecated since version 1.5: Use `isOverrunActive` instead.

  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.

    Parameters

      - filename (`str`) – Path to database file (.dbc)

      - channel_mask (`ChannelMask`) – Channels to use database on

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

    Parameters

      filename (`str`) – Path to file to be attached

  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.

  feedLogEvent(event)

    Feed one event to the converter.

    Used when reading log files directly from device.

  feedNextFile()

    Prepare for new file

    Notify the converter that next event in `feedLogEvent()` will come from another file. Used when reading log files directly from device.

    E.g. use this function with `FileFormat.MEMO_LOG` when using KVMLIB to read events from a Kvaser Memorator connected to USB.

    New in version 1.18.

  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 (`Property`) – Writer property to get

  getPropertyDefault(wr_property)

    Get default property.

    Deprecated since version 1.5: Use `WriterFormat.getPropertyDefault` instead.

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

  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(wr_property)

    Check if specified wr_property is supported by the current format.

    Deprecated since version 1.5: Use `WriterFormat.isPropertySupported` instead.

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

    Changed in version 1.16: The `file_format` parameter now accepts `ReaderFormat` as well.

    Changed in version 1.18: If `filename` is `None`, the format for `feedLogEvent` is set.

  setProperty(wr_property, value)

    Set a property value.

    Parameters

      wr_property (`Property`) – Writer property to be set