summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrad Bishop <bradleyb@fuzziesquirrel.com>2017-07-28 21:47:00 -0400
committerPatrick Williams <patrick@stwcx.xyz>2017-08-02 20:18:19 +0000
commitd37c0f850a4cf5ccbfcce22006398797ed42179d (patch)
tree23f36c9d8b59201abbbac8a28c7d5514fbd542ab
parentfcbedca0d847c27fdeab59cda9c6659d8640b6dd (diff)
downloadphosphor-fan-presence-d37c0f850a4cf5ccbfcce22006398797ed42179d.zip
phosphor-fan-presence-d37c0f850a4cf5ccbfcce22006398797ed42179d.tar.gz
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 <bradleyb@fuzziesquirrel.com>
-rw-r--r--presence/tach.cpp23
1 files 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 <phosphor-logging/log.hpp>
#include <string>
#include <tuple>
#include <vector>
@@ -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<int64_t>(s) = util::SDBusPlus::getProperty<int64_t>(
- tachPath,
- tachIface,
- tachProperty);
+ try
+ {
+ std::get<int64_t>(s) = util::SDBusPlus::getProperty<int64_t>(
+ tachPath,
+ tachIface,
+ tachProperty);
+ }
+ catch (std::exception&)
+ {
+ // Assume not spinning.
+
+ std::get<int64_t>(s) = 0;
+ log<level::INFO>(
+ "Unable to read fan tach sensor.",
+ entry("SENSOR=%s", tachPath));
+
+ }
}
// Set the initial state of the sensor.
OpenPOWER on IntegriCloud