From 8807780b550a630c2fc75044a24b6242aa6c9fd1 Mon Sep 17 00:00:00 2001 From: mumpf Date: Mon, 20 Mar 2023 14:41:31 +0100 Subject: [PATCH] FIX: occasional endless loop (wrong buffer limit) (#234) Co-authored-by: Waldemar Porscha --- src/knx/tpuart_data_link_layer.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/knx/tpuart_data_link_layer.cpp b/src/knx/tpuart_data_link_layer.cpp index 1de2eb2..1fafce5 100644 --- a/src/knx/tpuart_data_link_layer.cpp +++ b/src/knx/tpuart_data_link_layer.cpp @@ -335,7 +335,7 @@ void TpUartDataLinkLayer::loop() #ifdef DBG_TRACE print(rxByte, HEX); #endif - if (_RxByteCnt == MAX_KNX_TELEGRAM_SIZE) + if (_RxByteCnt == MAX_KNX_TELEGRAM_SIZE - 2) { println("invalid telegram size"); enterRxWaitEOP(); @@ -401,6 +401,8 @@ void TpUartDataLinkLayer::loop() } break; default: + println("invalid _rxState"); + enterRxWaitEOP(); break; } } while (_rxState == RX_L_ADDR && (stayInRx || _platform.uartAvailable()));