PEL: Print Extended User Header section to JSON
"Extended User Header": {
"Section Version": "1",
"Sub-section type": "0",
"Created by": "0x4552",
"Reporting Machine Type": "OPWR-131",
"Reporting Serial Number": "1318ABA",
"FW Released Ver": "BE868_007",
"FW SubSys Version": "00040905079B0004",
"Common Ref Time": "00/00/0000 00:00:00",
"Symptom Id Len": "0",
"Symptom Id": ""
},
Verified peltool output and all testcases passed.
Signed-off-by: Harisuddin Mohamed Isa <harisuddin@gmail.com>
Change-Id: Id66b9da27d49c89befd157b0e94bbc9defed0d6a
diff --git a/extensions/openpower-pels/extended_user_header.cpp b/extensions/openpower-pels/extended_user_header.cpp
index c5c1938..282bb41 100644
--- a/extensions/openpower-pels/extended_user_header.cpp
+++ b/extensions/openpower-pels/extended_user_header.cpp
@@ -15,6 +15,7 @@
*/
#include "extended_user_header.hpp"
+#include "json_utils.hpp"
#include "pel_types.hpp"
#include <phosphor-logging/log.hpp>
@@ -175,5 +176,35 @@
_symptomIDSize = _symptomID.size();
}
+std::optional<std::string> ExtendedUserHeader::getJSON() const
+{
+ std::string json;
+ jsonInsert(json, "Section Version", getNumberString("%d", _header.version),
+ 1);
+ jsonInsert(json, "Sub-section type", getNumberString("%d", _header.subType),
+ 1);
+ jsonInsert(json, "Created by", getNumberString("0x%X", _header.componentID),
+ 1);
+ jsonInsert(json, "Reporting Machine Type", machineTypeModel(), 1);
+ jsonInsert(json, "Reporting Serial Number", trimEnd(machineSerialNumber()),
+ 1);
+ jsonInsert(json, "FW Released Ver", serverFWVersion(), 1);
+ jsonInsert(json, "FW SubSys Version", subsystemFWVersion(), 1);
+ jsonInsert(json, "Common Ref Time",
+ getNumberString("%02X", _refTime.month) + '/' +
+ getNumberString("%02X", _refTime.day) + '/' +
+ getNumberString("%02X", _refTime.yearMSB) +
+ getNumberString("%02X", _refTime.yearLSB) + ' ' +
+ getNumberString("%02X", _refTime.hour) + ':' +
+ getNumberString("%02X", _refTime.minutes) + ':' +
+ getNumberString("%02X", _refTime.seconds),
+ 1);
+ jsonInsert(json, "Symptom Id Len", getNumberString("%d", _symptomIDSize),
+ 1);
+ jsonInsert(json, "Symptom Id", symptomID(), 1);
+ json.erase(json.size() - 2);
+ return json;
+}
+
} // namespace pels
} // namespace openpower
diff --git a/extensions/openpower-pels/extended_user_header.hpp b/extensions/openpower-pels/extended_user_header.hpp
index 422b3f5..b5a447d 100644
--- a/extensions/openpower-pels/extended_user_header.hpp
+++ b/extensions/openpower-pels/extended_user_header.hpp
@@ -155,6 +155,12 @@
return symptom;
}
+ /**
+ * @brief Get section in JSON.
+ * @return std::optional<std::string> - ExtendedUserHeader section's JSON
+ */
+ std::optional<std::string> getJSON() const override;
+
private:
/**
* @brief Fills in the object from the stream data
diff --git a/extensions/openpower-pels/private_header.cpp b/extensions/openpower-pels/private_header.cpp
index 1bf54ca..a0424d8 100644
--- a/extensions/openpower-pels/private_header.cpp
+++ b/extensions/openpower-pels/private_header.cpp
@@ -85,13 +85,13 @@
std::optional<std::string> PrivateHeader::getJSON() const
{
char tmpPhVal[50];
- sprintf(tmpPhVal, "%02X/%02X/%02X%02X %02X:%02X:%02X",
+ sprintf(tmpPhVal, "%02X/%02X/%02X%02X %02X:%02X:%02X",
_createTimestamp.month, _createTimestamp.day,
_createTimestamp.yearMSB, _createTimestamp.yearLSB,
_createTimestamp.hour, _createTimestamp.minutes,
_createTimestamp.seconds);
std::string phCreateTStr(tmpPhVal);
- sprintf(tmpPhVal, "%02X/%02X/%02X%02X %02X:%02X:%02X",
+ sprintf(tmpPhVal, "%02X/%02X/%02X%02X %02X:%02X:%02X",
_commitTimestamp.month, _commitTimestamp.day,
_createTimestamp.yearMSB, _commitTimestamp.yearLSB,
_commitTimestamp.hour, _commitTimestamp.minutes,
diff --git a/extensions/openpower-pels/tools/peltool.cpp b/extensions/openpower-pels/tools/peltool.cpp
index ed6daa2..ef59cd7 100644
--- a/extensions/openpower-pels/tools/peltool.cpp
+++ b/extensions/openpower-pels/tools/peltool.cpp
@@ -244,7 +244,7 @@
pel.userHeader().subsystem(), pel_values::subsystemValues);
listStr += "\t\t\"Subsystem\": \"" + subsystem + "\",\n";
// commit time
- sprintf(tmpValStr, "%02X/%02X/%02X%02X %02X:%02X:%02X",
+ sprintf(tmpValStr, "%02X/%02X/%02X%02X %02X:%02X:%02X",
pel.privateHeader().commitTimestamp().month,
pel.privateHeader().commitTimestamp().day,
pel.privateHeader().commitTimestamp().yearMSB,