sensorcommands: Add IPMI reading logging instrumentation

Noteworthy sensor readings, such as the first reading,
a new minimum or maximum value, or ending a good or
bad streak of readings, will now have some useful logging output.

Tested: Example logs
```
root@bmc:~# journalctl --no-pager | grep 'IPMI sensor'
Jan 01 00:03:16 bmc ipmid[2865]: IPMI sensor sensor0: First reading, value=6 byte=51
Jan 01 00:03:16 bmc ipmid[2865]: IPMI sensor sensor0: Range min=0 max=30, Coefficients mValue=118 rExp=-3 bValue=0 bExp=0 bSigned=0
Jan 01 00:03:16 bmc ipmid[2865]: IPMI sensor sensor1: First reading, value=7 byte=59
Jan 01 00:03:16 bmc ipmid[2865]: IPMI sensor sensor1: Range min=0 max=30, Coefficients mValue=118 rExp=-3 bValue=0 bExp=0 bSigned=0
Jan 01 00:03:16 bmc ipmid[2865]: IPMI sensor sensor2: First reading, value=1.437 byte=12
Jan 01 00:03:16 bmc ipmid[2865]: IPMI sensor sensor2: Range min=0 max=30, Coefficients mValue=118 rExp=-3 bValue=0 bExp=0 bSigned=0
Jan 01 00:03:16 bmc ipmid[2865]: IPMI sensor sensor3: First reading, value=1.437 byte=12
Jan 01 00:03:16 bmc ipmid[2865]: IPMI sensor sensor3: Range min=0 max=30, Coefficients mValue=118 rExp=-3 bValue=0 bExp=0 bSigned=0
Jan 01 00:03:16 bmc ipmid[2865]: IPMI sensor sensor4: First reading, value=1.96 byte=17
Jan 01 00:03:16 bmc ipmid[2865]: IPMI sensor sensor4: Range min=0 max=30, Coefficients mValue=118 rExp=-3 bValue=0 bExp=0 bSigned=0
...
```
Machine and sensors names are replaced.

Ported from:
https://gerrit.openbmc-project.xyz/c/openbmc/intel-ipmi-oem/+/40327

Signed-off-by: Josh Lehan <krellan@google.com>
Change-Id: Idf7c8d4285b286fdc0afb3f0e7260c2d4915b326
Signed-off-by: Willy Tu <wltu@google.com>
diff --git a/dbus-sdr/sensorcommands.cpp b/dbus-sdr/sensorcommands.cpp
index b706db2..42fb9de 100644
--- a/dbus-sdr/sensorcommands.cpp
+++ b/dbus-sdr/sensorcommands.cpp
@@ -341,6 +341,35 @@
             IPMISensorReadingByte2::readingStateUnavailable);
     }
 
+    if constexpr (details::enableInstrumentation)
+    {
+        int byteValue;
+        if (bSigned)
+        {
+            byteValue = static_cast<int>(static_cast<int8_t>(value));
+        }
+        else
+        {
+            byteValue = static_cast<int>(static_cast<uint8_t>(value));
+        }
+
+        // Keep stats on the reading just obtained, even if it is "NaN"
+        if (details::sdrStatsTable.updateReading(sensnum, reading, byteValue))
+        {
+            // This is the first reading, show the coefficients
+            double step = (max - min) / 255.0;
+            std::cerr << "IPMI sensor "
+                      << details::sdrStatsTable.getName(sensnum)
+                      << ": Range min=" << min << " max=" << max
+                      << ", step=" << step
+                      << ", Coefficients mValue=" << static_cast<int>(mValue)
+                      << " rExp=" << static_cast<int>(rExp)
+                      << " bValue=" << static_cast<int>(bValue)
+                      << " bExp=" << static_cast<int>(bExp)
+                      << " bSigned=" << static_cast<int>(bSigned) << "\n";
+        }
+    }
+
     uint8_t thresholds = 0;
 
     auto warningObject =
@@ -1187,6 +1216,9 @@
     std::strncpy(record.body.id_string, name.c_str(),
                  sizeof(record.body.id_string));
 
+    // Remember the sensor name, as determined for this sensor number
+    details::sdrStatsTable.updateName(sensornumber, name);
+
     IPMIThresholds thresholdData;
     try
     {