truma_inetbox(stream): stream slave responses too (enqueue in ISR, format/send in background); tag MASTER/SLAVE

This commit is contained in:
Hendrik Groove 2025-09-09 11:57:14 +02:00
parent 7248f611df
commit 451c184dda
2 changed files with 5 additions and 5 deletions

View File

@ -336,13 +336,14 @@ void LinBusListener::read_lin_frame_() {
TRUMA_LOGV_ISR(log_msg); TRUMA_LOGV_ISR(log_msg);
#endif // ESPHOME_LOG_HAS_VERBOSE #endif // ESPHOME_LOG_HAS_VERBOSE
if (this->current_data_valid && message_from_master) { if (this->current_data_valid) {
QUEUE_LIN_MSG lin_msg; QUEUE_LIN_MSG lin_msg;
lin_msg.current_PID = this->current_PID_; 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++) { for (u_int8_t i = 0; i < lin_msg.len; i++) {
lin_msg.data[i] = this->current_data_[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); xQueueSendFromISR(this->lin_msg_queue_, (void *) &lin_msg, QUEUE_WAIT_DONT_BLOCK);
} }
this->current_state_ = READ_STATE_BREAK; 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; line += b;
} }
} }
#ifdef ESPHOME_LOG_HAS_VERBOSE line += (lin_msg.from_master ? " MASTER" : " SLAVE");
line += " MASTER"; // lin_msg comes from master orders
#endif
line.push_back('\n'); line.push_back('\n');
this->stream_enqueue_line_(line); this->stream_enqueue_line_(line);
} }

View File

@ -33,6 +33,7 @@ struct QUEUE_LIN_MSG {
u_int8_t current_PID; u_int8_t current_PID;
u_int8_t data[8]; u_int8_t data[8];
u_int8_t len; u_int8_t len;
u_int8_t from_master; // 1 = master order, 0 = slave response
}; };
class LinBusListener : public PollingComponent, public uart::UARTDevice { class LinBusListener : public PollingComponent, public uart::UARTDevice {