commit | a9400dd8062387c4a4569c9ad42169cb549bf27d | [log] [tgz] |
---|---|---|
author | Patrick Williams <patrick@stwcx.xyz> | Wed Dec 18 11:20:27 2024 -0500 |
committer | Patrick Williams <patrick@stwcx.xyz> | Wed Dec 18 11:20:27 2024 -0500 |
tree | c3b8fd8c7f24631826769b1466ef9b8c872b9952 | |
parent | 2449cf7b2222ad4bf9d0e3dc71bc0d477c8317f7 [diff] |
clang-format: re-format for clang-19 clang-format-19 isn't compatible with the clang-format-18 output, so we need to reformat the code with the latest version. A few parameters in clang-tidy have been deprecated, so adjust the style file accordingly. See Ie2f6eb3b043f2d655c9df806815afd7971fd0947 for updated style. See I88192b41ab7a95599a90915013579608af7bc56f for clang-19 enablement. Change-Id: I57b034938198ef88f0a31ee2cb26fbd11d7340af Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
This project manages LED groups on dbus. Sometimes many LEDs must be driven together to indicate some system state.
For example, there can be multiple identify LEDs. When the user wants to identify the system, they should all light up together.
The configuration can happen via json or yaml.
Each LED can have "Priority" as "Blink", "Off" or "On". If this property is defined, it should be defined on each instance of the LED in the config.
When multiple LED groups are asserted and contain the same LED, "Priority" determines the state of the LED.
For example, Group 1 says LED1 should be "Blink", and Group 2 says it should be "On". LED1 will then have the state declared in "Priority".
Using LED Priority is fine for simple configurations, but when group state needs to always be consistent, Group Priority can be used to enforce the consistent representation.
The Group Priority
is optional and a higher priority means that when 2 groups are asserted, the one with highest Priority
will be represented consistently. Meaning all its LEDs will have the state as per the configuration.
Here we prioritize the locating group above the fault group since locating may be required to fix the fault.
So independent of the order that these groups are asserted, if both are asserted, "sys_id" should be in "Blink" state.
The "unrelated" group will have the default group priority of 0.
{ "leds": [ { "group": "enclosure_identify", "Priority": 2, "members": [ { "Name": "sys_id", "Action": "Blink" }, { "Name": "rear_id", "Action": "Blink" } ] }, { "group": "fault", "Priority": 1, "members": [ { "Name": "sys_id", "Action": "On" }, { "Name": "fault", "Action": "On" } ] }, { "group": "unrelated", "members": [ { "Name": "rear_id", "Action": "On" } ] } ] }
This is our configuration file. It describes 2 LEDs for the 'enclosure_identify' group, with their respective states and duty cycles.
{ "leds": [ { "group": "enclosure_identify", "members": [ { "Name": "pca955x_front_sys_id0", "Action": "On", "DutyOn": 50, "Period": 0, "Priority": "Blink" }, { "Name": "led_rear_enc_id0", "Action": "On", "DutyOn": 50, "Period": 0, "Priority": "Blink" } ] } ] }
Then start the program with
~# ./phosphor-led-manager --config example.json
When starting the program, our LED group shows up on dbus. Usually there will be many more groups.
$ busctl tree xyz.openbmc_project.LED.GroupManager `- /xyz `- /xyz/openbmc_project `- /xyz/openbmc_project/led `- /xyz/openbmc_project/led/groups `- /xyz/openbmc_project/led/groups/enclosure_identify $ busctl introspect xyz.openbmc_project.LED.GroupManager /xyz/openbmc_project/led/groups/enclosure_identify NAME TYPE SIGNATURE RESULT/VALUE FLAGS ... xyz.openbmc_project.Led.Group interface - - - .Asserted property b false emits-change writable
In the above output, the usual org.freedesktop.* interfaces have been removed to keep it readable.
We can now drive the entire group by setting it's 'Asserted' property on dbus.
$ busctl set-property \ xyz.openbmc_project.LED.GroupManager \ /xyz/openbmc_project/led/groups/enclosure_identify \ xyz.openbmc_project.Led.Group Asserted b true
The program can then use the xyz.openbmc_project.Led.Physical dbus interface exposed by phosphor-led-sysfs to set each LED state.
meson setup build
cd build
ninja