Add dynamic precision in critical sensor

Reading precision values from json file for each critical
sensor to be displayed on lcd screen and adjust output as
per precision value.

Tested: verified with lcd debug card screen.

Change-Id: I43bc0334fba8d939fc7c6da872e92dcf35eeefc7
Signed-off-by: Vijay Khemka <vijaykhemka@fb.com>
diff --git a/cri_sensors.json b/cri_sensors.json
index bde25f2..b7a1e35 100644
--- a/cri_sensors.json
+++ b/cri_sensors.json
@@ -9,11 +9,13 @@
 	},
 	"MB_HSC_IN_POWER":
 	{
-		"short_name": "HSC_PWR:"
+		"short_name": "HSC_PWR:",
+		"precision": 1
 	},
 	"MB_HSC_IN_VOLT":
 	{
-		"short_name": "HSC_VOL:"
+		"short_name": "HSC_VOL:",
+		"precision": 2
 	},
 	"MB_FAN0_TACH":
 	{
@@ -41,7 +43,8 @@
 	},
 	"MB_VR_CPU1_VCCIN_Output_Power":
 	{
-		"short_name": "P1_VR_Pwr:"
+		"short_name": "P1_VR_Pwr:",
+		"precision": 1
 	},
 	"MB_CPU0_DIMM_GRPA_TEMP":
 	{
diff --git a/src/usb-dbg.cpp b/src/usb-dbg.cpp
index 6a3e1ad..59dc566 100644
--- a/src/usb-dbg.cpp
+++ b/src/usb-dbg.cpp
@@ -797,7 +797,12 @@
             if (ipmi::storage::getSensorValue(senName, fvalue) == 0)
             {
                 std::stringstream ss;
-                ss << std::fixed << std::setprecision(2) << fvalue;
+                int prec = 0; // Default value
+
+                if (val.find("precision") != val.end())
+                    prec = val["precision"];
+
+                ss << std::fixed << std::setprecision(prec) << fvalue;
 
                 std::string senStr;
                 if (val.find("short_name") != val.end())