mirror of
https://github.com/esphome/esphome.git
synced 2024-12-22 21:44:55 +01:00
CAN bus: read all queued messages (#3194)
This commit is contained in:
parent
5a0b8328d8
commit
c054fb8a2c
1 changed files with 6 additions and 4 deletions
|
@ -56,13 +56,15 @@ void Canbus::add_trigger(CanbusTrigger *trigger) {
|
||||||
|
|
||||||
void Canbus::loop() {
|
void Canbus::loop() {
|
||||||
struct CanFrame can_message;
|
struct CanFrame can_message;
|
||||||
// readmessage
|
// read all messages until queue is empty
|
||||||
if (this->read_message(&can_message) == canbus::ERROR_OK) {
|
int message_counter = 0;
|
||||||
|
while (this->read_message(&can_message) == canbus::ERROR_OK) {
|
||||||
|
message_counter++;
|
||||||
if (can_message.use_extended_id) {
|
if (can_message.use_extended_id) {
|
||||||
ESP_LOGD(TAG, "received can message extended can_id=0x%x size=%d", can_message.can_id,
|
ESP_LOGD(TAG, "received can message (#%d) extended can_id=0x%x size=%d", message_counter, can_message.can_id,
|
||||||
can_message.can_data_length_code);
|
can_message.can_data_length_code);
|
||||||
} else {
|
} else {
|
||||||
ESP_LOGD(TAG, "received can message std can_id=0x%x size=%d", can_message.can_id,
|
ESP_LOGD(TAG, "received can message (#%d) std can_id=0x%x size=%d", message_counter, can_message.can_id,
|
||||||
can_message.can_data_length_code);
|
can_message.can_data_length_code);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue