Stop logging bad SEL on power transitions
Improve the power transition handling logic to avoid
extra sel.
Tested: DC cycled multiple times and watched SEL not happen
Change-Id: I173f8179ff983e08a12af0c618c03f4145c0ac04
Signed-off-by: James Feist <james.feist@linux.intel.com>
diff --git a/src/Utils.cpp b/src/Utils.cpp
index fade0e6..f1a70b5 100644
--- a/src/Utils.cpp
+++ b/src/Utils.cpp
@@ -128,6 +128,7 @@
void setupPowerMatch(const std::shared_ptr<sdbusplus::asio::connection>& conn)
{
+ static boost::asio::steady_timer timer(conn->get_io_context());
// create a match for powergood changes, first time do a method call to
// cache the correct value
if (powerMatch)
@@ -148,8 +149,28 @@
auto findState = values.find(power::property);
if (findState != values.end())
{
- powerStatusOn = boost::ends_with(
+ bool on = boost::ends_with(
std::get<std::string>(findState->second), "Running");
+ if (!on)
+ {
+ timer.cancel();
+ powerStatusOn = false;
+ return;
+ }
+ // on comes too quickly
+ timer.expires_after(std::chrono::seconds(10));
+ timer.async_wait([](boost::system::error_code ec) {
+ if (ec == boost::asio::error::operation_aborted)
+ {
+ return;
+ }
+ else if (ec)
+ {
+ std::cerr << "Timer error " << ec.message() << "\n";
+ return;
+ }
+ powerStatusOn = true;
+ });
}
});
@@ -236,4 +257,4 @@
association->register_property("associations", associations);
association->initialize();
}
-}
\ No newline at end of file
+}