Add power state check for HwmonTempSensor
We have some sensors that are on DC power, add the
check so this is configurable.
Tested: DC cycled, saw no logs
Change-Id: I0f2fc5c96c46d8c782f4bc364f649a9f2f699c3a
Signed-off-by: James Feist <james.feist@linux.intel.com>
diff --git a/src/HwmonTempSensor.cpp b/src/HwmonTempSensor.cpp
index 15d4d38..5222b04 100644
--- a/src/HwmonTempSensor.cpp
+++ b/src/HwmonTempSensor.cpp
@@ -43,12 +43,12 @@
std::shared_ptr<sdbusplus::asio::connection>& conn,
boost::asio::io_service& io, const std::string& sensorName,
std::vector<thresholds::Threshold>&& _thresholds,
- const std::string& sensorConfiguration) :
+ const std::string& sensorConfiguration, const PowerState powerState) :
Sensor(boost::replace_all_copy(sensorName, " ", "_"),
std::move(_thresholds), sensorConfiguration, objectType, maxReading,
minReading),
objServer(objectServer), inputDev(io, open(path.c_str(), O_RDONLY)),
- waitTimer(io), path(path), errCount(0)
+ waitTimer(io), path(path), errCount(0), readState(powerState)
{
sensorInterface = objectServer.add_interface(
"/xyz/openbmc_project/sensors/temperature/" + name,
@@ -70,6 +70,7 @@
"/xyz/openbmc_project/sensors/temperature/" + name,
association::interface);
setInitialProperties(conn);
+ setupPowerMatch(conn);
setupRead();
}
@@ -154,5 +155,9 @@
void HwmonTempSensor::checkThresholds(void)
{
+ if (readState == PowerState::on && !isPowerOn())
+ {
+ return;
+ }
thresholds::checkThresholds(this);
}