VPD Tool: Update Hardware
Vpd tool has --Hardware/-H flag which should be given along
with writeKeyword flags, if the user wants to write directly to "Hardware".
In general the user should give only the object path in
--path/-P value.
Only if --Hardware/-H flag is given, the user has an
option to give either eeprom path or the object path in
--path/-P value.
Test:
Tested on simics.
./vpd-tool --writeKeyword -H --path < hardware path/object path > -R < record name > -K < keyword > -V < value in hex/ascii >
CASE 1: <updating eeprom path> < update directly on hardware using -H.>
./vpd-tool -u -H -P /sys/devices/platform/ahb/ahb:apb/ahb:apb:bus@1e78a000/1e78a480.i2c-bus/i2c-8/8-0051/8-00510/nvmem -R VINI -K PN -V 0x717273
updation successful on both dbus and hardware.
CASE 2:
./vpd-tool -u -H -P /sys/devices/platform/ahb/ahb:apb/ahb:apb:bus@1e78a000/1e78a480.i2c-bus/i2c-8/8-0051/8-00510/nvmem -R DINF -K FL -V 0x717273
updation successful on hardware. <this wont get updated in dbus as the given record-keyword pair is not required to update in dbus(only those record keywords
present in dbus_properties.json are required to be updated in dbus).
CASE 3: <failure case - invalid eeprom path>
root@rainier:/tmp# ./vpd-tool -u -H -P /sys/devices/platform/ahb/ahb:apb/ahb:apb:bus@1e78a000/1e78a490.i2c-bus/i2c-8/8-0051/8-00510/nvmem -R VINI -K PN -V 0x717273
Invalid object path : /sys/devices/platform/ahb/ahb:apb/ahb:apb:bus@1e78a000/1e78a490.i2c-bus/i2c-8/8-0051/8-00510/nvmem. Unable to find the corresponding EEPROM path for the given object path : /sys/devices/platform/ahb/ahb:apb/ahb:apb:bus@1e78a000/1e7$
Signed-off-by: PriyangaRamasamy <priyanga24@in.ibm.com>
Change-Id: I6b893e699fe343c90c3a3fd2b07fd8b9a4711687
diff --git a/vpd_tool_impl.hpp b/vpd_tool_impl.hpp
index b490fcc..1ca50b5 100644
--- a/vpd_tool_impl.hpp
+++ b/vpd_tool_impl.hpp
@@ -1,6 +1,8 @@
#include "config.h"
+#include "editor_impl.hpp"
#include "types.hpp"
+#include "utils.hpp"
#include <nlohmann/json.hpp>
#include <string>
@@ -118,9 +120,22 @@
*/
void eraseInventoryPath(std::string& fru);
- /** @brief printReturnCode */
+ /**
+ * @brief printReturnCode
+ * Prints the return code of the program in console output, whenever
+ * the program fails to exit successfully.
+ *
+ * @param[in] returnCode - return code of the program.
+ */
void printReturnCode(int returnCode);
+ /**
+ * @brief Convert hex/ascii values to Binary
+ * @param[in] - value in hex/ascii.
+ * @param[out] - value in binary.
+ */
+ openpower::vpd::Binary toBinary(const std::string& value);
+
public:
/**
* @brief Dump the complete inventory in JSON format
@@ -166,13 +181,22 @@
* @brief Get Printable Value
*
* Checks if the vector value has non printable characters.
- * And returns hex value if non printable char is found else
+ * Returns hex value if non printable char is found else
* returns ascii value.
*
* @param[in] vector - Reference of the Binary vector
* @return printable value - either in hex or in ascii.
*/
- std::string getPrintableValue(const std::vector<unsigned char>& vec);
+ std::string getPrintableValue(const std::vector<unsigned char>& vector);
+
+ /**
+ * @brief Update Hardware
+ * If the given record-keyword pair is present in dbus_properties.json,
+ * then will update the given data in both dbus and hardware.
+ * Else update the given data only in hardware.
+ * @return returncode (success/failure).
+ */
+ int updateHardware();
/**
* @brief Constructor