LampTest: Notify PHYP to start the lamp test
- As part of the lamp test, when the lamp test is started / stoped,
the BMC needs to notify PHYP, so that PHYP can do lamp test on
externally connected drawers.
For example: MEX IO drawers.
- Since the command to notify PHYP needs to be completed in the PLDM
daemon, ledManager only needs to update the corresponding D-Bus
interface property value.
Tested:
- Notify PHYP by the host-lamp-test path
busctl set-property xyz.openbmc_project.LED.GroupManager
/xyz/openbmc_project/led/groups/host_lamp_test
xyz.openbmc_project.Led.Group Asserted b true
Signed-off-by: George Liu <liuxiwei@inspur.com>
Change-Id: I0a0aad91c512183e457903bddb392ee56118f21c
diff --git a/configure.ac b/configure.ac
index b0e7985..27d4d9d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -89,20 +89,24 @@
AS_HELP_STRING([--enable-use-lamp-test], [Enable lamp test configuration.]))
AM_CONDITIONAL([WANTS_LAMP_TEST], [test "x$enable_use_lamp_test" == "xyes"])
-
-
AS_IF([test "x$enable_use_lamp_test" == "xyes"],
AC_DEFINE([USE_LAMP_TEST],[],[Enable lamp test configuration.])
# lamp test path
AC_ARG_VAR(LAMP_TEST_OBJECT, [The lamp test object])
+ # host lamp test path
+ AC_ARG_VAR(HOST_LAMP_TEST_OBJECT, [The lamp test object])
+
# lamp test timeout secs
AC_ARG_VAR(LAMP_TEST_TIMEOUT_IN_SECS, [The lamp test timeout in seconds])
AS_IF([test "x$LAMP_TEST_OBJECT" == "x"], [LAMP_TEST_OBJECT="/xyz/openbmc_project/led/groups/lamp_test"])
AC_DEFINE_UNQUOTED([LAMP_TEST_OBJECT], ["$LAMP_TEST_OBJECT"], [The lamp test D-Bus object])
+ AS_IF([test "x$HOST_LAMP_TEST_OBJECT" == "x"], [HOST_LAMP_TEST_OBJECT="/xyz/openbmc_project/led/groups/host_lamp_test"])
+ AC_DEFINE_UNQUOTED([HOST_LAMP_TEST_OBJECT], ["$HOST_LAMP_TEST_OBJECT"], [The host lamp test D-Bus object])
+
AS_IF([test "x$LAMP_TEST_TIMEOUT_IN_SECS" == "x"], [LAMP_TEST_TIMEOUT_IN_SECS=240])
AC_DEFINE_UNQUOTED([LAMP_TEST_TIMEOUT_IN_SECS], [$LAMP_TEST_TIMEOUT_IN_SECS], [The lamp test timeout in seconds])
)
diff --git a/lamptest.cpp b/lamptest.cpp
index 572ef68..aaf73de 100644
--- a/lamptest.cpp
+++ b/lamptest.cpp
@@ -35,6 +35,9 @@
timer.setEnabled(false);
+ // Stop host lamp test
+ doHostLampTest(false);
+
// Set all the Physical action to Off
for (const auto& path : physicalLEDPaths)
{
@@ -128,6 +131,9 @@
timer.restart(std::chrono::seconds(LAMP_TEST_TIMEOUT_IN_SECS));
isLampTestRunning = true;
+ // Notify PHYP to start the lamp test
+ doHostLampTest(true);
+
// Set all the Physical action to On for lamp test
for (const auto& path : physicalLEDPaths)
{
@@ -180,5 +186,22 @@
}
}
+void LampTest::doHostLampTest(bool value)
+{
+ try
+ {
+ PropertyValue assertedValue{value};
+ dBusHandler.setProperty(HOST_LAMP_TEST_OBJECT,
+ "xyz.openbmc_project.Led.Group", "Asserted",
+ assertedValue);
+ }
+ catch (const sdbusplus::exception::SdBusError& e)
+ {
+ log<level::ERR>("Failed to set Asserted property",
+ entry("ERROR=%s", e.what()),
+ entry("PATH=%s", HOST_LAMP_TEST_OBJECT));
+ }
+}
+
} // namespace led
} // namespace phosphor
diff --git a/lamptest.hpp b/lamptest.hpp
index ef0d7b0..1797dce 100644
--- a/lamptest.hpp
+++ b/lamptest.hpp
@@ -110,6 +110,12 @@
* @return enumeration equivalent of the passed in string
*/
Layout::Action getActionFromString(const std::string& str);
+
+ /** @brief Notify PHYP to start / stop the lamp test
+ *
+ * @param[in] value - the Asserted property value
+ */
+ void doHostLampTest(bool value);
};
} // namespace led