Skip to content

CanSDO getValue assumes next message is the response. #10

Description

@jamiejones85
double GetValue(String name) {
    if (state != IDLE) return 0;
 
    twai_message_t rxframe;
  
    int id = getId(name);
  
    requestSdoElement(SDO_INDEX_PARAM_UID | (id >> 8), id & 0xFF);
  
    if (twai_receive(&rxframe, pdMS_TO_TICKS(10)) == ESP_OK) {
      if (rxframe.data[0] == 0x80)
        return 0;
      else
        return ((double)*(uint32_t*)&rxframe.data[4]) / 32;
    }
    else {
      return 0;
    }
}

It doesn't check the ID of the received can message is an SDO response, if it's a response for the requested parameter ID etc

Metadata

Metadata

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions