From 21261f80426e3329b9530af5f3d146344716b385 Mon Sep 17 00:00:00 2001 From: Rolf Ahrenberg Date: Mon, 12 Jan 2015 23:58:30 +0200 Subject: [PATCH] Clamp signal quality and level values. --- tuner.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tuner.c b/tuner.c index 7533d3e..464628d 100644 --- a/tuner.c +++ b/tuner.c @@ -292,7 +292,7 @@ void cSatipTuner::ProcessApplicationData(u_char *bufferP, int lengthP) // -65dBm corresponds to 32 // No signal corresponds to 0 c = strstr(c, ","); - value = atoi(++c); + value = min(atoi(++c), 255); // Scale value to 0-100 signalStrengthM = (value >= 0) ? (value * 100 / 255) : -1; @@ -310,7 +310,7 @@ void cSatipTuner::ProcessApplicationData(u_char *bufferP, int lengthP) // -a BER lower than 2x10-4 after Viterbi for DVB-S // -a PER lower than 10-7 for DVB-S2 c = strstr(c, ","); - value = atoi(++c); + value = min(atoi(++c), 15); // Scale value to 0-100 signalQualityM = (hasLockM && (value >= 0)) ? (value * 100 / 15) : 0; }