ros-industrial / ros_canopen

CANopen driver framework for ROS (http://wiki.ros.org/ros_canopen)
GNU Lesser General Public License v3.0
328 stars 267 forks source link

Subindex parsing doesn't abide by standard, misses parsing arrays that have skipped subindices #445

Open oren-hinkis opened 2 years ago

oren-hinkis commented 2 years ago

According to the standard, SubNumber indicates the total number of available objects in the array but doesn't indicate the highest subindex that is available. That is supposed to be give in the value of the sub0 object of that array.

image

However, the code uses the SubNumber as the variable to parse the array. This leads to issues in cases where a sub number is skipped in the EDS read_integer(subs, *object, "SubNumber"); for(uint8_t i=0; i < subs; ++i){}

https://www.can-cia.org/can-knowledge/canopen/cia306/

mathias-luedtke commented 2 years ago

Good point!

A fix should not be too hard: The code needs to iterate SubNumber times between 0 and sub0.