mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-07 16:29:51 +03:00
added threshold for Rx quality (5%)
This commit is contained in:
@@ -189,12 +189,13 @@ class EMSbus {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
static constexpr uint32_t EMS_BUS_TIMEOUT = 30000; // timeout in ms before recognizing the ems bus is offline (30 seconds)
|
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 uint32_t last_bus_activity_; // timestamp of last time a valid Rx came in
|
||||||
static uint8_t ems_mask_; // unset=0xFF, buderus=0x00, junkers/ht3=0x80
|
static bool bus_connected_; // start assuming the bus hasn't been connected
|
||||||
static uint8_t ems_bus_id_; // the bus id, which configurable and stored in settings
|
static uint8_t ems_mask_; // unset=0xFF, buderus=0x00, junkers/ht3=0x80
|
||||||
static uint8_t tx_mode_; // local copy of the tx mode
|
static uint8_t ems_bus_id_; // the bus id, which configurable and stored in settings
|
||||||
static uint8_t tx_state_; // state of the Tx line (NONE or waiting on a TX_READ or TX_WRITE)
|
static uint8_t tx_mode_; // local copy of the tx mode
|
||||||
|
static uint8_t tx_state_; // state of the Tx line (NONE or waiting on a TX_READ or TX_WRITE)
|
||||||
};
|
};
|
||||||
|
|
||||||
class RxService : public EMSbus {
|
class RxService : public EMSbus {
|
||||||
@@ -227,7 +228,8 @@ class RxService : public EMSbus {
|
|||||||
if (telegram_error_count_ == 0) {
|
if (telegram_error_count_ == 0) {
|
||||||
return 100; // all good, 100%
|
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 {
|
class QueuedRxTelegram {
|
||||||
@@ -247,6 +249,8 @@ class RxService : public EMSbus {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
static constexpr uint8_t EMS_BUS_QUALITY_RX_THRESHOLD = 5; // % threshold before reporting quality issues
|
||||||
|
|
||||||
uint8_t rx_telegram_id_ = 0; // queue counter
|
uint8_t rx_telegram_id_ = 0; // queue counter
|
||||||
uint32_t telegram_count_ = 0; // # Rx received
|
uint32_t telegram_count_ = 0; // # Rx received
|
||||||
uint32_t telegram_error_count_ = 0; // # Rx CRC errors
|
uint32_t telegram_error_count_ = 0; // # Rx CRC errors
|
||||||
|
|||||||
Reference in New Issue
Block a user