From 05741687d26b48db37ab0277c0a4d26d03a0a54a Mon Sep 17 00:00:00 2001 From: Florian Date: Mon, 23 Sep 2024 01:38:55 +0200 Subject: [PATCH] Fix --- components/tc_bus/tc_bus.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/components/tc_bus/tc_bus.cpp b/components/tc_bus/tc_bus.cpp index 38a05eb..c910604 100644 --- a/components/tc_bus/tc_bus.cpp +++ b/components/tc_bus/tc_bus.cpp @@ -315,7 +315,10 @@ namespace esphome ESP_LOGD(TAG, "Reading EEPROM: Received 4 Blocks starting at: %i", (reading_eeprom_count_ * 4)); // Save Data to EEPROM Store - eeprom_buffer_.insert(eeprom_buffer_.end(), reinterpret_cast(&command), reinterpret_cast(&command) + sizeof(command)); + eeprom_buffer_.push_back((command >> 24) & 0xFF); + eeprom_buffer_.push_back((command >> 16) & 0xFF); + eeprom_buffer_.push_back((command >> 8) & 0xFF); + eeprom_buffer_.push_back(command & 0xFF); // Next 4 Data Blocks reading_eeprom_count_++; @@ -325,12 +328,12 @@ namespace esphome // Turn off reading_eeprom_ = false; - std::string hexString(eeprom_buffer_.size() * 2, ' '); // Reserviere den String mit fester Größe + std::string hexString; + hexString.reserve(eeprom_buffer_.size() * 2); for (std::size_t i = 0; i < eeprom_buffer_.size(); ++i) { - uint8_t byte = eeprom_buffer_[i]; - hexString += format_hex(byte); + hexString += format_hex(eeprom_buffer_[i]); } ESP_LOGD(TAG, "Reading EEPROM: Count: %i, Result: %s", eeprom_buffer_.size(), hexString.c_str());