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 toDevice.MHYDRA_EXT)
- Returns
New in version 1.6.
Memorator¶
- class canlib.kvmlib.Memorator(handle, channel_number, device_type)[source]¶
A Memorator device opened with
openDeviceThis class should not be instantiated directly, instead call
openDevice.A device opened as
Memoratorcan be configured from XML usingkvamemolibxml.load_xml_fileandwrite_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
logattribute. 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.logbefore a mount).The log area can be mounted either with
openDevice’smountargument set toTrue, or later with theMemorator.mountfunction. Once this is done thelogattribute is aMountedLogwhich supports getting log files asLogFileobjects:# 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
MountedLogfor 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
- 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_spaceset to0, and then useMemorator.disk_usage.total.- Type
int
- property driver_version¶
The used driver version information
- Type
- property firmware_version¶
The device firmware version information
- Type
- 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
- Type
- mount()[source]¶
Mount the Memorator’s log area
This replaces the object
logattribute 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
bytesobject with the binary configuration data (param.lif).If a
kvamemolibxml.Configurationis desired, the returnedbytescan be parsed usingkvamemolibxml.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
bytesobject with the binary configuration data (param.lif).Given a
kvamemolibxml.Configurationobject, pass itslifattribute to this function:memorator.write_config(config_object.lif)