Memorator

openDevice()

canlib.kvmlib.openDevice(channel_number, mount=False, device_type=Device.MHYDRA_EXT)[source]

Open a Memorator device

Parameters:
  • channel_number (int) – A channel number of the Memorator to be opened.

  • mount (bool) – Whether the memorator log area should be mounted before returned.

  • device_type (Device) – The type of the memorator to be opened (defaults to Device.MHYDRA_EXT)

Returns:

Memorator

New in version 1.6.

Memorator

class canlib.kvmlib.Memorator(handle, channel_number, device_type)[source]

A Memorator device opened with openDevice

This class should not be instantiated directly, instead call openDevice.

A device opened as Memorator can be configured from XML using kvamemolibxml.load_xml_file and write_config:

# Read the original XML file (config.xml)
config = kvamemolibxml.load_xml_file("config.xml")

# Validate the XML
errors, warnings = config.validate()
if errors or warnings:
    print(errors)
    print(warnings)
    raise Exception("One or more errors/warnings in xml configuration")

# Write the configuration in binary
memorator.write_config(config.lif)

The configuration can then be read back (in binary):

dev.read_config()

The log files on the device can be accessed via the log attribute. By default, the log area is not mounted so only a few operations are allowed, such as getting the number of log files:

num_log_files = len(memorator.log)

For a full list of allowed operations, see UnmountedLog (the type of .log before a mount).

The log area can be mounted either with openDevice’s mount argument set to True, or later with the Memorator.mount function. Once this is done the log attribute is a MountedLog which supports getting log files as LogFile objects:

# We can index the Memorator object if we know what file we want
log_file_number_two = memorator.log[2]

# Although usually we want to loop through all log files
for log_file in memorator.log:
    ...

See the documentation of MountedLog for all available operations.

Parameters:
  • channel_number (int) – The channel number that was used to connect to this memorator.

  • device_type (Device) – The device type that was used to connect to this memorator.

  • mounted (bool) – Whether the device’s memory card has been mounted.

New in version 1.6.

property config_version_needed

The version of param.lif that the connected device expects

Type:

canlib.VersionNumber

property disk_size

The disk size in megabytes

Warning

This is not necessarily the amount of space available for allocation; Memorator.format_disk(reserved_space=Memorator.disk_size) is not guaranteed to succeed.

The most reliable way of calculating reserved space is to first format the disk with reserved_space set to 0, and then use Memorator.disk_usage.total.

Type:

int

property driver_version

The used driver version information

Type:

canlib.VersionNumber

property firmware_version

The device firmware version information

Type:

canlib.VersionNumber

flash_leds()[source]

Flash all LEDs on the Memorator

format_disk(reserved_space=10, database_space=2, fat32=True)[source]

Format the SD memory card in the Memorator

Parameters:
  • reserved_space (int) – Space to reserve for user files, in MB.

  • database_space (int) – Space to reserve for database files, in MB.

  • fat32 (bool) – Whether the filesystem should be formatted as fat32 (defaults to True)

Changed in version 1.9: Will now reopen the internal handle if the log is mounted in order to refresh Memorator.log.ldf_version

property kvmlib_version

Returns the version of kvmlib

Type:

canlib.VersionNumber

mount()[source]

Mount the Memorator’s log area

This replaces the object log attribute with a MountedLog, which allows access to log files.

If the log has already been mounted (self.mounted == True), this is a no-op.

mounted = None
read_config()[source]

Read the configuration of the Memorator

The configuration is returned as a bytes object with the binary configuration data (param.lif).

If a kvamemolibxml.Configuration is desired, the returned bytes can be parsed using kvamemolibxml.load_lif:

config_object = kvamemolibxml.load_lif(memorator.read_config())
reopen(device_type=None, mount=False)[source]

Closes and then reopens the internal handle

property rtc

The value of the real-time clock

Type:

datetime.datetime

property serial_number

The serial number of the Memorator

Type:

int

write_config(config_lif)[source]

Writes configuration to the Memorator

The configuration should be given as a bytes object with the binary configuration data (param.lif).

Given a kvamemolibxml.Configuration object, pass its lif attribute to this function:

memorator.write_config(config_object.lif)