From 240d5cbd4b602e38f777c28450a8f287bd335208 Mon Sep 17 00:00:00 2001 From: Hendrik Groove Date: Fri, 19 Sep 2025 18:02:37 +0200 Subject: [PATCH] add slave response frame --- .../LinBusListener_esp32_arduino.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/components/truma_inetbox/LinBusListener_esp32_arduino.cpp b/components/truma_inetbox/LinBusListener_esp32_arduino.cpp index 690fb9d..4fc2100 100644 --- a/components/truma_inetbox/LinBusListener_esp32_arduino.cpp +++ b/components/truma_inetbox/LinBusListener_esp32_arduino.cpp @@ -92,6 +92,8 @@ bool LinBusListener::write_lin_master_frame_(uint8_t pid, const uint8_t *data, u auto uartComp = static_cast(this->parent_); auto uart_num = uartComp->get_hw_serial_number(); auto hw_serial = uartComp->get_hw_serial(); + + // Send master frame (break + sync + pid + data + crc) uart_send_break((uint8_t) uart_num); hw_serial->write(0x55); uint8_t pid_with_parity = (pid & 0x3F) | (addr_parity(pid) << 6); @@ -100,6 +102,23 @@ bool LinBusListener::write_lin_master_frame_(uint8_t pid, const uint8_t *data, u if (len > 0) hw_serial->write((uint8_t*)data, len); hw_serial->write(crc); hw_serial->flush(); + + // For diagnostic frames (0x3C), automatically schedule slave response (0x7D) + if (pid == 0x3C) { + // Small delay to allow slave processing time + delayMicroseconds(5000); // 5ms delay + + // Send response slot header (break + sync + 0x7D with parity) + uart_send_break((uint8_t) uart_num); + hw_serial->write(0x55); + uint8_t response_pid_with_parity = (0x7D & 0x3F) | (addr_parity(0x7D) << 6); + hw_serial->write(response_pid_with_parity); + hw_serial->flush(); + + // Note: We don't send data/CRC for response slot - slave will provide that + ESP_LOGD(TAG, "Scheduled 0x7D response slot after 0x3C diagnostic frame"); + } + return true; }