ekfsm 0.13.0a183__py3-none-any.whl → 1.5.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of ekfsm might be problematic. Click here for more details.

Files changed (46) hide show
  1. ekfsm/__init__.py +3 -14
  2. ekfsm/boards/oem/ekf/shu-shuttle.yaml +43 -0
  3. ekfsm/boards/oem/ekf/sq3-quartet.yaml +51 -37
  4. ekfsm/boards/oem/ekf/z1010.yaml +102 -0
  5. ekfsm/boards/oem/hitron/hdrc-300s.yaml +1 -1
  6. ekfsm/cli.py +32 -9
  7. ekfsm/config.py +14 -6
  8. ekfsm/core/__init__.py +13 -3
  9. ekfsm/core/components.py +7 -8
  10. ekfsm/core/connections.py +19 -0
  11. ekfsm/core/slots.py +6 -8
  12. ekfsm/core/sysfs.py +215 -25
  13. ekfsm/core/utils.py +128 -64
  14. ekfsm/devices/__init__.py +27 -7
  15. ekfsm/devices/buttons.py +251 -0
  16. ekfsm/devices/colorLed.py +110 -0
  17. ekfsm/devices/coretemp.py +35 -13
  18. ekfsm/devices/eeprom.py +73 -45
  19. ekfsm/devices/ekf_ccu_uc.py +76 -54
  20. ekfsm/devices/ekf_sur_led.py +6 -2
  21. ekfsm/devices/generic.py +200 -59
  22. ekfsm/devices/gpio.py +37 -27
  23. ekfsm/devices/iio.py +15 -31
  24. ekfsm/devices/iio_thermal_humidity.py +20 -13
  25. ekfsm/devices/imu.py +8 -4
  26. ekfsm/devices/io4edge.py +185 -0
  27. ekfsm/devices/ledArray.py +54 -0
  28. ekfsm/devices/mux.py +46 -8
  29. ekfsm/devices/pixelDisplay.py +141 -0
  30. ekfsm/devices/pmbus.py +74 -101
  31. ekfsm/devices/smbios.py +28 -8
  32. ekfsm/devices/smbus.py +1 -1
  33. ekfsm/devices/thermal_humidity.py +80 -0
  34. ekfsm/devices/toggles.py +90 -0
  35. ekfsm/devices/utils.py +52 -8
  36. ekfsm/devices/watchdog.py +79 -0
  37. ekfsm/exceptions.py +28 -7
  38. ekfsm/lock.py +48 -21
  39. ekfsm/simctrl.py +37 -83
  40. ekfsm/system.py +89 -73
  41. ekfsm/utils.py +44 -0
  42. {ekfsm-0.13.0a183.dist-info → ekfsm-1.5.0.dist-info}/METADATA +12 -6
  43. ekfsm-1.5.0.dist-info/RECORD +57 -0
  44. ekfsm-0.13.0a183.dist-info/RECORD +0 -45
  45. {ekfsm-0.13.0a183.dist-info → ekfsm-1.5.0.dist-info}/WHEEL +0 -0
  46. {ekfsm-0.13.0a183.dist-info → ekfsm-1.5.0.dist-info}/entry_points.txt +0 -0
ekfsm/__init__.py CHANGED
@@ -1,16 +1,5 @@
1
- from .core.slots import Slot
2
1
  from .system import System
3
- from .core import HwModule
4
- from .core.slots import SlotType
5
- from .exceptions import ConfigError
6
- from .lock import locking_cleanup, locking_configure
2
+ from .config import load_config
3
+ from .log import ekfsm_logger
7
4
 
8
- __all__ = (
9
- "System",
10
- "ConfigError",
11
- "HwModule",
12
- "Slot",
13
- "SlotType",
14
- "locking_cleanup",
15
- "locking_configure",
16
- )
5
+ __all__ = ("System", "load_config", "ekfsm_logger")
@@ -0,0 +1,43 @@
1
+ id: 73
2
+ name: "EKF SHU-SHUTTLE"
3
+ slot_type: CPCI_S0_UTILITY
4
+ children:
5
+ - device_type: I2CMux
6
+ name: "MUX"
7
+ addr: 0x70
8
+ slot_coding_mask: 0x0
9
+ children:
10
+ - device_type: MuxChannel
11
+ name: "CH00"
12
+ channel_id: 0
13
+ children:
14
+ - device_type: EKFIdentificationIOExpander
15
+ name: "GPIO"
16
+ addr: 0x3D
17
+ provides:
18
+ inventory:
19
+ - revision
20
+ - device_type: EKF_CCU_EEPROM
21
+ name: "EEPROM"
22
+ addr: 0x55
23
+ provides:
24
+ inventory:
25
+ - vendor
26
+ - serial
27
+ - model
28
+ - repaired_at
29
+ - manufactured_at
30
+ chassis_inventory:
31
+ - revision: crevision
32
+ - write_revision: write_crevision
33
+ - vendor: cvendor
34
+ - write_vendor: write_cvendor
35
+ - serial: cserial
36
+ - write_serial: write_cserial
37
+ - model: cmodel
38
+ - write_model: write_cmodel
39
+ - unit
40
+ - write_unit
41
+ custom_eeprom:
42
+ - write: write_customer_area
43
+ - read: customer_area
@@ -2,40 +2,54 @@ id: 69
2
2
  name: "EKF SQ3-QUARTET"
3
3
  slot_type: CPCI_S0_PER
4
4
  children:
5
- - device_type: I2CMux
6
- name: "MUX"
7
- addr: 0x70
8
- slot_coding_mask: 0x07
9
- children:
10
- - device_type: MuxChannel
11
- name: "CH00"
12
- channel_id: 0
13
- children:
14
- - device_type: EKFIdentificationIOExpander
15
- name: "GPIO"
16
- addr: 0x3D
17
- provides:
18
- inventory:
19
- - revision
20
- - device_type: EKF_EEPROM
21
- name: "EEPROM"
22
- addr: 0x55
23
- provides:
24
- inventory:
25
- - vendor
26
- - serial
27
- - model
28
- - repaired_at
29
- - manufactured_at
30
- - device_type: MuxChannel
31
- name: "CH01"
32
- channel_id: 1
33
- children:
34
- - device_type: MuxChannel
35
- name: "CH02"
36
- channel_id: 2
37
- children:
38
- - device_type: MuxChannel
39
- name: "CH03"
40
- channel_id: 3
41
- children:
5
+ - device_type: IO4Edge
6
+ name: "BMC"
7
+ children:
8
+ - device_type: PixelDisplay
9
+ name: "display"
10
+ - device_type: ButtonArray
11
+ name: "buttons"
12
+ children:
13
+ - device_type: Button
14
+ name: "up"
15
+ channel_id: 0
16
+ - device_type: Button
17
+ name: "down"
18
+ channel_id: 1
19
+ - device_type: I2CMux
20
+ name: "MUX"
21
+ addr: 0x70
22
+ slot_coding_mask: 0x07
23
+ children:
24
+ - device_type: MuxChannel
25
+ name: "CH00"
26
+ channel_id: 0
27
+ children:
28
+ - device_type: EKFIdentificationIOExpander
29
+ name: "GPIO"
30
+ addr: 0x3D
31
+ provides:
32
+ inventory:
33
+ - revision
34
+ - device_type: EKF_EEPROM
35
+ name: "EEPROM"
36
+ addr: 0x55
37
+ provides:
38
+ inventory:
39
+ - vendor
40
+ - serial
41
+ - model
42
+ - repaired_at
43
+ - manufactured_at
44
+ - device_type: MuxChannel
45
+ name: "CH01"
46
+ channel_id: 1
47
+ children:
48
+ - device_type: MuxChannel
49
+ name: "CH02"
50
+ channel_id: 2
51
+ children:
52
+ - device_type: MuxChannel
53
+ name: "CH03"
54
+ channel_id: 3
55
+ children:
@@ -0,0 +1,102 @@
1
+ id: 112
2
+ name: "EKF Z1010"
3
+ slot_type: CPCI_S0_UTILITY
4
+ children:
5
+ - device_type: I2CMux
6
+ name: "MUX"
7
+ addr: 0x70
8
+ slot_coding_mask: 0x0
9
+ children:
10
+ - device_type: MuxChannel
11
+ name: "CH00"
12
+ channel_id: 0
13
+ children:
14
+ - device_type: EKFIdentificationIOExpander
15
+ name: "GPIO"
16
+ addr: 0x3D
17
+ provides:
18
+ inventory:
19
+ - revision
20
+ - device_type: EKF_CCU_EEPROM
21
+ name: "EEPROM"
22
+ addr: 0x55
23
+ provides:
24
+ inventory:
25
+ - vendor
26
+ - serial
27
+ - model
28
+ - repaired_at
29
+ - manufactured_at
30
+ chassis_inventory:
31
+ - revision: crevision
32
+ - write_revision: write_crevision
33
+ - vendor: cvendor
34
+ - write_vendor: write_cvendor
35
+ - serial: cserial
36
+ - write_serial: write_cserial
37
+ - model: cmodel
38
+ - write_model: write_cmodel
39
+ - unit
40
+ - write_unit
41
+ custom_eeprom:
42
+ - write: write_customer_area
43
+ - read: customer_area
44
+ - device_type: IO4Edge
45
+ name: "I4E"
46
+ provides:
47
+ management:
48
+ - identify_firmware
49
+ - load_firmware
50
+ - load_parameter
51
+ - get_parameter
52
+ - restart
53
+ children:
54
+ - device_type: LEDArray
55
+ name: "leds"
56
+ children:
57
+ - device_type: ColorLED
58
+ name: "led0"
59
+ channel_id: 0
60
+ - device_type: ColorLED
61
+ name: "led1"
62
+ channel_id: 1
63
+ - device_type: ColorLED
64
+ name: "led2"
65
+ channel_id: 2
66
+ - device_type: ColorLED
67
+ name: "led3"
68
+ channel_id: 3
69
+ - device_type: ColorLED
70
+ name: "led4"
71
+ channel_id: 4
72
+ - device_type: ColorLED
73
+ name: "led5"
74
+ channel_id: 5
75
+ - device_type: ColorLED
76
+ name: "led6"
77
+ channel_id: 6
78
+ - device_type: ColorLED
79
+ name: "led7"
80
+ channel_id: 7
81
+ - device_type: Watchdog
82
+ name: "watchdog"
83
+ provides:
84
+ sysstate:
85
+ - kick
86
+ - device_type: ThermalHumidity
87
+ name: "th"
88
+ - device_type: GPIOArray
89
+ name: "gpios"
90
+ children:
91
+ - device_type: BinaryToggle
92
+ name: "power"
93
+ channel_id: 0
94
+ - device_type: BinaryToggle
95
+ name: "redriver"
96
+ channel_id: 1
97
+ - device_type: ButtonArray
98
+ name: "buttons"
99
+ children:
100
+ - device_type: Button
101
+ name: "eject"
102
+ channel_id: 2
@@ -2,7 +2,7 @@ id: HDRC300S.*
2
2
  name: "Hitron HDRC-300S"
3
3
  slot_type: CPCI_S0_PSU
4
4
  children:
5
- - device_type: PmBus
5
+ - device_type: PMBus
6
6
  name: "PMBUS"
7
7
  addr: 0x18
8
8
  slot_coding_mask: 0x07
ekfsm/cli.py CHANGED
@@ -1,21 +1,23 @@
1
1
  #! /usr/bin/env python3
2
2
  # import os
3
3
  # import sys
4
- import click
4
+ # pyright: reportOptionalMemberAccess = false
5
5
  import logging
6
6
  from pathlib import Path
7
7
 
8
- from ekfsm.system import System
9
- from ekfsm.log import ekfsm_logger
10
- from ekfsm.simctrl import enable_simulation
11
- from ekfsm.simctrl import register_gpio_simulations
8
+ import click
12
9
 
10
+ from ekfsm.log import ekfsm_logger
11
+ from ekfsm.simctrl import enable_simulation, register_gpio_simulations
12
+ from ekfsm.system import System
13
13
 
14
14
  logging.basicConfig(level=logging.WARNING, format="%(levelname)s: %(message)s")
15
15
  logger = ekfsm_logger(__name__)
16
16
 
17
17
  sm: System | None = None
18
18
 
19
+ __all__ = ("cli", "main", "write", "show")
20
+
19
21
 
20
22
  @click.group()
21
23
  @click.option("--verbose", "-v", is_flag=True, help="Enable verbose output")
@@ -37,7 +39,30 @@ sm: System | None = None
37
39
  )
38
40
  def cli(verbose, debug, sysfs, config):
39
41
  global sm
40
- """POSIX-compliant CLI tool with subcommands"""
42
+ """POSIX-compliant CLI tool with subcommands
43
+ for the EKF System Management (EKFSM) library.
44
+
45
+ This tool provides a command-line interface for managing and
46
+ interacting with the EKF System Management library. It allows
47
+ users to perform various operations related to system management,
48
+ including reading and writing data to the system, and displaying
49
+ information about the system.
50
+
51
+ Parameters
52
+ ----------
53
+ verbose
54
+ Enable verbose output. If set, the logging level will be set to INFO.
55
+ debug
56
+ Enable debug output. If set, the logging level will be set to DEBUG.
57
+ sysfs
58
+ Use custom sysfs directory for simulation mode. If set, the
59
+ simulation mode will be enabled and the specified directory
60
+ will be used for sysfs operations.
61
+ config
62
+ Path to the configuration file. This file is required for
63
+ initializing the system. The path should point to a valid
64
+ configuration file in YAML format.
65
+ """
41
66
  if verbose:
42
67
  logging.getLogger().setLevel(logging.INFO)
43
68
  logger.info("Verbose output enabled")
@@ -62,9 +87,7 @@ def cli(verbose, debug, sysfs, config):
62
87
  type=int,
63
88
  help="Write chassis serial number",
64
89
  )
65
- @click.option(
66
- "--unit", "-u", is_flag=False, prompt=True, type=int, help="Write chassis unit"
67
- )
90
+ @click.option("--unit", "-u", is_flag=False, prompt=True, type=int, help="Write chassis unit")
68
91
  @click.option(
69
92
  "--vendor",
70
93
  "-n",
ekfsm/config.py CHANGED
@@ -1,8 +1,10 @@
1
+ from typing import Any, List, Tuple
2
+
3
+ import munch
1
4
  import yamale # type: ignore
2
5
  import yaml
3
- import munch
4
6
 
5
- from typing import Any, List, Tuple
7
+ from ekfsm.exceptions import ConfigError
6
8
 
7
9
  schema_str = """
8
10
  system_config:
@@ -22,13 +24,19 @@ slot:
22
24
  def _validate_config(config_file: str) -> None:
23
25
  schema = yamale.make_schema(content=schema_str)
24
26
  data = yamale.make_data(config_file)
25
- yamale.validate(schema, data)
27
+ try:
28
+ yamale.validate(schema, data)
29
+ except yamale.YamaleError:
30
+ raise ConfigError("Error in configuration file")
26
31
 
27
32
 
28
33
  def _parse_config(config_file: str) -> Any | munch.Munch | List | Tuple:
29
- with open(config_file) as file:
30
- config = yaml.safe_load(file)
31
- munchified_config = munch.munchify(config)
34
+ try:
35
+ with open(config_file) as file:
36
+ config = yaml.safe_load(file)
37
+ munchified_config = munch.munchify(config)
38
+ except OSError:
39
+ raise ConfigError("Failed to open configuration file: {config_file}")
32
40
  return munchified_config
33
41
 
34
42
 
ekfsm/core/__init__.py CHANGED
@@ -1,4 +1,14 @@
1
- from .slots import Slot, SlotType, Slots # noqa: F401
2
- from .sysfs import SysFSDevice, SysFSAttribute # noqa: F401
3
- from .components import HwModule # noqa: F401
1
+ from .components import HWModule # noqa: F401
4
2
  from .probe import ProbeableDevice # noqa: F401
3
+ from .slots import Slot, Slots, SlotType # noqa: F401
4
+ from .sysfs import SysFSAttribute, SysfsDevice # noqa: F401
5
+
6
+ __all__ = [
7
+ "Slot",
8
+ "SlotType",
9
+ "Slots",
10
+ "SysfsDevice",
11
+ "SysFSAttribute",
12
+ "HWModule",
13
+ "ProbeableDevice",
14
+ ]
ekfsm/core/components.py CHANGED
@@ -36,9 +36,9 @@ class SysTree(NodeMixin):
36
36
  print(self)
37
37
 
38
38
 
39
- class HwModule(SysTree):
39
+ class HWModule(SysTree):
40
40
  """
41
- A HwModule represents an instantiation of a specifc hw board type,
41
+ A HWModule represents an instantiation of a specifc hw board type,
42
42
  for example an instance of an EKF SC9 board.
43
43
  """
44
44
 
@@ -51,7 +51,7 @@ class HwModule(SysTree):
51
51
  *args,
52
52
  **kwargs,
53
53
  ) -> None:
54
- from ekfsm.core.utils import deserialize_hardware_tree
54
+ from ekfsm.core.utils import deserialize_hardware_tree, deserialize_module
55
55
 
56
56
  from .slots import SlotType
57
57
 
@@ -59,9 +59,8 @@ class HwModule(SysTree):
59
59
  self._slot: Slot = slot
60
60
  self.config = config
61
61
 
62
- self.id, self.board_type, slot_type, self.children = deserialize_hardware_tree(
63
- self.logger, self.config, parent=self
64
- )
62
+ self.id, self.board_type, slot_type = deserialize_module(self.logger, config)
63
+ self.children = deserialize_hardware_tree(self.logger, self.config, parent=self)
65
64
 
66
65
  self.slot_type = SlotType.from_string(slot_type)
67
66
 
@@ -119,13 +118,13 @@ class HwModule(SysTree):
119
118
  @property
120
119
  def instance_name(self) -> str:
121
120
  if self.name is None:
122
- raise RuntimeError("instance name not set")
121
+ raise RuntimeError("Instance name not set")
123
122
  return self.name
124
123
 
125
124
  @property
126
125
  def slot(self) -> Slot:
127
126
  if self._slot is None:
128
- raise RuntimeError("slot not set")
127
+ raise RuntimeError("Slot not set")
129
128
  return self._slot
130
129
 
131
130
  def __repr__(self) -> str:
@@ -0,0 +1,19 @@
1
+ from contextlib import contextmanager
2
+
3
+
4
+ class Connectable:
5
+
6
+ def __init__(self, client=None):
7
+ self._client = client
8
+ self._connected = False
9
+
10
+ @contextmanager
11
+ def connect(self):
12
+ if not self._connected:
13
+ client = self._client(self.service_addr, command_timeout=self.timeout)
14
+ self._connected = True
15
+ try:
16
+ yield client
17
+ finally:
18
+ client.close()
19
+ del client
ekfsm/core/slots.py CHANGED
@@ -1,11 +1,9 @@
1
1
  from enum import Enum
2
- from ekfsm.core.components import HwModule
3
-
2
+ from typing import Any
4
3
 
5
4
  from munch import Munch
6
5
 
7
-
8
- from typing import Any
6
+ from ekfsm.core.components import HWModule
9
7
 
10
8
 
11
9
  class SlotType(Enum):
@@ -66,8 +64,8 @@ class Slot:
66
64
  desired_hwmodule_type: str,
67
65
  desired_hwmodule_name: str,
68
66
  number: int,
69
- hwmodule: HwModule | None = None,
70
- master: HwModule | None = None,
67
+ hwmodule: HWModule | None = None,
68
+ master: HWModule | None = None,
71
69
  attributes: Munch | None = None,
72
70
  ) -> None:
73
71
  self._name = name
@@ -142,7 +140,7 @@ class Slots(Munch):
142
140
 
143
141
  Example
144
142
  -------
145
- >>> from ekfsm.slot import Slot, Slots, SlotType
143
+ >>> from ekfsm..core.slots import Slot, Slots, SlotType
146
144
  >>> slotA = Slot("SlotA", SlotType.CPCI_S0_PER, "Bla", "Blubb", 3)
147
145
  >>> slots = Slots((slotA.name, slotA))
148
146
  >>> print(slots[name])
@@ -192,7 +190,7 @@ class Slots(Munch):
192
190
 
193
191
  Example
194
192
  -------
195
- >>> from ekfsm.slot import Slot, Slots, SlotType
193
+ >>> from ekfsm.core.slots import Slot, Slots, SlotType
196
194
  >>> slotA = Slot("SlotA", SlotType.CPCI_S0_PER, "Bla", "Blubb", 3)
197
195
  >>> slots = Slots()
198
196
  >>> slots.add(slotA) # add slotA to the collection