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)[source]¶ Bases:
canlib.cenum.CFlag
Masking channels
The
ChannelMask
is used inConverter.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)[source]¶ 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
andkvlcDeleteConverter
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)[source]¶ Add a database file.
Converters with the property
canlib.kvlclib.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
canlib.kvlclib.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.
-
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.
-
getProperty
(wr_property)[source]¶ Get current value for a writer property.
Parameters: wr_property ( canlib.kvlclib.Property
) – Writer property to be set
-
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.
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
-
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
[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
-
setInputFile
(filename, file_format)[source]¶ Select input file.
Parameters: - filename (string) – Name of input file
- file_format (
canlib.kvlclib.FileFormat
) – A supported input format
-
setProperty
(wr_property, value)[source]¶ Set a property value.
Parameters: wr_property ( canlib.kvlclib.Property
) – Writer property to be set
-
-
class
canlib.kvlclib.
Error
[source]¶ 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
[source]¶ 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
[source]¶ Bases:
canlib.kvlclib.exceptions.KvlcError
Exception used when EOF is reached on input file.
-
status
= -3¶
-
-
exception
canlib.kvlclib.
KvlcError
[source]¶ 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)[source]¶ 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 newConverter.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()
-
exception
canlib.kvlclib.
KvlcNotImplemented
[source]¶ Bases:
canlib.kvlclib.exceptions.KvlcError
,exceptions.NotImplementedError
Exception used when kvlclib returns -11.
-
status
= -4¶
-
-
canlib.kvlclib.
Kvlclib
¶ alias of
canlib.kvlclib.deprecated.KvlcLib
-
class
canlib.kvlclib.
Property
[source]¶ Bases:
canlib.cenum.CEnum
-
ATTACHMENTS
= 1003¶
-
CALENDAR_TIME_STAMPS
= 7¶
-
CHANNEL_MASK
= 5¶
-
CREATION_DATE
= 27¶
-
CROP_PRETRIGGER
= 22¶
-
DATA_IN_HEX
= 12¶
-
DECIMAL_CHAR
= 10¶
-
ENUM_VALUES
= 23¶
-
FILL_BLANKS
= 15¶
-
FIRST_TRIGGER
= 2¶
-
FULLY_QUALIFIED_NAMES
= 30¶
-
HLP_J1939
= 6¶
-
ID_IN_HEX
= 11¶
-
ISO8601_DECIMALS
= 17¶
-
LIMIT_DATA_BYTES
= 26¶
-
MERGE_LINES
= 18¶
-
NAME_MANGLING
= 14¶
-
NUMBER_OF_DATA_DECIMALS
= 31¶
-
NUMBER_OF_TIME_DECIMALS
= 13¶
-
OFFSET
= 4¶
-
OVERWRITE
= 28¶
-
RESAMPLE_COLUMN
= 19¶
-
SEPARATOR_CHAR
= 9¶
-
SHOW_COUNTER
= 21¶
-
SHOW_SIGNAL_SELECT
= 1002¶
-
SHOW_UNITS
= 16¶
-
SIGNAL_BASED
= 1001¶
-
SIZE_LIMIT
= 24¶
-
START_OF_MEASUREMENT
= 1¶
-
TIMEZONE
= 29¶
-
TIME_LIMIT
= 25¶
-
USE_OFFSET
= 3¶
-
VERSION
= 20¶
-
WRITE_HEADER
= 8¶
-
-
class
canlib.kvlclib.
ReaderFormat
(id_)[source]¶ Bases:
object
Helper class that encapsulates a Reader.
You may list available Readers using:
for format in kvlclib.reader_formats(): print(format)
New in version 1.7.
-
isPropertySupported
(rd_property)[source]¶ Check if specified read property is supported.
Retuns True if the property is supported by input format.
Parameters: rd_property ( canlib.kvlclib.Property
) – Reader property
-
-
class
canlib.kvlclib.
WriterFormat
(id_)[source]¶ Bases:
object
Helper class that encapsulates a Writer.
You may list available Writers using:
for format in kvlclib.writer_formats(): print(format)
-
isPropertySupported
(wr_property)[source]¶ Check if specified write property is supported.
Retuns True if the property is supported by output format.
Parameters: wr_property ( canlib.kvlclib.Property
) – Writer propertyReturns: bool
-
-
canlib.kvlclib.
getVersion
[source]¶ Get the kvlclib version number as a
str
Deprecated since version 1.5: Use
dllversion
instead.
-
canlib.kvlclib.
reader_formats
()[source]¶ Return a generator of all writer formats.
New in version 1.7.
-
canlib.kvlclib.
writer_formats
()[source]¶ Return a generator of all writer formats.
New in version 1.7.
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.
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’sWriterFormat
withConverter.format
and use theWriterFormat.getPropertyDefault
andWriterFormat.isPropertySupported
.