Fix: Read IM value from planar for single FAB
Reading IM value from system planar by its hardcoded offset value is
failing, as IM offset found different for different systems.
This commit adds the code to address the issue, instead of reading IM
value directly from offset, existing Parser class implementation is
used for reading IM value.
where Parser class iterates through the given record and extracts the
keyword value from the EEPROM file.
This commit also updates isFieldModeEnabled API to return ‘true’ only
when ‘fieldmode’ is set ‘true’ on the system explicitly, in all other
case it should be considered as ‘false’.
Change-Id: I0bf9cfee4dab046da0b485504bde63bc4561f710
Signed-off-by: Anupama B R <anupama.b.r1@ibm.com>
diff --git a/vpd-manager/src/single_fab.cpp b/vpd-manager/src/single_fab.cpp
index ca07a1a..c823e90 100644
--- a/vpd-manager/src/single_fab.cpp
+++ b/vpd-manager/src/single_fab.cpp
@@ -55,30 +55,28 @@
{
try
{
- types::BinaryVector l_imValue(IM_SIZE_IN_BYTES);
- std::fstream l_vpdFileStream;
+ const std::string l_systemPlanarPath(SYSTEM_VPD_FILE_PATH);
+ Parser l_parserObj(l_systemPlanarPath, nlohmann::json{});
- l_vpdFileStream.exceptions(
- std::ifstream::badbit | std::ifstream::failbit);
+ std::shared_ptr<ParserInterface> l_vpdParserInstance =
+ l_parserObj.getVpdParserInstance();
- l_vpdFileStream.open(SYSTEM_VPD_FILE_PATH,
- std::ios::in | std::ios::binary);
+ auto l_readValue = l_vpdParserInstance->readKeywordFromHardware(
+ std::make_tuple(constants::recVSBP, constants::kwdIM));
- l_vpdFileStream.seekg(IM_KW_VALUE_OFFSET, std::ios_base::beg);
-
- // Read keyword value
- l_vpdFileStream.read(reinterpret_cast<char*>(&l_imValue[0]),
- IM_SIZE_IN_BYTES);
-
- l_vpdFileStream.clear(std::ios_base::eofbit);
-
- std::ostringstream l_imData;
- for (const auto& l_byte : l_imValue)
+ if (auto l_keywordValue =
+ std::get_if<types::BinaryVector>(&l_readValue);
+ l_keywordValue && !l_keywordValue->empty())
{
- l_imData << std::setw(2) << std::setfill('0') << std::hex
- << static_cast<int>(l_byte);
+ std::ostringstream l_imData;
+ for (const auto& l_byte : *l_keywordValue)
+ {
+ l_imData << std::setw(2) << std::setfill('0') << std::hex
+ << static_cast<int>(l_byte);
+ }
+
+ return l_imData.str();
}
- return l_imData.str();
}
catch (const std::ifstream::failure& l_ex)
{}
@@ -120,7 +118,7 @@
try
{
std::vector<std::string> l_cmdOutput =
- commonUtility::executeCmd("/sbin/fw_printenv -n fieldmode 2>&1");
+ commonUtility::executeCmd("/sbin/fw_printenv fieldmode");
if (l_cmdOutput.size() > 0)
{
@@ -129,7 +127,7 @@
// Remove the new line character from the string.
l_cmdOutput[0].erase(l_cmdOutput[0].length() - 1);
- return l_cmdOutput[0] == "false" ? false : true;
+ return l_cmdOutput[0] == "fieldmode=true" ? true : false;
}
}
catch (const std::exception& l_ex)