fix rx quality calculation

This commit is contained in:
MichaelDvP
2022-10-14 14:28:08 +02:00
parent 9d4d3738ff
commit 42f6bf6182

View File

@@ -250,11 +250,7 @@ class RxService : public EMSbus {
if (telegram_error_count_ == 0) { if (telegram_error_count_ == 0) {
return 100; // all good, 100% return 100; // all good, 100%
} }
if (telegram_error_count_ >= telegram_count_) { uint8_t q = (telegram_error_count_ * 100 / (telegram_count_ + telegram_error_count_));
return 100;
}
uint8_t q = ((float)telegram_error_count_ / telegram_count_ * 100);
return (q <= EMS_BUS_QUALITY_RX_THRESHOLD ? 100 : 100 - q); return (q <= EMS_BUS_QUALITY_RX_THRESHOLD ? 100 : 100 - q);
} }