Canbus - listen to all can_id

How do I listen to all can_id's? From the documentation I gather that setting can_id_mask to 0 should accomplish that, but in this case I get no messages at all.

Listening to specific can_id’s works as expected.

I too am trying to receive all can_id’s

Did you find a solution?

I’m wondering if it can be done in lambda, similar to sending via lambda

This works for me:

canbus:
  - platform: esp32_can
    tx_pin: GPIO25
    rx_pin: GPIO26
    can_id: 100       # can id for transmitting frames
    bit_rate: 250kbps # rv-c
    on_frame:
    - can_id:      0  # listen to all messages
      can_id_mask: 0
      use_extended_id: true
      then:
        - lambda: |-
            char buf[29];
            // DGN
            // Source Address (SA)
            // Priority
            // Data (8 bytes)
            int dgn = (can_id >>8) & 0x1ffff;
            int pri = (can_id >> 26) & 0b111;
            int sa  = can_id & 0xff;
            snprintf((char*)&buf, sizeof(buf), "%05X,%02X,%1X,%02X%02X%02X%02X%02X%02X%02X%02X", dgn, sa, pri, x[0], x[1], x[2], x[3], x[4], x[5], x[6], x[7]);
            id(rvc_rx).publish_state((const char*)&buf);
            ESP_LOGI("can", "%s", (const char*)&buf);
1 Like

it won’t work in 2024

Why won’t it work? no longer supported?

I’m interested in knowing how to do this as well, if using 0 isn’t the correct way anymore.