Resolve issues in lamp test feature
This commit implements the following changes in lamp test
1. Reset lamp test timer on assert to assert case
2. Reject stopping lamp test when there is a request to
deassert lamp test.
Test:
Case 1: Start lamp test (False to True).
Result: 4mins of lamp test execution and Asserted is set back to
false after 4mins.
Case 2: Stop lamp test (False to False).
Result: Lamp test is not performed and Asserted remains false.
Case 3: Stop request when lamp test is still on (True to false)
Result: Stop request not allowed and lamp test continues to execute.
Asserted stays true until the lamp test ends.
Case 4: Retrigger lamp test (True to True).
Result: 4mins timer restarts. Asserted should be back to false after
4mins.
Change-Id: Ib6086f223d5c5ce80b872ed5f35645893ce79cf9
Signed-off-by: Priyanga Ramasamy <priyanga24@in.ibm.com>
diff --git a/manager/lamptest/lamptest.cpp b/manager/lamptest/lamptest.cpp
index 408f832..3dfaaa5 100644
--- a/manager/lamptest/lamptest.cpp
+++ b/manager/lamptest/lamptest.cpp
@@ -167,6 +167,10 @@
{
// reset the timer and then return
timer.restart(std::chrono::seconds(LAMP_TEST_TIMEOUT_IN_SECS));
+
+ // Notify host to reset the timer
+ doHostLampTest(true);
+
return;
}
@@ -190,7 +194,7 @@
timer.restart(std::chrono::seconds(LAMP_TEST_TIMEOUT_IN_SECS));
isLampTestRunning = true;
- // Notify PHYP to start the lamp test
+ // Notify host to start the lamp test
doHostLampTest(true);
// Set all the Physical action to On for lamp test
@@ -222,7 +226,7 @@
groupObj->asserted(false);
}
-void LampTest::requestHandler(Group* group, bool value)
+bool LampTest::requestHandler(Group* group, bool value)
{
if (groupObj == NULL)
{
@@ -232,10 +236,30 @@
if (value)
{
start();
+
+ // Return true in both cases (F -> T && T -> T)
+ return true;
}
else
{
- stop();
+ if (timer.hasExpired())
+ {
+ stop();
+
+ // Return true as the request to stop the lamptest is handled
+ // successfully.
+ return true;
+ }
+ else if (timer.isEnabled())
+ {
+ lg2::info(
+ "Lamp test is still running. Cannot force stop the lamp test. Asserted is set back to true.");
+
+ // Return false as the request to stop lamptest is not handled as
+ // the lamptest is still running.
+ return false;
+ }
+ return false;
}
}
@@ -304,6 +328,5 @@
}
return;
}
-
} // namespace led
} // namespace phosphor