Compare commits
No commits in common. "451c184dda06b57acdcb9f6b36a71f4fe46b0271" and "02cafc62ddaafc7304c4e03cfcb981f1153c0228" have entirely different histories.
451c184dda
...
02cafc62dd
@ -336,14 +336,13 @@ void LinBusListener::read_lin_frame_() {
|
||||
TRUMA_LOGV_ISR(log_msg);
|
||||
#endif // ESPHOME_LOG_HAS_VERBOSE
|
||||
|
||||
if (this->current_data_valid) {
|
||||
if (this->current_data_valid && message_from_master) {
|
||||
QUEUE_LIN_MSG lin_msg;
|
||||
lin_msg.current_PID = this->current_PID_;
|
||||
lin_msg.len = this->current_data_count_ - 1; // exclude CRC
|
||||
lin_msg.len = this->current_data_count_ - 1;
|
||||
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;
|
||||
@ -359,10 +358,6 @@ void LinBusListener::clear_uart_buffer_() {
|
||||
void LinBusListener::process_lin_msg_queue(TickType_t xTicksToWait) {
|
||||
QUEUE_LIN_MSG lin_msg;
|
||||
while (xQueueReceive(this->lin_msg_queue_, &lin_msg, xTicksToWait) == pdPASS) {
|
||||
#ifdef USE_ESP32
|
||||
// Also forward master frames to UDP stream regardless of logger level
|
||||
this->maybe_send_stream_from_lin_msg_(lin_msg);
|
||||
#endif
|
||||
this->lin_message_recieved_(lin_msg.current_PID, lin_msg.data, lin_msg.len);
|
||||
}
|
||||
}
|
||||
@ -443,32 +438,6 @@ void LinBusListener::process_log_queue(TickType_t xTicksToWait) {
|
||||
}
|
||||
|
||||
#ifdef USE_ESP32
|
||||
void LinBusListener::maybe_send_stream_from_lin_msg_(const QUEUE_LIN_MSG &lin_msg) {
|
||||
if (!this->stream_enabled_) return;
|
||||
if (this->udp_sock_ < 0) this->stream_try_init_();
|
||||
if (this->udp_sock_ < 0) return;
|
||||
const uint8_t pid = lin_msg.current_PID;
|
||||
if (this->stream_diag_only_ && !(pid == DIAGNOSTIC_FRAME_MASTER || pid == DIAGNOSTIC_FRAME_SLAVE)) {
|
||||
return;
|
||||
}
|
||||
std::string line;
|
||||
line.reserve(64);
|
||||
char head[16];
|
||||
snprintf(head, sizeof(head), "PID %02X ", pid);
|
||||
line += head;
|
||||
// Local hex format to avoid dependency on verbose-only helper
|
||||
{
|
||||
char b[4];
|
||||
for (uint8_t i = 0; i < lin_msg.len; i++) {
|
||||
if (!line.empty() && line.back() != ' ') line.push_back(' ');
|
||||
snprintf(b, sizeof(b), "%02X", lin_msg.data[i]);
|
||||
line += b;
|
||||
}
|
||||
}
|
||||
line += (lin_msg.from_master ? " MASTER" : " SLAVE");
|
||||
line.push_back('\n');
|
||||
this->stream_enqueue_line_(line);
|
||||
}
|
||||
void LinBusListener::stream_send_test(const std::string &line) {
|
||||
if (!this->stream_enabled_) return;
|
||||
if (this->udp_sock_ < 0) this->stream_try_init_();
|
||||
|
||||
@ -33,7 +33,6 @@ 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 {
|
||||
@ -152,7 +151,6 @@ class LinBusListener : public PollingComponent, public uart::UARTDevice {
|
||||
void stream_try_init_();
|
||||
void stream_maybe_keepalive_();
|
||||
void stream_enqueue_line_(const std::string &line);
|
||||
void maybe_send_stream_from_lin_msg_(const QUEUE_LIN_MSG &lin_msg);
|
||||
|
||||
uint8_t lin_msg_static_queue_storage[TRUMA_MSG_QUEUE_LENGTH * sizeof(QUEUE_LIN_MSG)];
|
||||
StaticQueue_t lin_msg_static_queue_;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user