Memorator¶
openDevice()¶
- canlib.kvmlib.openDevice(channel_number, mount=False, device_type=<Device.MHYDRA_EXT: 1>)[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 (
canlib.kvmlib.Device
) – The type of the memorator to be opened (defaults tocanlib.kvmlib.Device.MHYDRA_EXT
)
- Returns
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 usingcanlib.kvamemolibxml
andwrite_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
canlib.kvmlib.UnmountedLog
(the type of.log
before a mount).The log area can be mounted either with
openDevice
’smount
argument set toTrue
, or later with theMemorator.mount
function. Once this is done thelog
attribute is acanlib.kvmlib.MountedLog
which supports getting log files ascanlib.kvmlib.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
canlib.kvmlib.MountedLog
for all available operations.- Variables
Memorator.channel_number (
int
) – The channel number that was used to connect to this memorator.device_type (
canlib.kvmlib.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
- property disk_size¶
The disk size in megabytes
Warning
This is not necessarily the amount of space available for allocation;
memo.format_disk(reserved_space=memo.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 to0
, and then usememo.disk_usage.total
.- Type
int
- property driver_version¶
The used driver version information
- property firmware_version¶
The device firmware version information
- 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 toTrue
)
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
- mount()[source]¶
Mount the Memorator’s log area
This replaces the object
log
attribute with aMountedLog
, 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
canlib.kvamemolibxml.Configuration
is desired, the returnedbytes
can be parsed usingcanlib.kvamemolibxml.load_lif
:config_object = kvamemolibxml.load_lif(memorator.read_config())
- 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
canlib.kvamemolibxml.Configuration
object, pass itslif
attribute to this function:memorator.write_config(config_object.lif)