Implement de-glitch for fan fault or warn
If three consecutive reads in a row, one second apart, show the fault
on, create and log an error.
Change-Id: Iac7d244b0dc2609c9b499514b88460d653b8d70d
Signed-off-by: Brandon Wyman <bjwyman@gmail.com>
diff --git a/power-supply/power_supply.cpp b/power-supply/power_supply.cpp
index a03eb74..f0c3089 100644
--- a/power-supply/power_supply.cpp
+++ b/power-supply/power_supply.cpp
@@ -434,25 +434,38 @@
{
using namespace witherspoon::pmbus;
- // Check for a fan fault or warning condition
- if ((statusWord & status_word::FAN_FAULT) &&
- !fanFault)
+ if (fanFault < FAULT_COUNT)
{
- util::NamesValues nv;
- nv.add("STATUS_WORD", statusWord);
- captureCmd(nv, STATUS_MFR, Type::Debug);
- captureCmd(nv, STATUS_TEMPERATURE, Type::Debug);
- captureCmd(nv, STATUS_FANS_1_2, Type::Debug);
+ // Check for a fan fault or warning condition
+ if (statusWord & status_word::FAN_FAULT)
+ {
+ fanFault++;
+ }
+ else
+ {
+ if (fanFault > 0)
+ {
+ fanFault = 0;
+ }
+ }
- using metadata = org::open_power::Witherspoon::Fault::
- PowerSupplyFanFault;
+ if (fanFault >= FAULT_COUNT)
+ {
+ util::NamesValues nv;
+ nv.add("STATUS_WORD", statusWord);
+ captureCmd(nv, STATUS_MFR, Type::Debug);
+ captureCmd(nv, STATUS_TEMPERATURE, Type::Debug);
+ captureCmd(nv, STATUS_FANS_1_2, Type::Debug);
- report<PowerSupplyFanFault>(
- metadata::RAW_STATUS(nv.get().c_str()),
- metadata::CALLOUT_INVENTORY_PATH(inventoryPath.c_str()));
+ using metadata = org::open_power::Witherspoon::Fault::
+ PowerSupplyFanFault;
- faultFound = true;
- fanFault = true;
+ report<PowerSupplyFanFault>(
+ metadata::RAW_STATUS(nv.get().c_str()),
+ metadata::CALLOUT_INVENTORY_PATH(inventoryPath.c_str()));
+
+ faultFound = true;
+ }
}
}
@@ -505,7 +518,7 @@
powerOnFault = 0;
outputOCFault = 0;
outputOVFault = 0;
- fanFault = false;
+ fanFault = 0;
temperatureFault = false;
faultFound = false;
diff --git a/power-supply/power_supply.hpp b/power-supply/power_supply.hpp
index ba3a511..b6fcc3a 100644
--- a/power-supply/power_supply.hpp
+++ b/power-supply/power_supply.hpp
@@ -181,9 +181,13 @@
size_t outputOVFault = 0;
/**
- * @brief Set to true when a fan fault or warning condition is detected
+ * @brief Indicates a fan fault or warning condition was detected if
+ * equal to FAULT_COUNT.
+ *
+ * @details This is incremented when the 'FAN_FAULT' bit in the
+ * STATUS_WORD command response is on.
*/
- bool fanFault = false;
+ size_t fanFault = 0;
/**
* @brief Set to true during a temperature fault or warn condition.