Skip to content

Using latest ESP32 release files to load TWAI driver #2

@MarkRiddoch

Description

@MarkRiddoch

There has been a change in the TWAI driver in the latest release that means the library fails to log the TWAI driver. Th problem is that there are some extra options in the twai_general_config_t structure. This manifests itself with an illegal argument error response when calling twai_driver_install().

The fix is simple, in the begin() routine zero out the contents of g_config with a call to memset. This should be future proof in that any new things added will also get set to zero.

bool CBUSESP32::begin(bool poll, SPIClass& spi) {

  esp_err_t iret;

  _numMsgsSent = 0;
  _numMsgsRcvd = 0;

  // configure CAN bus driver
  twai_general_config_t g_config;
  
  memset(&g_config, 0, sizeof(g_config));       // Initialise all configuration 
                                 
  g_config.mode = TWAI_MODE_NORMAL;

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions