Ignore the most significant bit in PDO mapping lengths #421
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The maximum size of a PDO is 64 bits = 0x40. Any higher value is per definition invalid, so the highest bit is definitely unused.
This prompted at least one device manufacturer (miControl GmbH) to utilize this bit for their own purpose. They state in their manual that the device supports only the following lengths: 8 (0x08), 16 (0x10), 32 (0x20) bits. However, the device allows setting the highest bit as well, to indicate the mapping concerns a signed variable. This triggers the appropriate sign bit padding when receiving the value, as all internal variable accesses are handled as INTEGER32.
When such a PDO mapping is read in, the total PDO size calculation in the canopen library fails badly. Thus the easy fix is to just always mask out that highest bit, which is never a meaningful part of the length field.