mirror of
https://github.com/esphome/esphome.git
synced 2025-03-15 07:08:20 +00:00
add logging for debugging
This commit is contained in:
parent
c592f57cce
commit
d2c812cdaa
@ -36,10 +36,17 @@ void Canbus::send_data(uint32_t can_id, const std::vector<uint8_t> data) {
|
|||||||
|
|
||||||
void Canbus::loop() {
|
void Canbus::loop() {
|
||||||
struct can_frame can_message;
|
struct can_frame can_message;
|
||||||
this->read_message_(&can_message);
|
//readmessage
|
||||||
for(auto trigger: this->triggers_){
|
if( this->read_message_(&can_message) == canbus::ERROR_OK ) {
|
||||||
if(trigger->can_id_ == can_message.can_id) {
|
ESP_LOGD(TAG,"received can message can_id=%04x length=%d",can_message.can_id, can_message.can_dlc);
|
||||||
trigger->trigger();
|
//show data received
|
||||||
|
for(int i = 0; i< can_message.can_dlc;i++)
|
||||||
|
ESP_LOGD(TAG,"data[%d]=%02x",i, can_message.data[i]);
|
||||||
|
//fire all triggers
|
||||||
|
for(auto trigger: this->triggers_){
|
||||||
|
if(trigger->can_id_ == can_message.can_id) {
|
||||||
|
trigger->trigger();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user