Add a helper function getFruData to updateFRUProperty
Refactoring updateFRUProperty function and created a new helper
function getFruData. Moved this function to fru_utils.cpp as it
is common for all fru-device deamons and avoid code duplication.
This patch is created based on suggestion on the below patch.
https://gerrit.openbmc.org/c/openbmc/entity-manager/+/51555
TESTED : Built Facebook YosemiteV2 images and loaded
on the target hardware. Verified all the fru's read and write.
Signed-off-by: Kumar Thangavel <thangavel.k@hcl.com>
Change-Id: I7514469d5798c68efce7353ca486195016cacf81
diff --git a/src/fru_utils.cpp b/src/fru_utils.cpp
index bcc1180..b168705 100644
--- a/src/fru_utils.cpp
+++ b/src/fru_utils.cpp
@@ -1034,3 +1034,19 @@
}
return productName;
}
+
+bool getFruData(std::vector<uint8_t>& fruData, uint32_t bus, uint32_t address)
+{
+ try
+ {
+ fruData = getFRUInfo(static_cast<uint16_t>(bus),
+ static_cast<uint8_t>(address));
+ }
+ catch (const std::invalid_argument& e)
+ {
+ std::cerr << "Failure getting FRU Info" << e.what() << "\n";
+ return false;
+ }
+
+ return !fruData.empty();
+}