summaryrefslogtreecommitdiffstats
path: root/monitor/tach_sensor.cpp
diff options
context:
space:
mode:
authorMatthew Barth <msbarth@us.ibm.com>2018-01-26 12:53:15 -0600
committerMatthew Barth <msbarth@linux.vnet.ibm.com>2018-01-30 15:29:43 +0000
commit0a9fe160d600ece0c5797741042d0e6f975ab101 (patch)
tree37e1948ae086507bb06db636487151e20c87cac5 /monitor/tach_sensor.cpp
parent9a5b6994c745480a78ef658148cfd96dd3e12bdb (diff)
downloadphosphor-fan-presence-0a9fe160d600ece0c5797741042d0e6f975ab101.tar.gz
phosphor-fan-presence-0a9fe160d600ece0c5797741042d0e6f975ab101.zip
Set tach sensor to functional on start
With the addition of a functional state for each fan rotor tach sensor, these should be set to functional on each power on. This is done during fan monitor init mode when no monitor is done and then again once monitoring mode begins. Change-Id: I3c73c1be5f912c7cee8499f47cc799ac3c20983b Signed-off-by: Matthew Barth <msbarth@us.ibm.com>
Diffstat (limited to 'monitor/tach_sensor.cpp')
-rw-r--r--monitor/tach_sensor.cpp75
1 files changed, 39 insertions, 36 deletions
diff --git a/monitor/tach_sensor.cpp b/monitor/tach_sensor.cpp
index 2aa1609..22875a2 100644
--- a/monitor/tach_sensor.cpp
+++ b/monitor/tach_sensor.cpp
@@ -64,7 +64,8 @@ static void readProperty(const std::string& interface,
}
-TachSensor::TachSensor(sdbusplus::bus::bus& bus,
+TachSensor::TachSensor(Mode mode,
+ sdbusplus::bus::bus& bus,
Fan& fan,
const std::string& id,
bool hasTarget,
@@ -81,48 +82,50 @@ TachSensor::TachSensor(sdbusplus::bus::bus& bus,
// Start from a known state of functional
setFunctional(true);
- // Load in starting Target and Input values
- try
- {
- // Use getProperty directly to allow a missing sensor object
- // to abort construction.
- _tachInput = util::SDBusPlus::getProperty<decltype(_tachInput)>(
- _bus,
- _name,
- FAN_SENSOR_VALUE_INTF,
- FAN_VALUE_PROPERTY);
- }
- catch (std::exception& e)
+ // Load in current Target and Input values when entering monitor mode
+ if (mode != Mode::init)
{
- throw InvalidSensorError();
- }
+ try
+ {
+ // Use getProperty directly to allow a missing sensor object
+ // to abort construction.
+ _tachInput = util::SDBusPlus::getProperty<decltype(_tachInput)>(
+ _bus,
+ _name,
+ FAN_SENSOR_VALUE_INTF,
+ FAN_VALUE_PROPERTY);
+ }
+ catch (std::exception& e)
+ {
+ throw InvalidSensorError();
+ }
- if (_hasTarget)
- {
- readProperty(FAN_SENSOR_CONTROL_INTF,
- FAN_TARGET_PROPERTY,
- _name,
- _bus,
- _tachTarget);
- }
+ if (_hasTarget)
+ {
+ readProperty(FAN_SENSOR_CONTROL_INTF,
+ FAN_TARGET_PROPERTY,
+ _name,
+ _bus,
+ _tachTarget);
+ }
- auto match = getMatchString(FAN_SENSOR_VALUE_INTF);
+ auto match = getMatchString(FAN_SENSOR_VALUE_INTF);
- tachSignal = std::make_unique<sdbusplus::server::match::match>(
- _bus,
- match.c_str(),
- [this](auto& msg){ this->handleTachChange(msg); });
+ tachSignal = std::make_unique<sdbusplus::server::match::match>(
+ _bus,
+ match.c_str(),
+ [this](auto& msg){ this->handleTachChange(msg); });
- if (_hasTarget)
- {
- match = getMatchString(FAN_SENSOR_CONTROL_INTF);
+ if (_hasTarget)
+ {
+ match = getMatchString(FAN_SENSOR_CONTROL_INTF);
- targetSignal = std::make_unique<sdbusplus::server::match::match>(
- _bus,
- match.c_str(),
- [this](auto& msg){ this->handleTargetChange(msg); });
+ targetSignal = std::make_unique<sdbusplus::server::match::match>(
+ _bus,
+ match.c_str(),
+ [this](auto& msg){ this->handleTargetChange(msg); });
+ }
}
-
}
std::string TachSensor::getMatchString(const std::string& interface)
OpenPOWER on IntegriCloud