Add critical sensor units to lcd display
Get sensor type from path and add its unit to output
on debug card LCD display.
Tested: verified with lcd debug card screen.
Change-Id: I7caf7d7b58d25662614ee38b1c84d5d32808d2f3
Signed-off-by: Vijay Khemka <vijaykhemka@fb.com>
diff --git a/src/storagecommands.cpp b/src/storagecommands.cpp
index d38008e..3c11372 100644
--- a/src/storagecommands.cpp
+++ b/src/storagecommands.cpp
@@ -860,6 +860,37 @@
return 0;
}
+const static boost::container::flat_map<const char *, std::string, CmpStr>
+ sensorUnitStr{{{"temperature", "C"},
+ {"voltage", "V"},
+ {"current", "mA"},
+ {"fan_tach", "RPM"},
+ {"fan_pwm", "RPM"},
+ {"power", "W"}}};
+
+int getSensorUnit(std::string &name, std::string &unit)
+{
+ std::string connection;
+ std::string path;
+ int ret = -1;
+
+ ret = getSensorConnectionByName(name, connection, path);
+ if (ret < 0)
+ {
+ return ret;
+ }
+
+ std::string sensorTypeStr = getSensorTypeStringFromPath(path);
+ auto findSensor = sensorUnitStr.find(sensorTypeStr.c_str());
+ if (findSensor != sensorUnitStr.end())
+ {
+ unit = findSensor->second;
+ return 0;
+ }
+ else
+ return -1;
+}
+
void registerStorageFunctions()
{
// <READ FRU Data>
diff --git a/src/usb-dbg.cpp b/src/usb-dbg.cpp
index 9fa0553..6a3e1ad 100644
--- a/src/usb-dbg.cpp
+++ b/src/usb-dbg.cpp
@@ -69,7 +69,8 @@
namespace storage
{
int getSensorValue(std::string &, double &);
-}
+int getSensorUnit(std::string &, std::string &);
+} // namespace storage
typedef struct _sensor_desc
{
@@ -805,6 +806,12 @@
senStr = senName;
senStr += ss.str();
+
+ /* Get unit string for sensor and append in output */
+ std::string unitStr;
+ if (ipmi::storage::getSensorUnit(senName, unitStr) == 0)
+ senStr += unitStr;
+
frame_snr.append(senStr.c_str(), 0);
}
else