psu-ng: Limit tracing/logging read failures
Signed-off-by: Brandon Wyman <bjwyman@gmail.com>
Change-Id: I433f164b82e9c5e6529d197354f4ab1169417540
diff --git a/phosphor-power-supply/power_supply.hpp b/phosphor-power-supply/power_supply.hpp
index f1220fd..3386b80 100644
--- a/phosphor-power-supply/power_supply.hpp
+++ b/phosphor-power-supply/power_supply.hpp
@@ -30,6 +30,8 @@
static constexpr auto FL_KW_SIZE = 20;
#endif
+constexpr auto LOG_LIMIT = 3;
+
/**
* @class PowerSupply
* Represents a PMBus power supply device.
@@ -196,6 +198,14 @@
return inventoryPath;
}
+ /** @brief Returns true if the number of failed reads exceeds limit
+ * TODO: or CML bit on.
+ */
+ bool hasCommFault() const
+ {
+ return readFail >= LOG_LIMIT;
+ }
+
private:
/** @brief systemd bus member */
sdbusplus::bus::bus& bus;
@@ -218,6 +228,9 @@
/** @brief True if bit 3 of STATUS_WORD low byte is on. */
bool vinUVFault = false;
+ /** @brief Count of the number of read failures. */
+ size_t readFail = 0;
+
/**
* @brief D-Bus path to use for this power supply's inventory status.
**/