added threshold for Rx quality (5%)

This commit is contained in:
proddy
2020-10-08 15:55:54 +02:00
parent 43e15ebf20
commit 0cc2abfcfe

View File

@@ -189,6 +189,7 @@ class EMSbus {
private:
static constexpr uint32_t EMS_BUS_TIMEOUT = 30000; // timeout in ms before recognizing the ems bus is offline (30 seconds)
static uint32_t last_bus_activity_; // timestamp of last time a valid Rx came in
static bool bus_connected_; // start assuming the bus hasn't been connected
static uint8_t ems_mask_; // unset=0xFF, buderus=0x00, junkers/ht3=0x80
@@ -227,7 +228,8 @@ class RxService : public EMSbus {
if (telegram_error_count_ == 0) {
return 100; // all good, 100%
}
return (100 - (((float)telegram_error_count_ / telegram_count_ * 100)));
uint8_t q = ((float)telegram_error_count_ / telegram_count_ * 100);
return (q <= EMS_BUS_QUALITY_RX_THRESHOLD ? 100 : 100 - q);
}
class QueuedRxTelegram {
@@ -247,6 +249,8 @@ class RxService : public EMSbus {
}
private:
static constexpr uint8_t EMS_BUS_QUALITY_RX_THRESHOLD = 5; // % threshold before reporting quality issues
uint8_t rx_telegram_id_ = 0; // queue counter
uint32_t telegram_count_ = 0; // # Rx received
uint32_t telegram_error_count_ = 0; // # Rx CRC errors