Add vendor id/name mapping and remove extra space for serial number
1. Add vendor id to vendor name mapping
2. remove the extra space for serial number
Signed-off-by: George Hung <george.hung@quantatw.com>
Change-Id: I59398dd0db570b1aceb4ec053d7861eacd96ade5
diff --git a/nvme_manager.cpp b/nvme_manager.cpp
index 5411a92..7e0fefd 100644
--- a/nvme_manager.cpp
+++ b/nvme_manager.cpp
@@ -39,6 +39,9 @@
static constexpr const int TEMPERATURE_SENSOR_FAILURE = 0x81;
+static std::map<std::string, std::string> map_vendor = {{"80 86", "Intel"},
+ {"14 4d", "Samsung"}};
+
namespace fs = std::filesystem;
namespace phosphor
@@ -268,10 +271,21 @@
nvmeData.vendor =
intToHex(rsp_data_command_8[1]) + " " + intToHex(rsp_data_command_8[2]);
+ for (auto iter = map_vendor.begin(); iter != map_vendor.end(); iter++)
+ {
+ if (iter->first == nvmeData.vendor)
+ {
+ nvmeData.vendor = iter->second;
+ break;
+ }
+ }
+
for (int offset = SERIALNUMBER_START_INDEX; offset < SERIALNUMBER_END_INDEX;
offset++)
{
- nvmeData.serialNumber += static_cast<char>(rsp_data_command_8[offset]);
+ if (rsp_data_command_8[offset] != ' ')
+ nvmeData.serialNumber +=
+ static_cast<char>(rsp_data_command_8[offset]);
}
nvmeData.statusFlags = intToHex(rsp_data_command_0[1]);