Make IpmbSensor properly clear sensor value on PowerOff
Previously when platform was put in Off state, IpmbSensor stopped
polling ON-only sensors, which is fine.
However, it didn't clear sensor value and availability state (which is normally done
by updateValue() for such cases.
This commit introduces following changes:
- updateValue() in invalid power state sets sensor to 'nan'
- modified IpmbSensor to use the same logic as updateValue()
in optimized (skip reading in invalid state) flow
Testing:
- put platform in shutdown state - sensor Value is set to 'nan',
Available is 'false', Functional still 'true'
- after restarting platform - values and flags goes back to normal
Signed-off-by: Adrian Ambrożewicz <adrian.ambrozewicz@linux.intel.com>
Change-Id: Ib413000560820d430fe726740c0e9ae5ca062f12
diff --git a/src/IpmbSensor.cpp b/src/IpmbSensor.cpp
index 5658210..d821982 100644
--- a/src/IpmbSensor.cpp
+++ b/src/IpmbSensor.cpp
@@ -296,8 +296,9 @@
{
return; // we're being canceled
}
- if (!isPowerOn() && readState != PowerState::always)
+ if (!readingStateGood())
{
+ updateValue(std::numeric_limits<double>::quiet_NaN());
read();
return;
}