From c619701137ab6051b762cb3bb37d53222e19cde6 Mon Sep 17 00:00:00 2001 From: proddy Date: Thu, 4 Jun 2020 11:05:03 +0200 Subject: [PATCH] show tx fails in ems sub-menu --- src/emsesp.cpp | 22 +++++++++++----------- src/telegram.cpp | 9 ++++++--- src/telegram.h | 9 +++++++++ 3 files changed, 26 insertions(+), 14 deletions(-) diff --git a/src/emsesp.cpp b/src/emsesp.cpp index b1aa2ad0e..fd8da4e07 100644 --- a/src/emsesp.cpp +++ b/src/emsesp.cpp @@ -110,22 +110,22 @@ void EMSESP::trace_watch_id(uint16_t trace_watch_id) { } } -// show the Rx and Tx queues +// show the EMS bus status plus both Rx and Tx queues void EMSESP::show_emsbus(uuid::console::Shell & shell) { - // EMS bus specific + // EMS bus information if (rxservice_.bus_connected()) { uint8_t success_rate = 0; if (rxservice_.telegram_error_count()) { success_rate = ((float)rxservice_.telegram_error_count() / (float)rxservice_.telegram_count()) * 100; } - shell.printfln(F("EMS Bus protocol: %s, #telegrams received: %d, #Read requests sent: %d, #Write requests sent: %d, #CRC errors: %d (%d%%)"), - EMSbus::is_ht3() ? F("HT3") : F("Buderus"), - rxservice_.telegram_count(), - txservice_.telegram_read_count(), - txservice_.telegram_write_count(), - rxservice_.telegram_error_count(), - success_rate); + shell.printfln(F("EMS Bus info:")); + shell.printfln(F(" Bus protocol: %s"), EMSbus::is_ht3() ? F("HT3") : F("Buderus")); + shell.printfln(F(" #telegrams received: %d"), rxservice_.telegram_count()); + shell.printfln(F(" #read requests sent: %d"), txservice_.telegram_read_count()); + shell.printfln(F(" #write requests sent: %d"), txservice_.telegram_write_count()); + shell.printfln(F(" #CRC errors: %d (%d%%)"), rxservice_.telegram_error_count(), success_rate); + shell.printfln(F(" #Tx fails: %d"), txservice_.telegram_fail_count()); } else { shell.printfln(F("EMS Bus is disconnected")); } @@ -603,9 +603,9 @@ void EMSESP::incoming_telegram(uint8_t * data, const uint8_t length) { // So re-send the last Tx and increment retry count uint8_t retries = txservice_.retry_tx(); // returns 0 if exceeded count if (retries) { - LOG_ERROR(F("Last Tx read failed. Retrying #%d..."), retries); + LOG_ERROR(F("Last Tx operation failed. Retrying #%d..."), retries); } else { - LOG_ERROR(F("Last Tx read failed after %d retries. Abandoning Tx operation."), txservice_.MAXIMUM_TX_RETRIES); + LOG_ERROR(F("Last Tx operation failed after %d retries. Ignoring request."), txservice_.MAXIMUM_TX_RETRIES); } return; diff --git a/src/telegram.cpp b/src/telegram.cpp index 66420ea93..3187a64cd 100644 --- a/src/telegram.cpp +++ b/src/telegram.cpp @@ -611,10 +611,13 @@ void TxService::remember_tx(const uint8_t * data, const uint8_t length) { // returns retry count, or 0 if all done uint8_t TxService::retry_tx() { if (++retry_count_ == MAXIMUM_TX_RETRIES) { - reset_retry_count(); // give up - } else { - add(telegram_last_, telegram_last_length_); // add the last Tx telegram to the tx queue, at the top + reset_retry_count(); // give up + increment_telegram_fail_count(); // another Tx fail + return 0; } + + add(telegram_last_, telegram_last_length_); // add the last Tx telegram to the tx queue, at the top + return retry_count_; } diff --git a/src/telegram.h b/src/telegram.h index ef6129b21..4c8608d82 100644 --- a/src/telegram.h +++ b/src/telegram.h @@ -270,6 +270,14 @@ class TxService : public EMSbus { telegram_read_count_++; } + uint16_t telegram_fail_count() const { + return telegram_fail_count_; + } + + void increment_telegram_fail_count() { + telegram_fail_count_++; + } + uint16_t telegram_write_count() const { return telegram_write_count_; } @@ -312,6 +320,7 @@ class TxService : public EMSbus { const std::shared_ptr telegram_last; // copy of last telegram uint16_t telegram_read_count_ = 0; // # Tx successful reads uint16_t telegram_write_count_ = 0; // # Tx successful writes + uint16_t telegram_fail_count_ = 0; // # Tx unsuccessful transmits uint8_t retry_count_ = 0; // count for # Tx retries