Converter

class canlib.kvlclib.Converter(filename, file_format)[source]

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 (string) – 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()[source]
IsOutputFilenameNew()[source]
IsOverrunActive()[source]
addDatabaseFile(filename, channel_mask)[source]

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)[source]

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()[source]

Convert next event.

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

eventCount()[source]

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)[source]

Feed one event to the converter.

Used when reading log files directly from device.

feedNextFile()[source]

Prepare for new file

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

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

New in version 1.18.

flush()[source]

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()[source]

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()[source]

Get the filename of the current output file.

getProperty(wr_property)[source]

Get current value for a writer property.

Parameters

wr_property (Property) – Writer property to be set

getPropertyDefault(wr_property)[source]

Get default value for a writer property.

isDataTruncated()[source]

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()[source]

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()[source]

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()[source]

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)[source]

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)[source]

Select next input file.

resetDlcMismatch()[source]

Reset DLC mismatch status.

resetOverrunActive()[source]

Reset overrun status.

resetStatusTruncated()[source]

Reset data trunctation status.

setInputFile(filename, file_format)[source]

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)[source]

Set a property value.

Parameters

wr_property (Property) – Writer property to be set