Correct ADC sensors max reading
Set ADC max reading to be reference voltage 1.8Volt.
Calculate maxReading from it. This fixes threshold hysteresis.
Tested:
Use sensor override to trigger alarm and verify that
de-assert happens when sensor reading back to normal.
Without the change, the de-assert never happens.
Example:
busctl set-property xyz.openbmc_project.ADCSensor /xyz/openbmc_project/sensors/voltage/ABC_CPU1 xyz.openbmc_project.Sensor.Value Value d 1.348
intel-obmc adcsensor[412]: Sensor ABC_CPU1 high threshold 1.301 assert: value 1.348 raw data 1244
intel-obmc adcsensor[412]: Sensor ABC_CPU1 high threshold 1.263 assert: value 1.348 raw data 1244
intel-obmc ipmid[242]: thresholdChanged: Assert
intel-obmc ipmid[242]: thresholdChanged: Assert
intel-obmc sel-logger[288]: ABC_CPU1 sensor crossed a critical high threshold going high. Reading=1.348000 Threshold=1.301000.
intel-obmc sel-logger[288]: ABC_CPU1 sensor crossed a warning high threshold going high. Reading=1.348000 Threshold=1.263000.
intel-obmc ipmid[242]: thresholdChanged: deassert
intel-obmc ipmid[242]: thresholdChanged: deassert
intel-obmc sel-logger[288]: ABC_CPU1 sensor crossed a critical high threshold going low. Reading=1.244000 Threshold=1.301000.
intel-obmc sel-logger[288]: ABC_CPU1 sensor crossed a warning high threshold going low. Reading=1.244000 Threshold=1.263000.
Also ran "ipmitool sensor list" and varified ADCSensor values are correct
A P12V PSU SCALE | 12.096 | Volts | ok | na | 10.647 | 10.962 | 13.104 | 13.482 | na
P1V8 PCH | 1.805 | Volts | ok | na | 1.645 | 1.701 | 1.908 | 1.965 | na
P3V3 | 3.320 | Volts | ok | na | 2.976 | 3.062 | 3.543 | 3.646 | na
P3VBAT | 3.074 | Volts | ok | na | 2.141 | 2.459 | 3.265 | 3.286 | na
P12V AUX | 12.096 | Volts | ok | na | 10.647 | 10.962 | 13.104 | 13.482 | na
P105 PCH AUX | 1.058 | Volts | ok | na | 0.966 | 0.994 | 1.108 | 1.136 | na
PVCCIN CPU1 | 1.824 | Volts | ok | na | 1.372 | 1.419 | 2.087 | 2.153 | na
PVCCIO CPU1 | 1.030 | Volts | ok | na | 0.731 | 0.753 | 1.157 | 1.193 | na
PVDQ ABC CPU1 | 1.243 | Volts | ok | na | 1.101 | 1.136 | 1.264 | 1.299 | na
PVDQ DEF CPU1 | 1.243 | Volts | ok | na | 1.101 | 1.136 | 1.264 | 1.299 | na
PVNN PCH AUX | 0.902 | Volts | ok | na | 0.781 | 0.809 | 1.051 | 1.079 | na
Signed-off-by: Zhikui Ren <zhikui.ren@intel.com>
Change-Id: If0dd132f963253172862d1b5e2b96c3bbedcdfd4
diff --git a/src/ADCSensorMain.cpp b/src/ADCSensorMain.cpp
index 9024eb9..473d8a1 100644
--- a/src/ADCSensorMain.cpp
+++ b/src/ADCSensorMain.cpp
@@ -210,6 +210,11 @@
{
scaleFactor = std::visit(VariantToFloatVisitor(),
findScaleFactor->second);
+ // scaleFactor is used in division
+ if (scaleFactor == 0.0f)
+ {
+ scaleFactor = 1.0;
+ }
}
auto findPowerOn = baseConfiguration->second.find("PowerState");