fix(c++): remove stray CRLF escapes and place write_lin_master_frame_ inside namespaces
This commit is contained in:
parent
8db35ea7a5
commit
891d3c59e8
@ -1,4 +1,4 @@
|
|||||||
#ifdef USE_ESP32_FRAMEWORK_ARDUINO
|
#ifdef USE_ESP32_FRAMEWORK_ARDUINO
|
||||||
#include "LinBusListener.h"
|
#include "LinBusListener.h"
|
||||||
#include "esphome/core/log.h"
|
#include "esphome/core/log.h"
|
||||||
#include "driver/uart.h"
|
#include "driver/uart.h"
|
||||||
@ -77,6 +77,24 @@ void LinBusListener::eventTask_(void *args) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool LinBusListener::write_lin_master_frame_(uint8_t pid, const uint8_t *data, uint8_t len) {
|
||||||
|
if (!this->master_mode_) return false;
|
||||||
|
if (len > 8) return false;
|
||||||
|
auto uartComp = static_cast<ESPHOME_UART *>(this->parent_);
|
||||||
|
auto uart_num = uartComp->get_hw_serial_number();
|
||||||
|
auto hw_serial = uartComp->get_hw_serial();
|
||||||
|
uart_tx_break((uart_port_t) uart_num, 13);
|
||||||
|
hw_serial->write(0x55);
|
||||||
|
uint8_t pid_with_parity = (pid & 0x3F) | (addr_parity(pid) << 6);
|
||||||
|
hw_serial->write(pid_with_parity);
|
||||||
|
uint8_t crc = data_checksum(data, len, 0);
|
||||||
|
if (len > 0) hw_serial->write((uint8_t*)data, len);
|
||||||
|
hw_serial->write(crc);
|
||||||
|
hw_serial->flush();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace truma_inetbox
|
} // namespace truma_inetbox
|
||||||
} // namespace esphome
|
} // namespace esphome
|
||||||
|
|
||||||
@ -84,27 +102,3 @@ void LinBusListener::eventTask_(void *args) {
|
|||||||
#undef ESPHOME_UART
|
#undef ESPHOME_UART
|
||||||
|
|
||||||
#endif // USE_ESP32_FRAMEWORK_ARDUINO
|
#endif // USE_ESP32_FRAMEWORK_ARDUINO
|
||||||
bool LinBusListener::write_lin_master_frame_(uint8_t pid, const uint8_t *data, uint8_t len) {
|
|
||||||
if (!this->master_mode_) return false;
|
|
||||||
if (len > 8) return false;
|
|
||||||
auto uartComp = static_cast<ESPHOME_UART *>(this->parent_);
|
|
||||||
auto uart_num = uartComp->get_hw_serial_number();
|
|
||||||
auto hw_serial = uartComp->get_hw_serial();
|
|
||||||
|
|
||||||
// Send BREAK using ESP-IDF uart driver, then SYNC (0x55), PID, data, checksum
|
|
||||||
// Best effort: not all cores expose the same API; try common call.
|
|
||||||
// Begin BREAK
|
|
||||||
uart_tx_break((uart_port_t) uart_num, 13);
|
|
||||||
// SYNC
|
|
||||||
hw_serial->write(0x55);
|
|
||||||
// PID with parity (upper 2 bits)
|
|
||||||
uint8_t pid_with_parity = (pid & 0x3F) | (addr_parity(pid) << 6);
|
|
||||||
hw_serial->write(pid_with_parity);
|
|
||||||
|
|
||||||
// Data
|
|
||||||
uint8_t crc = data_checksum(data, len, 0);
|
|
||||||
if (len > 0) hw_serial->write((uint8_t*)data, len);
|
|
||||||
hw_serial->write(crc);
|
|
||||||
hw_serial->flush();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|||||||
@ -38,7 +38,8 @@ void TrumaiNetBoxApp::update() {
|
|||||||
this->write_lin_master_frame_(req.pid, req.data, req.len);
|
this->write_lin_master_frame_(req.pid, req.data, req.len);
|
||||||
this->last_master_send_us_ = now;
|
this->last_master_send_us_ = now;
|
||||||
}
|
}
|
||||||
}\r\n#ifdef USE_TIME
|
}
|
||||||
|
#ifdef USE_TIME
|
||||||
// Update time of CP Plus automatically when
|
// Update time of CP Plus automatically when
|
||||||
// - Time component configured
|
// - Time component configured
|
||||||
// - Update was not done
|
// - Update was not done
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user