From 7b9e70770965013443fbe521e1bbe93050e7239b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gu=C3=B0ni=20M=C3=A1r=20Gilbert?= Date: Wed, 18 Oct 2023 23:25:17 +0000 Subject: [PATCH] mmu: add ResetCommunicationTimeoutAttempts Adding __attribute__((noinline)) saves 14 bytes of flash Change in memory: Flash: +34 bytes SRAM: 0 bytes --- Firmware/mmu2.cpp | 2 +- Firmware/mmu2_protocol_logic.cpp | 9 +++++++-- Firmware/mmu2_protocol_logic.h | 2 ++ 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/Firmware/mmu2.cpp b/Firmware/mmu2.cpp index 6bd6f1605..ced863fe0 100644 --- a/Firmware/mmu2.cpp +++ b/Firmware/mmu2.cpp @@ -63,8 +63,8 @@ void MMU2::Start() { // start the communication logic.Start(); - logic.ResetRetryAttempts(); + logic.ResetCommunicationTimeoutAttempts(); } void MMU2::Stop() { diff --git a/Firmware/mmu2_protocol_logic.cpp b/Firmware/mmu2_protocol_logic.cpp index 77a0da950..65b5a4115 100644 --- a/Firmware/mmu2_protocol_logic.cpp +++ b/Firmware/mmu2_protocol_logic.cpp @@ -256,7 +256,7 @@ StepStatus ProtocolLogic::ProcessVersionResponse(uint8_t stage) { SendVersion(stage); } } else { - dataTO.Reset(); // got a meaningful response from the MMU, stop data layer timeout tracking + ResetCommunicationTimeoutAttempts(); // got a meaningful response from the MMU, stop data layer timeout tracking SendVersion(stage + 1); } } @@ -774,7 +774,7 @@ void ProtocolLogic::LogResponse() { StepStatus ProtocolLogic::SuppressShortDropOuts(const char *msg_P, StepStatus ss) { if (dataTO.Record(ss)) { LogError(msg_P); - dataTO.Reset(); // prepare for another run of consecutive retries before firing an error + ResetCommunicationTimeoutAttempts(); // prepare for another run of consecutive retries before firing an error return dataTO.InitialCause(); } else { return Processing; // suppress short drop outs of communication @@ -865,6 +865,11 @@ void ProtocolLogic::ResetRetryAttempts() { retryAttempts = MAX_RETRIES; } +void __attribute__((noinline)) ProtocolLogic::ResetCommunicationTimeoutAttempts() { + SERIAL_ECHOLNPGM("RSTCommTimeout"); + dataTO.Reset(); +} + bool DropOutFilter::Record(StepStatus ss) { if (occurrences == maxOccurrences) { cause = ss; diff --git a/Firmware/mmu2_protocol_logic.h b/Firmware/mmu2_protocol_logic.h index bf884106b..6e46360ed 100644 --- a/Firmware/mmu2_protocol_logic.h +++ b/Firmware/mmu2_protocol_logic.h @@ -186,6 +186,8 @@ public: /// Reset the retryAttempts back to the default value void ResetRetryAttempts(); + void ResetCommunicationTimeoutAttempts(); + constexpr bool InAutoRetry() const { return inAutoRetry; } void SetInAutoRetry(bool iar) { inAutoRetry = iar;