add slave response frame
This commit is contained in:
parent
3384c89475
commit
240d5cbd4b
@ -92,6 +92,8 @@ bool LinBusListener::write_lin_master_frame_(uint8_t pid, const uint8_t *data, u
|
|||||||
auto uartComp = static_cast<ESPHOME_UART *>(this->parent_);
|
auto uartComp = static_cast<ESPHOME_UART *>(this->parent_);
|
||||||
auto uart_num = uartComp->get_hw_serial_number();
|
auto uart_num = uartComp->get_hw_serial_number();
|
||||||
auto hw_serial = uartComp->get_hw_serial();
|
auto hw_serial = uartComp->get_hw_serial();
|
||||||
|
|
||||||
|
// Send master frame (break + sync + pid + data + crc)
|
||||||
uart_send_break((uint8_t) uart_num);
|
uart_send_break((uint8_t) uart_num);
|
||||||
hw_serial->write(0x55);
|
hw_serial->write(0x55);
|
||||||
uint8_t pid_with_parity = (pid & 0x3F) | (addr_parity(pid) << 6);
|
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);
|
if (len > 0) hw_serial->write((uint8_t*)data, len);
|
||||||
hw_serial->write(crc);
|
hw_serial->write(crc);
|
||||||
hw_serial->flush();
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user