psu-ng: Create error for communication fault
Signed-off-by: Brandon Wyman <bjwyman@gmail.com>
Change-Id: I3f147063759559bf2486e78d9873c6d464381ddd
diff --git a/phosphor-power-supply/power_supply.hpp b/phosphor-power-supply/power_supply.hpp
index 3386b80..875e714 100644
--- a/phosphor-power-supply/power_supply.hpp
+++ b/phosphor-power-supply/power_supply.hpp
@@ -150,7 +150,7 @@
*/
bool isFaulted() const
{
- return faultFound;
+ return (faultFound || hasCommFault());
}
/**
@@ -193,6 +193,11 @@
return vinUVFault;
}
+ const std::string getDevicePath() const
+ {
+ return pmbusIntf->path();
+ }
+
const std::string& getInventoryPath() const
{
return inventoryPath;
diff --git a/phosphor-power-supply/psu_manager.cpp b/phosphor-power-supply/psu_manager.cpp
index 32847b8..b7f8caa 100644
--- a/phosphor-power-supply/psu_manager.cpp
+++ b/phosphor-power-supply/psu_manager.cpp
@@ -226,6 +226,18 @@
psu->setFaultLogged();
}
+ else if (psu->hasCommFault())
+ {
+ /* Attempts to communicate with the power supply have reached
+ * there limit. Create an error. */
+ additionalData["CALLOUT_DEVICE_PATH"] = psu->getDevicePath();
+
+ createError(
+ "xyz.openbmc_project.Power.PowerSupply.Error.CommFault",
+ additionalData);
+
+ psu->setFaultLogged();
+ }
}
}
}
diff --git a/phosphor-power-supply/test/mock.hpp b/phosphor-power-supply/test/mock.hpp
index 63afffe..02e3947 100644
--- a/phosphor-power-supply/test/mock.hpp
+++ b/phosphor-power-supply/test/mock.hpp
@@ -22,6 +22,7 @@
MOCK_METHOD(void, writeBinary,
(const std::string& name, std::vector<uint8_t> data, Type type),
(override));
+ MOCK_METHOD(const fs::path&, path, (), (const, override));
};
} // namespace pmbus