From 910570cd0b7b5128686d02d121828406a356f1b4 Mon Sep 17 00:00:00 2001 From: ElVit Date: Mon, 23 Mar 2026 19:40:17 +0100 Subject: [PATCH 1/2] Revert "Do not chunk uart messages" This reverts commit 49067807071477d66f5e8cde66a52e24cdf1e974. --- components/panasonic_heatpump/helpers.cpp | 6 +++++- components/panasonic_heatpump/helpers.h | 4 ++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/components/panasonic_heatpump/helpers.cpp b/components/panasonic_heatpump/helpers.cpp index 29e5b71..a2fdaf8 100644 --- a/components/panasonic_heatpump/helpers.cpp +++ b/components/panasonic_heatpump/helpers.cpp @@ -32,7 +32,11 @@ void PanasonicHelpers::log_uart_hex(UartLogDirection direction, const uint8_t* d delay(10); logStr += byte_array_to_hex_string(data, length, separator); - ESP_LOGI(TAG, "%s %s", msgDir.c_str(), logStr.c_str()); + + for (size_t i = 0; i < logStr.length(); i += UART_LOG_CHUNK_SIZE) { + ESP_LOGI(TAG, "%s %s", msgDir.c_str(), logStr.substr(i, UART_LOG_CHUNK_SIZE).c_str()); + delay(10); + } } std::string PanasonicHelpers::byte_array_to_hex_string(const std::vector& data, const char separator) { diff --git a/components/panasonic_heatpump/helpers.h b/components/panasonic_heatpump/helpers.h index 042234a..af71f9c 100644 --- a/components/panasonic_heatpump/helpers.h +++ b/components/panasonic_heatpump/helpers.h @@ -5,6 +5,10 @@ #include #include +#ifndef UART_LOG_CHUNK_SIZE +#define UART_LOG_CHUNK_SIZE 120 +#endif + namespace esphome { namespace panasonic_heatpump { enum UartLogDirection : uint8_t { From 1410f1676edc495a778b72df6ac3aa5638be47f9 Mon Sep 17 00:00:00 2001 From: ElVit Date: Mon, 23 Mar 2026 19:49:00 +0100 Subject: [PATCH 2/2] Add comment to explain why chunking log messages --- components/panasonic_heatpump/helpers.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/components/panasonic_heatpump/helpers.cpp b/components/panasonic_heatpump/helpers.cpp index a2fdaf8..5546ea0 100644 --- a/components/panasonic_heatpump/helpers.cpp +++ b/components/panasonic_heatpump/helpers.cpp @@ -33,6 +33,8 @@ void PanasonicHelpers::log_uart_hex(UartLogDirection direction, const uint8_t* d logStr += byte_array_to_hex_string(data, length, separator); + // Log in chunks to avoid ESP_LOG buffer overflow (https://developers.esphome.io/architecture/logging/). + // The default log buffer is 512 bytes but UART messages can be larger (203 * 3 = 609 characters + log header). for (size_t i = 0; i < logStr.length(); i += UART_LOG_CHUNK_SIZE) { ESP_LOGI(TAG, "%s %s", msgDir.c_str(), logStr.substr(i, UART_LOG_CHUNK_SIZE).c_str()); delay(10);