Skip to content

ESP IDF < 5.2 Compatibility #79

@jeroenveer

Description

@jeroenveer

bus_handle = nullptr; gives a build error if the IDF is lower than 5.2.
To fix it, check the IDF version:

#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 2, 0)
    bus_handle = nullptr;
#endif

esp32_can_buildin.cpp:

ESP32CAN::ESP32CAN(gpio_num_t rxPin, gpio_num_t txPin, uint8_t busNumber) : CAN_COMMON(32)
{
    twai_general_cfg.rx_io = rxPin;
    twai_general_cfg.tx_io = txPin;
    cyclesSinceTraffic = 0;
    readyForTraffic = false;
    twai_general_cfg.tx_queue_len = BI_TX_BUFFER_SIZE;
    twai_general_cfg.rx_queue_len = 6;
    rxBufferSize = BI_RX_BUFFER_SIZE;
    
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 2, 0)
    bus_handle = nullptr;
    twai_general_cfg.controller_id = busNumber;
#endif
}

ESP32CAN::ESP32CAN() : CAN_COMMON(BI_NUM_FILTERS) 
{
    twai_general_cfg.tx_queue_len = BI_TX_BUFFER_SIZE;
    twai_general_cfg.rx_queue_len = 6;
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 2, 0)
    bus_handle = nullptr;
#endif

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions