KITmedical / kacanopen

Easy-to-use CanOpen stack and CanOpen-to-ROS bridge.
Other
93 stars 57 forks source link

In certain cases, sdo will trigger "received_unassigned_sdo" #29

Open LoopholesInTheHeart opened 2 years ago

LoopholesInTheHeart commented 2 years ago

In type SDOResponse , the data from "Message" to "SDOResponse ", the data size from "8" to "7". but in file "sdo_response.cpp", in fuc " SDOResponse::get_index()" , The message-based 8-data approach is still used. This brings up some issues regarding the handling and alignment of SDO messages.

My solution is to make the data size in SDOResponse 8-byte base as well, and change func "SDOResponse::get_data()" to

uint32_t SDOResponse::get_data() const { const uint8_t dataIndex = 4; return (((uint32_t)data[dataIndex + 3]) << 24) + (((uint32_t)data[dataIndex + 2]) << 16) + (((uint32_t)data[dataIndex + 1]) << 8) + (uint32_t)data[dataIndex + 0]; }

There are other minor changes along the way in other functions , For example, change the boundary from "i < 7" to "i < = 7"