fix ems line quality calculation

This commit is contained in:
proddy
2021-03-27 16:02:01 +01:00
parent e21ad6a6ba
commit 96b83e3eb3
2 changed files with 14 additions and 5 deletions

View File

@@ -218,7 +218,11 @@ class RxService : public EMSbus {
if (telegram_error_count_ == 0) {
return 100; // all good, 100%
}
if (telegram_error_count_ >= telegram_count_) {
return 100;
}
uint8_t q = ((float)telegram_error_count_ / telegram_count_ * 100);
return (q <= EMS_BUS_QUALITY_RX_THRESHOLD ? 100 : 100 - q);
}
@@ -308,6 +312,9 @@ class TxService : public EMSbus {
if (telegram_fail_count_ == 0) {
return 100; // all good, 100%
}
if (telegram_fail_count_ >= telegram_read_count_) {
return 100;
}
return (100 - (uint8_t)(((float)telegram_fail_count_ / telegram_read_count_ * 100)));
}