From d37c0f850a4cf5ccbfcce22006398797ed42179d Mon Sep 17 00:00:00 2001 From: Brad Bishop Date: Fri, 28 Jul 2017 21:47:00 -0400 Subject: presence: Allow missing tach sensors Do not allow missing tach sensors to abort the program. Instead, assume the fan is not spinning. Change-Id: Idc923b9c57b4d180aa16f0aa4933c65e7e4a2d42 Signed-off-by: Brad Bishop --- presence/tach.cpp | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/presence/tach.cpp b/presence/tach.cpp index 0d96ce5..10eb4f2 100644 --- a/presence/tach.cpp +++ b/presence/tach.cpp @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +#include #include #include #include @@ -26,6 +27,7 @@ namespace fan namespace presence { +using namespace phosphor::logging; using namespace std::literals::string_literals; static const auto tachNamespace = "/xyz/openbmc_project/sensors/fan_tach/"s; @@ -57,10 +59,23 @@ bool Tach::start() [this, i](auto& msg){ this->propertiesChanged(i, msg);}); // Get an initial tach speed. - std::get(s) = util::SDBusPlus::getProperty( - tachPath, - tachIface, - tachProperty); + try + { + std::get(s) = util::SDBusPlus::getProperty( + tachPath, + tachIface, + tachProperty); + } + catch (std::exception&) + { + // Assume not spinning. + + std::get(s) = 0; + log( + "Unable to read fan tach sensor.", + entry("SENSOR=%s", tachPath)); + + } } // Set the initial state of the sensor. -- cgit v1.2.1