log debug information for sensor threshold assert events
There are sightings that TCPUx_P12_PVCCIO_VS_Temp Sensor
reports reading of zero and trips the low critical threshold.
Add debug prints to gather data.
Also add logs for raw value in sensor base class to help
debug threshold assert events for other sensori type.
Tested:
Verified that log messages show up as expected for threshold
assert events. There is no unwanted log messages on systems that
do not have bad sensor readings.
Signed-off-by: Zhikui Ren <zhikui.ren@intel.com>
Change-Id: Ib0557e804d275fbb3dce3347b4abec696925cc67
diff --git a/src/Thresholds.cpp b/src/Thresholds.cpp
index 986d183..6aa077c 100644
--- a/src/Thresholds.cpp
+++ b/src/Thresholds.cpp
@@ -244,6 +244,7 @@
static int cLoFalse = 0;
static int cLoMidstate = 0;
static int cDebugThrottle = 0;
+static constexpr int assertLogCount = 10;
struct ChangeParam
{
@@ -276,7 +277,12 @@
if (value >= threshold.value)
{
thresholdChanges.emplace_back(threshold, true, value);
- ++cHiTrue;
+ if (++cHiTrue < assertLogCount)
+ {
+ std::cerr << "Sensor " << sensor->name << " high threshold "
+ << threshold.value << " assert: value " << value
+ << " raw data " << sensor->rawValue << "\n";
+ }
}
else if (value < (threshold.value - sensor->hysteresisTrigger))
{
@@ -293,7 +299,13 @@
if (value <= threshold.value)
{
thresholdChanges.emplace_back(threshold, true, value);
- ++cLoTrue;
+ if (++cLoTrue < assertLogCount)
+ {
+ std::cerr << "Sensor " << sensor->name << " low threshold "
+ << threshold.value << " assert: value "
+ << sensor->value << " raw data "
+ << sensor->rawValue << "\n";
+ }
}
else if (value > (threshold.value + sensor->hysteresisTrigger))
{