Confiurations¶
Configuration¶
-
class
canlib.kvamemolibxml.
Configuration
(xml=None, lif=None)[source]¶ Configuration data for Kvaser devices
It is usually preferred to create objects of this class with one of the functions:
The XML and param.lif representation of this configuration can be accessed with the
xml
andlif
attributes, respectively.Two
Configuration
objects can be tested for equality:config1 == config2
This will test whether the objects are equivalent: whether they have the same param.lif representation.
Finally, the configuration can be validated with
Configuration.validate
:errors, warnings = configuration.validate() for error in errors: print(error) for warning in warnings: print(warning) if errors: raise ValueError("Invalid configuration")
-
lif
¶ The param.lif representation of this configuration
Type: bytes
-
validate
()[source]¶ Validate this configuration
Validates the XML representation of this configuration, and returns a tuple
(errors, warnings)
whereerrors
is alist
ofcanlib.kvamemolibxml.ValidationError
andwarnings
is alist
canlib.kvamemolibxml.ValidationWarning
.
-
xml
¶ The XML representation of this configuration
Type: str
-
load_lif()¶
-
canlib.kvamemolibxml.
load_lif
(lif_bytes)[source]¶ Create a
Configuration
from a param.lifbytes
Parameters: lif_bytes ( bytes
) – Binary configuration in param.lif format
load_lif_file()¶
load_xml()¶
-
canlib.kvamemolibxml.
load_xml
(xml_string)[source]¶ Create a
Configuration
from an xmlstring
Parameters: xml_string ( str
) – XML configuration