From 451c184dda06b57acdcb9f6b36a71f4fe46b0271 Mon Sep 17 00:00:00 2001 From: Hendrik Groove Date: Tue, 9 Sep 2025 11:57:14 +0200 Subject: [PATCH] truma_inetbox(stream): stream slave responses too (enqueue in ISR, format/send in background); tag MASTER/SLAVE --- components/truma_inetbox/LinBusListener.cpp | 9 ++++----- components/truma_inetbox/LinBusListener.h | 1 + 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/components/truma_inetbox/LinBusListener.cpp b/components/truma_inetbox/LinBusListener.cpp index 79e9d7c..13ae6e0 100644 --- a/components/truma_inetbox/LinBusListener.cpp +++ b/components/truma_inetbox/LinBusListener.cpp @@ -336,13 +336,14 @@ void LinBusListener::read_lin_frame_() { TRUMA_LOGV_ISR(log_msg); #endif // ESPHOME_LOG_HAS_VERBOSE - if (this->current_data_valid && message_from_master) { + if (this->current_data_valid) { QUEUE_LIN_MSG lin_msg; lin_msg.current_PID = this->current_PID_; - lin_msg.len = this->current_data_count_ - 1; + lin_msg.len = this->current_data_count_ - 1; // exclude CRC for (u_int8_t i = 0; i < lin_msg.len; i++) { lin_msg.data[i] = this->current_data_[i]; } + lin_msg.from_master = message_from_master ? 1 : 0; xQueueSendFromISR(this->lin_msg_queue_, (void *) &lin_msg, QUEUE_WAIT_DONT_BLOCK); } this->current_state_ = READ_STATE_BREAK; @@ -464,9 +465,7 @@ void LinBusListener::maybe_send_stream_from_lin_msg_(const QUEUE_LIN_MSG &lin_ms line += b; } } -#ifdef ESPHOME_LOG_HAS_VERBOSE - line += " MASTER"; // lin_msg comes from master orders -#endif + line += (lin_msg.from_master ? " MASTER" : " SLAVE"); line.push_back('\n'); this->stream_enqueue_line_(line); } diff --git a/components/truma_inetbox/LinBusListener.h b/components/truma_inetbox/LinBusListener.h index 293e75b..e009b45 100644 --- a/components/truma_inetbox/LinBusListener.h +++ b/components/truma_inetbox/LinBusListener.h @@ -33,6 +33,7 @@ struct QUEUE_LIN_MSG { u_int8_t current_PID; u_int8_t data[8]; u_int8_t len; + u_int8_t from_master; // 1 = master order, 0 = slave response }; class LinBusListener : public PollingComponent, public uart::UARTDevice {