Commit 96b83e3 1 parent e21ad6a commit 96b83e3 Copy full SHA for 96b83e3
File tree 2 files changed +14
-5
lines changed
2 files changed +14
-5
lines changed Original file line number Diff line number Diff line change @@ -196,19 +196,21 @@ uint8_t EMSESP::bus_status() {
196
196
// check if we have Tx issues.
197
197
uint32_t total_sent = txservice_.telegram_read_count () + txservice_.telegram_write_count ();
198
198
199
- // nothing sent successfully, also no errors - must be ok
199
+ // nothing sent and also no errors - must be ok
200
200
if ((total_sent == 0 ) && (txservice_.telegram_fail_count () == 0 )) {
201
201
return BUS_STATUS_CONNECTED;
202
202
}
203
203
204
- // nothing sent successfully , but have Tx errors
204
+ // nothing sent, but have Tx errors
205
205
if ((total_sent == 0 ) && (txservice_.telegram_fail_count () != 0 )) {
206
206
return BUS_STATUS_TX_ERRORS;
207
207
}
208
208
209
- // Tx Failure rate > 5%
210
- if (((txservice_.telegram_fail_count () * 100 ) / total_sent) > EMSbus::EMS_TX_ERROR_LIMIT) {
211
- return BUS_STATUS_TX_ERRORS;
209
+ // Tx Failure rate > 10%
210
+ if (txservice_.telegram_fail_count () < total_sent) {
211
+ if (((txservice_.telegram_fail_count () * 100 ) / total_sent) > EMSbus::EMS_TX_ERROR_LIMIT) {
212
+ return BUS_STATUS_TX_ERRORS;
213
+ }
212
214
}
213
215
214
216
return BUS_STATUS_CONNECTED;
Original file line number Diff line number Diff line change @@ -218,7 +218,11 @@ class RxService : public EMSbus {
218
218
if (telegram_error_count_ == 0 ) {
219
219
return 100 ; // all good, 100%
220
220
}
221
+ if (telegram_error_count_ >= telegram_count_) {
222
+ return 100 ;
223
+ }
221
224
uint8_t q = ((float )telegram_error_count_ / telegram_count_ * 100 );
225
+
222
226
return (q <= EMS_BUS_QUALITY_RX_THRESHOLD ? 100 : 100 - q);
223
227
}
224
228
@@ -308,6 +312,9 @@ class TxService : public EMSbus {
308
312
if (telegram_fail_count_ == 0 ) {
309
313
return 100 ; // all good, 100%
310
314
}
315
+ if (telegram_fail_count_ >= telegram_read_count_) {
316
+ return 100 ;
317
+ }
311
318
return (100 - (uint8_t )(((float )telegram_fail_count_ / telegram_read_count_ * 100 )));
312
319
}
313
320
You can’t perform that action at this time.
0 commit comments