ekfsm package
- class ekfsm.System(config, abort=False)[source]
Bases:
SysTree
A System represents a CPCI system.
- Once initialised, it will create:
a list of boards that are present in the system which can be accessed either by name or by slot number.
a list of slots that are present in the system which can be accessed under the slots attribute.
Visual representation of the system is shown as trees of HW Modules and attached devices.
- name
The name of the system.
- slots
A dictionary-like object that contains all slots in the system.
- boards
A list of all boards in the system.
- master
The master board of the system.
- master_slot_number
The slot number of the master board.
- config
The system configuration.
Accessing boards
Iterating over the system will iterate over all boards in the system.
- <board_name>
The board object can be accessed by its name.
- <slot_number>
The board object can be accessed by its slot number.
Example
>>> from ekfsm.system import System >>> system = System("path/to/config.yaml") >>> print(system) # Print the system configuration as trees of HwModules >>> system.print() # same as above >>> cpu = system.cpu # Access the CPU board by its name >>> cpu = system[0] # Access the CPU board by its slot index (index as in configuration file) >>> print(system.slots) # Print all slots in the system >>> print(system.boards) # Print all boards in the system >>> for b in system: # Iterate over all boards in the system >>> print(b.name + b.slot.name) # Print the name of the board and the slot it is in
- _create_hwmodule_from_cfg_file(slot, board_name, path)[source]
Try to create a HwModule object from a board config file. It does not probe the hardware.
- Return type:
- Returns:
HwModule object.
- Raises:
FileNotFoundError – If the board config file does not exist.
ConfigError – If the slot type in the config file does not match the slot type.
Exception – If something else went wrong.
- Parameters:
- create_hwmodule(slot_entry, slot_number, master)[source]
Create HwModule object for the slot.
- Parameters:
- Return type:
- Returns:
HwModule and Slot. HwModule is None if it cannot be created.
- ekfsm.ekfsm_logger(name)[source]
Create a logger with the name ‘ekfsm:name’
- Returns:
The logger object.
- Return type:
- Parameters:
name (
str
) – The name of the module, class or object that is using the logger.
Exceptions
- exception ekfsm.exceptions.AcquisitionError[source]
Bases:
EkfSmException
Error while handling data acquisition
- exception ekfsm.exceptions.ConfigError[source]
Bases:
EkfSmException
Error in configuration
- exception ekfsm.exceptions.DataCorruptionError(details=None)[source]
Bases:
EkfSmException
Error while handling data corruption
- Parameters:
details (str | None)
- exception ekfsm.exceptions.EkfSmException[source]
Bases:
Exception
Base class for all exceptions in the EKFSM Library
- exception ekfsm.exceptions.FirmwareNodeError[source]
Bases:
EkfSmException
Error while handlig firmware node
- exception ekfsm.exceptions.GPIOError(error_type, details=None)[source]
Bases:
EkfSmException
Error while handling GPIO
- exception ekfsm.exceptions.SYSFSError[source]
Bases:
EkfSmException
Error while handling sysfs pseudo file system
CLI
ekfsm-cli
ekfsm-cli [OPTIONS] COMMAND [ARGS]...
Options
- -v, --verbose
Enable verbose output
- -d, --debug
Enable debug output
- -s, --sysfs <sysfs>
Use custom sysfs dir for simulation mode
- -c, --config <config>
Required Path to configuration file
show
Show information about the system
ekfsm-cli show [OPTIONS]
write
Write data to the system
ekfsm-cli write [OPTIONS]
Options
- -s, --serial <serial>
Write chassis serial number
- -u, --unit <unit>
Write chassis unit
- -n, --vendor <vendor>
Write chassis vendor
- -r, --revision <revision>
Write chassis revision
- -m, --model <model>
Write chassis model
- -c, --custom <custom>
Write chassis custom information
- -v, --version <version>
Write schema version
Locking
- class ekfsm.lock.Locker(module)[source]
Bases:
object
A class that implements a locking mechanism using file locks.
- Parameters:
module (
str
) – The name of the module or resource to lock. This will be used to create a unique lock file.
Example
- with Locker(“mysharedresourcename”).lock():
# Access the shared resource here pass
ekfsm.devices package
I2C Devices using SysFs
EEPROM
A module containing classes to represent EEPROM devices.
Routine Listings
- class ekfsm.devices.eeprom.EEPROM(name, parent=None, *args, **kwargs)[source]
Bases:
Device
A class used to represent a generic EEPROM device.
- Parameters:
Caution
- The following conditions must be met for this class to work properly:
EEPROM must be I2C accessable
EEPROM must have a sysfs device
Note
This class should be inherited by classes representing specific EEPROM devices and defining custom storage schemes.
- _update_content()[source]
Update the content of the EEPROM device.
- Return type:
Note
This method should be called whenever the content of the EEPROM is updated (after each write op).
Inheriting classes should call this method before updating their own attributes.
- read()[source]
Read the content of the EEPROM.
- Return type:
- Returns:
The content of the EEPROM.
- Raises:
FileNotFoundError – If the EEPROM sysfs file is not found.
RuntimeError – If the sysfs device is not found.
- write(data, offset=0)[source]
Write data to the EEPROM.
- Parameters:
- Raises:
RuntimeError – If the sysfs device is not found.
FileNotFoundError – If the EEPROM sysfs file is not found.
DataCorruptionError – If an error occurs during the write operation.
- Return type:
Note
Operation is checked for data corruption by reading back the written data.
- class ekfsm.devices.eeprom.EKF_CCU_EEPROM(*args, **kwargs)[source]
Bases:
EKF_EEPROM
EKF CCU EEPROM - uses the second part of the EEPROM for chassis inventory and customer area
- property ccrc: int
Gets or sets the CRC value of the EEPROM content.
- Parameters:
value (optional) – The CRC value to write to the EEPROM.
- Returns:
Caution
The setter actually writes the CRC value to the EEPROM.
Warning
The setter method should be used with caution as it can lead to data corruption if the CRC value is not correct!
Note
The setter is usually triggered automatically after a successful write operation and in most cases, there is no need to call it manually.
- crevision()[source]
Get the revision of the chassis.
- Return type:
- Returns:
The revision of the chassis.
- cserial()[source]
Get the chassis serial number.
- Return type:
- Returns:
The serial number of the chassis.
- custom_raw_data()[source]
Get the raw content area data stored in the EEPROM.
- Return type:
- Returns:
The data contained in the raw content block of the EEPROM.
Note
This area is free for custom data storage and is not included during crc calculations and validations.
Important
If custom raw data should be stored on EEPROM and if it should be protected against corruption, it has to be validated manually.
- customer_area()[source]
Get the customer area of the CCU EEPROM.
- Return type:
- Returns:
The customer area of the CCU EEPROM.
- unit()[source]
Get the subsystem unit number.
- Return type:
- Returns:
The unit number of the subsystem.
- property valid: bool
Checks if the EEPROM content is valid by comparing the stored CRC value with the computed CRC value.
- Returns:
True if the EEPROM content is valid, False otherwise.
- Return type:
- version()[source]
Get the version of the EEPROM data scheme.
Note
If undefined, the version is set to 255 and then defaults to 0.
- Return type:
- Returns:
The version of the EEPROM data scheme.
- write(data, offset=0)[source]
Write data to the EEPROM.
- Parameters:
- Raises:
RuntimeError – If the sysfs device is not found.
FileNotFoundError – If the EEPROM sysfs file is not found.
DataCorruptionError – If an error occurs during the write operation.
- Return type:
Note
Operation is checked for data corruption by reading back the written data.
- class ekfsm.devices.eeprom.EKF_EEPROM(*args, **kwargs)[source]
Bases:
Validatable_EEPROM
,ProbeableDevice
A class used to represent an EKF EEPROM device.
Structure
The EKF_EEPROM content is structured as follows:
- Serial number (4 bytes, starts at pos 8):
The serial number of the device.
- Manufactured at (2 bytes, starts at pos 12):
The date the device was manufactured.
- Repaired at (2 bytes, starts at pos 14):
The date the device was repaired.
- Customer serial number (4 bytes, starts at pos 32):
The customer serial number of the device.
- Customer configuration block offset pointer (4 bytes, starts at pos 36):
The offset pointer to the customer configuration block.
- String array (78 bytes, starts at pos 48):
An array of strings containing the model, manufacturer, and custom board data of the device.
- CRC (2 bytes, starts at pos 126):
The CRC value of the EEPROM content.
- Raw content (80 bytes, starts at pos 128):
Free customizable content for other purposes.
Note
As the CRC value is stored at the end of the OEM data space, just before the customer configuration block, the CRC position is manually set and the
_update_content()
method is overridden.The CRC value is computed using the CRC-16/XMODEM algorithm.
Dates are stored in a proprietary format (2 bytes) and must be decoded using the
_decode_date()
method.
See also
Important
All data read from the EEPROM should be validated using the @validated decorator. This decorator ensures that the data is not corrupted by checking the CRC value.
- raises DataCorruptionError:
If the CRC validation fails.
- classmethod _decode_date(encoded_date)[source]
Decode a date from a proprietary 2-byte format.
- Parameters:
- Raises:
ValueError – If the date is invalid (e.g., 30th Feb).
- Returns:
The decoded date.
- Return type:
date
- custom_board_data()[source]
Get the custom board data of the device.
Note
This is a custom field that can be set by the user.
Attention
This field is optional and may not be present in the EEPROM content.
- custom_raw_data()[source]
Get the raw content area data stored in the EEPROM.
- Return type:
- Returns:
The data contained in the raw content block of the EEPROM.
Note
This area is free for custom data storage and is not included during crc calculations and validations.
Important
If custom raw data should be stored on EEPROM and if it should be protected against corruption, it has to be validated manually.
- custom_serial()[source]
Get the customer serial number of the device to which the EEPROM is attached (the root device).
Attention
This is a custom - non-OEM - serial number that can be set by the user.
- Return type:
- Returns:
The customer serial number of the root device.
- manufactured_at()[source]
Get the date the device was manufactured.
- Return type:
- Returns:
The date the device was manufactured.
- model()[source]
Get the model name of the device to which the EEPROM is attached to (the root device).
- probe(*args, **kwargs)[source]
Probe the hardware device to check if it is present and if it is the correct device.
- repaired_at()[source]
Get the date the device was repaired.
- Return type:
- Returns:
The most recent date the device was repaired.
- serial()[source]
Get the serial number of the device to which the EEPROM is attached (the root device).
- Return type:
- Returns:
The serial number of the root device.
- vendor()[source]
Get the vendor/manufacturer of the device to which the EEPROM is attached to (the root device).
- write_custom_board_data(data)[source]
Write custom board data to EEPROM.
Important
Due to size limitations, the custom board data should only contain expressive, short content like serials, variants or specific codes.
Attention
The model and vendor fields are mandatory and must be set before writing custom board data.
- Raises:
ValueError – If the model and vendor fields are not set before writing custom board data.
- Parameters:
data (str)
- Return type:
None
- write_custom_serial(serial)[source]
Write customer serial number of the root device to EEPROM.
- Parameters:
serial (
int
) – The customer serial number to write to the EEPROM.- Raises:
ValueError – If the serial number is not within the bounds of a 32-bit unsigned integer.
- Return type:
Note
Due to space restrictions on storage, the serial number must be a 32-bit unsigned integer.
- write_repaired_at(date)[source]
Write the date the device was repaired to EEPROM.
Note
The date year must be within the range of 1980-2079.
Attention
The date is stored in a proprietary 2-byte format.
- Raises:
ValueError – If the year is not within the range of 1980-2079.
- Parameters:
date (date)
- Return type:
None
- class ekfsm.devices.eeprom.Validatable_EEPROM(crc_pos='end', crc_length=2, *args, **kwargs)[source]
-
Abstract class used to represent an EEPROM device using CRC to validate its content.
- Parameters:
Note
Derived classes must implement a method to compute the CRC value of the EEPROM content.
If the CRC position differs from the shipped schema (‘start’ | ‘end’), the derived class must override the
_update_content()
method.Validity of individual content fields stored/returned by attributes, methods or properties can be achieved by using the
validated()
decorator.
See also
Validatable_EEPROM._compute_crc
Method to compute the CRC value of the EEPROM content.
- abstract _compute_crc()[source]
This method should be implemented by derived classes to compute the CRC value of the EEPROM content.
- Return type:
- Returns:
The computed CRC value.
- _update_content()[source]
Update the content of the EEPROM device (checksum excluded).
- Return type:
- property crc: int
Gets or sets the CRC value of the EEPROM content.
- Parameters:
value (optional) – The CRC value to write to the EEPROM.
- Returns:
Caution
The setter actually writes the CRC value to the EEPROM.
Warning
The setter method should be used with caution as it can lead to data corruption if the CRC value is not correct!
Note
The setter is usually triggered automatically after a successful write operation and in most cases, there is no need to call it manually.
- property valid: bool
Checks if the EEPROM content is valid by comparing the stored CRC value with the computed CRC value.
- Returns:
True if the EEPROM content is valid, False otherwise.
- Return type:
- write(data, offset=0)[source]
Write data to the EEPROM.
- Parameters:
- Raises:
RuntimeError – If the sysfs device is not found.
FileNotFoundError – If the EEPROM sysfs file is not found.
DataCorruptionError – If an error occurs during the write operation.
- Return type:
Note
Operation is checked for data corruption by reading back the written data.
GPIO
- class ekfsm.devices.gpio.EKFIdSimGpio(coding_gnd, coding_vcc, coding_6, coding_7)[source]
Bases:
SimGpio
- class ekfsm.devices.gpio.EKFIdentificationIOExpander(name, parent, *args, **kwargs)[source]
Bases:
GPIOExpander
,ProbeableDevice
- class ekfsm.devices.gpio.GPIO(name, parent=None, *args, **kwargs)[source]
Bases:
Device
- class ekfsm.devices.gpio.SimGpio[source]
Bases:
ABC
EKF SUR LED
- class ekfsm.devices.ekf_sur_led.EKFSurLed(name, parent, *args, **kwargs)[source]
Bases:
GPIOExpander
A class to represent the EKF-SUR-LED devices.
PMBUS
- class ekfsm.devices.pmbus.PmBus(name, parent=None, children=None, *args, **kwargs)[source]
Bases:
Device
,ProbeableDevice
This class represents a PMBus device (e.g. a PSU).
- curr1_input()[source]
Get input current of PSU page 1.
- Return type:
- Returns:
Input current in amperes
- curr2_input()[source]
Get input current of PSU page 2.
- Return type:
- Returns:
Input current in amperes
- probe(*args, **kwargs)[source]
Probe the hardware device to check if it is present and if it is the correct device.
- Return type:
- status0_input()[source]
Get the status of PSU page 1.
- Return type:
- Returns:
PSU status as defined in PsuStatus
- status1_input()[source]
Get the status of PSU page 2.
- Return type:
- Returns:
PSU status as defined in PsuStatus
- class ekfsm.devices.pmbus.PsuStatus(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]
Bases:
IntFlag
Represents the status of a PSU according to STATUS_BYTE register.
See also
External Documentation: PMBus Power System Management Protocol Specification - Part II - Revision 1.4, Fig. 60
Example
>>> from ekfsm.devices.pmbus import PsuStatus >>> status = PsuStatus(0x1F) >>> status <PsuStatus.OUTPUT_OVERCURRENT|INPUT_UNDERVOLTAGE|TEMP_ANORMALY|COMMUNICATION_ERROR|ERROR: 31> >>> PsuStatus.OUTPUT_OVERCURRENT in status True >>> # OK is always present >>> PsuStatus.OK in status True >>> # Instead, check if status is OK >>> status = PsuStatus(0x00) >>> status <PsuStatus.OK: 0> >>> PsuStatus.OUTPUT_OVERCURRENT in status False
- COMMUNICATION_ERROR = 2
- ERROR = 1
- INPUT_UNDERVOLTAGE = 8
- OK = 0
- OUTPUT_OVERCURRENT = 16
- OUTPUT_OVERVOLTAGE = 32
- TEMP_ANORMALY = 4
- static _generate_next_value_(name, start, count, last_values)
Generate the next value when not given.
name: the name of the member start: the initial start value or None count: the number of existing members last_values: the last value assigned or None
- classmethod _iter_member_(value)
Extract all members from the value in definition order.
- ekfsm.devices.pmbus.retry(max_attempts=5, delay=0.5)[source]
Retry decorator.
Decorator that retries a function a number of times before giving up.
This is useful for functions that may fail due to transient errors.
Note
This is needed for certain PMBus commands that may fail due to transient errors because page switching timing is not effectively handled by older kernel versions.
Important
This decorator is thread-safe, meaning a read attempt is atomic and cannot be interupted by scheduler.
- Parameters:
max_attempts – The maximum number of attempts before giving up.
delay – The delay in seconds between attempts.
IIO Thermal and Humidity Sensor
I2C MUX
- class ekfsm.devices.mux.I2CMux(name, parent=None, children=None, *args, **kwargs)[source]
Bases:
Device
This class represents an I2C multiplexer device.
I2C Devices using SMBus directly
EKF CCU Microcontroller
- class ekfsm.devices.ekf_ccu_uc.CcuCommands(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]
Bases:
Enum
- CCU_HUMIDITY = 20
- CCU_TEMPERATURE = 19
- FAN_STATUS = 17
- GET_PARAMETERSET_BEGIN = 132
- GET_PARAMETERSET_FOLLOW = 133
- IDENTIFY_FIRMWARE_TITLE = 128
- IDENTIFY_FIRMWARE_VERSION = 129
- IMU_SAMPLES = 16
- LOAD_FIRMWARE_CHUNK = 130
- LOAD_PARAMETERSET = 131
- NOP = 1
- PUSH_TEMPERATURE = 21
- RESTART = 143
- SW_SHUTDOWN = 22
- VIN_VOLTAGE = 18
- WD_TRIGGER = 23
- class ekfsm.devices.ekf_ccu_uc.EKFCcuUc(name, parent, *args, **kwargs)[source]
Bases:
Device
A class to communicate with I2C microcontroller on the EKF CCU.
- fan_status(fan)[source]
Get the status of a fan.
- Parameters:
fan (
int
) – The fan number (0-2).- Return type:
- Returns:
Note
The diagnostic value is a bitfield with the following meaning:
bit 0: 0 = fan status is invalid, 1 = fan status is valid
bit 1: 0 = no error detected, 1 = fan is stuck
- get_parameterset()[source]
Get the CCU parameterset in JSON format.
A typical parameterset looks like this:
{ "version": "factory", "parameters": { "num-fans": "2", "fan-temp2rpm": "25:2800;50:5000;100:6700", "fan-rpm2duty": "2800:55;5000:88;6700:100", "fan-defrpm": "5500", "fan-ppr": "2", "fan-push-tout": "4000", "pon-min-temp": "-25", "pon-max-temp": "70", "shutdn-delay": "120", "wd-tout": "0", "pwrcycle-time": "10" }, "unsupported_parameters": [], "missing_parameters": ["num-fans", "fan-temp2rpm", "fan-rpm2duty", "fan-defrpm", "fan-ppr", "fan-push-tout", "pon-min-temp", "pon-max-temp", "shutdn-delay", "wd-tout", "pwrcycle-time"], "invalid_parameters": [], "reboot_required": false }
version is the version of the parameterset. If no parameterset has been loaded by the user, the version is factory, otherwise it is the version of the loaded parameterset.
parameters contains the current values of all parameters of the parameterset.
unsupported_parameters contains the names of parameters that might have been downloaded, but are not supported by the CCU firmware.
missing_parameters contains the names of parameters that have not been downloaded yet. Those parameters will have their default values.
invalid_parameters contains the names of parameters that have been downloaded, but have invalid values. Those parameters will have their default values.
reboot_required is a flag that indicates if a reboot is required to apply the parameterset.
- Returns:
The parameterset in JSON format.
- Return type:
- humidity()[source]
Get the relative humidity from the CCU thermal/humidity sensor. The humidity is read once per second.
- Returns:
The relative humidity in percent.
- Return type:
- Raises:
AcquisitionError – If the humidity cannot be read, for example, because the sensor is not working.
- imu_sample()[source]
Read the next IMU sample from the CCU’s IMU sample FIFO.
If no sample is available, this method returns None. The second return value indicates if more samples are available in the FIFO.
The CCU periodically samples the accelerometer and gyroscope data from the IMU and places it into a FIFO of 256 entries. Application must periodically read the samples from the FIFO to avoid overflow.
FIFO overflow is indicated in the sample by the lost attribute.
Note that the x, y, and z axes of the accelerometer and gyroscope are aligned to the mounting of the IMU on the CCU board. Please correct the axes if necessary to match the orientation of the IMU in your application.
- load_firmware(firmware, progress_callback=None)[source]
Load firmware into the CCU.
The firmware must be the binary firmware file containing the application partition, typically named fw-ccu-mm-default.bin, where mm is the major version of the CCU hardware.
The download can take several minutes, that is why a progress callback can be provided.
When the download is complete and successful, the CCU will restart. To check if the firmware was loaded successfully, call
identify_firmware()
after the restart.
- load_parameterset(_cfg)[source]
Load a parameterset into the CCU.
The parameterset must be a JSON string containing the parameterset, for example:
{ "version": "1.0.0", "parameters": { "fan-defrpm": "6000" } }
This would load a parameterset with just one parameter, the default fan speed. All other parameters will be set to their default values.
In order to apply the parameterset, the CCU must be restarted.
- push_temperature(fan, temp)[source]
Tell FAN controller the external temperature, usually the CPU temperature.
- Parameters:
- Return type:
Important
If push_temperature is no more called for a certain time (configurable with fan-push-tout parameter), the fan controller will fallback to it’s default fan speed (configurable with the fan-defrpm parameter).
- sw_shutdown()[source]
Tell CCU that the system is going to shutdown. This cause the CCU’s system state controller to enter shutdown state and power off the system after a certain time (parameter shutdn-delay).
- Return type:
- temperature()[source]
Get the temperature from the CCU thermal/humidity sensor. The temperature is read once per second.
- Returns:
The temperature in degrees Celsius.
- Return type:
- Raises:
AcquisitionError – If the temperature cannot be read, for example, because the sensor is not working.
- vin_voltage()[source]
Get the system input voltage from the CCU (the pimary voltage of the PSU). The voltage is read every 100ms.
- Returns:
The system input voltage in volts.
- Return type:
- Raises:
AcquisitionError – If the voltage cannot be read, for example, because the ADC is not working.
- wd_trigger()[source]
Trigger the CCU’s application watchdog. This will reset the watchdog timer.
The CCU watchdog is only enabled when the parameter wd-tout is set to a value greater than 0. Triggering the watchdog when the timeout is 0 will have no effect.
If the watchdog is not reset within the timeout, the CCU will power cycle the system.
- Return type:
Devices using SysFs
CoreTemp
- class ekfsm.devices.coretemp.CoreTemp(name, parent, *args, **kwargs)[source]
Bases:
Device
This class provides an interface to read the CPU core temperature from the HWMON device.
Note: Currently, only the average temperature over all cores is read from the HWMON device.
- ekfsm.devices.coretemp.find_core_temp_dir(hwmon_dir)[source]
Find the directory containing the coretemp hwmon device.
- Return type:
- Args:
hwmon_dir: Path to the hwmon directory
- Returns:
Path to the directory containing the coretemp hwmon device
- Raises:
FileNotFoundError: If no coretemp directory is found
SMBIOS
- class ekfsm.devices.smbios.SMBIOS(name, parent=None, *args, **kwargs)[source]
Bases:
Device
A class to represent the SMBIOS device.
A SMBIOS device is a virtual device that is used to read system configuration values from the DMI table.
Note: Currently, only the board version / revision is read from the DMI table.
Base Classes and Utilities
- class ekfsm.devices.generic.Device(name, parent=None, children=None, abort=False, *args, **kwargs)[source]
Bases:
SysTree
A generic device.
- get_i2c_bus_number()[source]
Get the I2C bus number of the device. Works for devices that do not have a sysfs_device attribute.
- Return type:
- property hw_module: HwModule
Get or set the HwModule instance that this device belongs to.
- Parameters:
hw_module (optional) – The HwModule instance to set.
- Returns:
HwModule
– The HwModule instance that this device belongs to.None
– If used as a setter.
- ekfsm.devices.iio.iio_get_in_value(dev, attrset)[source]
Calculate a value from an IIO in_* attribute set, using the _raw, _scale and _offset attributes (if present). Typical name of attrset are “in_temp” or “in_voltage0”.
Formula according to https://wiki.st.com/stm32mpu/wiki/How_to_use_the_IIO_user_space_interface
- Parameters:
dev (
SysFSDevice
) – sysfs device object pointing to the iio directoryattrset (
str
) – name of the attribute set to read from (e.g. “in_temp”)
- Returns:
calculated value from the attribute set (no unit conversion)
- Return type:
- Raises:
FileNotFoundError – if the neiter _input nor _raw attribute is found
ekfsm.core package
- class ekfsm.core.components.HwModule(instance_name, config, slot, abort=False, *args, **kwargs)[source]
Bases:
SysTree
A HwModule represents an instantiation of a specifc hw board type, for example an instance of an EKF SC9 board.
- class ekfsm.core.components.SysTree(name, abort=False)[source]
Bases:
NodeMixin
Base class for all system components including Hardware Modules and Devices.
- class ekfsm.core.slots.Slot(name, slot_type, desired_hwmodule_type, desired_hwmodule_name, number, hwmodule=None, master=None, attributes=None)[source]
Bases:
object
A slot represents a physical slot in a chassis.
- Parameters:
name (
str
) – The name of the slot, e.g. “SlotA” or “CPCI-SYSTEMSLOT”slot_type (
SlotType
) – The type of the slot, e.g. SlotType.CPCI_S0_SYSdesired_hwmodule_type (
str
) – The desired type of the hardware module that should be in the slot (currently unused)desired_hwmodule_name (
str
) – The name to be used for the hardware module instance in the slot. (currently unused)hwmodule (
HwModule
|None
) – The hardware module that is in the slotnumber (
int
) – The number of the slotattributes (
Munch
|None
) – Additional attributes
- info()[source]
Returns a dictionary with information about the slot. :rtype:
dict
[str
,Any
]name (str): The name of the slot
slot_type (str): The type of the slot
number (int): The number of the slot
desired_hwmodule_type (str): The desired type of the hardware module
actual_hwmodule_type (str): The actual type of the hardware module
desired_hwmodule_name (str): The desired name of the hardware module
is_populated (bool): Is the slot populated?
is_correctly_populated (bool): Is the slot correctly populated?
- class ekfsm.core.slots.SlotType(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]
Bases:
Enum
Define the types of slots that can be found in a chassis.
The following slot types are defined: - CPCI_S0_UTILITY: CompactPCI Serial Utility Connector - CPCI_S0_SYS: CompactPCI Serial System Slot - CPCI_S0_PER: CompactPCI Serial Peripheral Slot - CPCI_S0_PSU: CompactPCI Serial Power Supply Slot
- CPCI_S0_PER = 3
- CPCI_S0_PSU = 4
- CPCI_S0_SYS = 2
- CPCI_S0_UTILITY = 1
- class ekfsm.core.slots.Slots(*args, **kwargs)[source]
Bases:
Munch
A collection of slots.
Slots are stored in a dictionary-like object, where the key is the slot name and the value is the Slot object. Slots can be accessed by name, by number or via an attribute access matching the key.
Example
>>> from ekfsm..core.slots import Slot, Slots, SlotType >>> slotA = Slot("SlotA", SlotType.CPCI_S0_PER, "Bla", "Blubb", 3) >>> slots = Slots((slotA.name, slotA)) >>> print(slots[name]) >>> print(slots.slotA) # attribute access, same as slots[name] >>> print(slots[3]) # number access, same as slots.slotA
- add(slot)[source]
Add a Slot object to the collection, where the name of the slot object is used as the key.
Example
>>> from ekfsm.core.slots import Slot, Slots, SlotType >>> slotA = Slot("SlotA", SlotType.CPCI_S0_PER, "Bla", "Blubb", 3) >>> slots = Slots() >>> slots.add(slotA) # add slotA to the collection >>> print(slots.SlotA) # attribute access, same as slots["SlotA"]
- class ekfsm.core.sysfs.SysFSAttribute(path)[source]
Bases:
object
A SysFSAttribute is a singular sysfs attribute located somewhere in /sys.
- Parameters:
path (Path)
- path
Path to the underlying file for the SysFSAttribute instance.