Fix cppcheck warnings

Warning message:
```
/usr/lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/bits/unique_ptr.h:97:16: error: invalid application of 'sizeof' to an incomplete type 'phosphor::led::fru::fault::monitor::Remove'
   97 |         static_assert(sizeof(_Tp)>0,
      |                       ^~~~~~~~~~~
/usr/lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/bits/unique_ptr.h:404:4: note: in instantiation of member function 'std::default_delete<phosphor::led::fru::fault::monitor::Remove>::operator()' requested here
  404 |           get_deleter()(std::move(__ptr));
      |           ^
/usr/lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/bits/stl_construct.h:88:15: note: in instantiation of member function 'std::unique_ptr<phosphor::led::fru::fault::monitor::Remove>::~unique_ptr' requested here
   88 |         __location->~_Tp();
      |                      ^
/usr/lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/bits/stl_construct.h:149:12: note: in instantiation of function template specialization 'std::destroy_at<std::unique_ptr<phosphor::led::fru::fault::monitor::Remove>>' requested here
  149 |       std::destroy_at(__pointer);
      |            ^
/usr/lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/bits/stl_construct.h:163:11: note: in instantiation of function template specialization 'std::_Destroy<std::unique_ptr<phosphor::led::fru::fault::monitor::Remove>>' requested here
  163 |             std::_Destroy(std::__addressof(*__first));
      |                  ^
/usr/lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/bits/stl_construct.h:193:35: note: in instantiation of function template specialization 'std::_Destroy_aux<false>::__destroy<std::unique_ptr<phosphor::led::fru::fault::monitor::Remove> *>' requested here
  193 |         return std::_Destroy_aux<false>::__destroy(__first, __last);
      |                                          ^
/usr/lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/bits/alloc_traits.h:948:12: note: in instantiation of function template specialization 'std::_Destroy<std::unique_ptr<phosphor::led::fru::fault::monitor::Remove> *>' requested here
  948 |       std::_Destroy(__first, __last);
      |            ^
/usr/lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/bits/stl_vector.h:735:7: note: in instantiation of function template specialization 'std::_Destroy<std::unique_ptr<phosphor::led::fru::fault::monitor::Remove> *, std::unique_ptr<phosphor::led::fru::fault::monitor::Remove>>' requested here
  735 |         std::_Destroy(this->_M_impl._M_start, this->_M_impl._M_finish,
      |              ^
../../../fault-monitor/fru-fault-monitor.hpp:48:14: note: in instantiation of member function 'std::vector<std::unique_ptr<phosphor::led::fru::fault::monitor::Remove>>::~vector' requested here
   48 |     explicit Add(sdbusplus::bus_t& bus) :
      |              ^
../../../fault-monitor/fru-fault-monitor.hpp:28:7: note: forward declaration of 'phosphor::led::fru::fault::monitor::Remove'
   28 | class Remove;
      |       ^
```

Signed-off-by: George Liu <liuxiwei@ieisystem.com>
Change-Id: I5c20a0031deff51e6bacccdd81310e95f14e52a0
1 file changed
tree: 8e023f58fa3191e5a3ef031e1466fc89effb7ded
  1. configs/
  2. example/
  3. fault-monitor/
  4. manager/
  5. scripts/
  6. subprojects/
  7. test/
  8. .clang-format
  9. .gitignore
  10. .linter-ignore
  11. .shellcheck
  12. led.yaml
  13. LICENSE
  14. meson.build
  15. meson.options
  16. OWNERS
  17. pyproject.toml
  18. README.md
  19. utils.cpp
  20. utils.hpp
README.md

phosphor-led-manager

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.

Configuration

The configuration can happen via json or yaml.

Configuration Example (JSON)

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

Dbus interface

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.

How to Build

meson setup build
cd build
ninja