ExitAir: Limit error prints
This was spamming the logs on systems with FP disconnected.
Tested: Less logs were there
Change-Id: I0b6ae204c4052317f1200d3adf89d81e518756f2
Signed-off-by: James Feist <james.feist@linux.intel.com>
diff --git a/src/ExitAirTempSensor.cpp b/src/ExitAirTempSensor.cpp
index 0736a55..42ae6db 100644
--- a/src/ExitAirTempSensor.cpp
+++ b/src/ExitAirTempSensor.cpp
@@ -629,7 +629,10 @@
bool ExitAirTempSensor::calculate(double& val)
{
+ constexpr size_t maxErrorPrint = 1;
static bool firstRead = false;
+ static size_t errorPrint = maxErrorPrint;
+
double cfm = getTotalCFM();
if (cfm <= 0)
{
@@ -640,7 +643,11 @@
// if there is an error getting inlet temp, return error
if (std::isnan(inletTemp))
{
- std::cerr << "Cannot get inlet temp\n";
+ if (errorPrint > 0)
+ {
+ errorPrint--;
+ std::cerr << "Cannot get inlet temp\n";
+ }
val = 0;
return false;
}
@@ -684,7 +691,11 @@
if (totalPower == 0)
{
- std::cerr << "total power 0\n";
+ if (errorPrint > 0)
+ {
+ errorPrint--;
+ std::cerr << "total power 0\n";
+ }
val = 0;
return false;
}
@@ -758,6 +769,7 @@
val = reading;
lastReading = reading;
lastTime = time;
+ errorPrint = maxErrorPrint;
return true;
}