Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Skip the "highest subindex" entry when iterating over SdoRecord #538

Merged
merged 11 commits into from
Aug 17, 2024

Conversation

acolomb
Copy link
Collaborator

@acolomb acolomb commented Aug 16, 2024

The count entry itself is not part of the data (according to CiA 301), thus should not be yielded from an iterator. That matches the behavior of SdoArray, which also yields only the array contents.

Note that the basis of returned record sub-objects is still the subset described by the OD, which might be smaller than the actual entries accessible on the node, and less than indicated by the record's subindex 0. Thus the count (and iteration set) is reduced by one element only if the subindex 0 was actually part of this subset.

This supersedes PR #430, with the alternative approach justified in the last comment there.

The count entry itself is not part of the data (according to CiA 301),
thus should not be yielded from an iterator.  That matches the
behavior of SdoArray, which also yields only the array contents.

Note that the basis of returned record sub-objects is still the subset
described by the OD, which might be smaller than the actual entries
accessible on the node, and less than indicated by the record's
subindex 0.  Thus the count (and iteration set) is reduced by one
element only if the subindex 0 was actually part of this subset.
@codecov-commenter
Copy link

codecov-commenter commented Aug 16, 2024

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 71.16%. Comparing base (273bab1) to head (5eb88d7).

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #538   +/-   ##
=======================================
  Coverage   71.16%   71.16%           
=======================================
  Files          26       26           
  Lines        3114     3114           
  Branches      527      527           
=======================================
  Hits         2216     2216           
  Misses        766      766           
  Partials      132      132           
Files Coverage Δ
canopen/sdo/base.py 82.79% <100.00%> (ø)

Copy link
Contributor

@erlend-aasland erlend-aasland left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider to also update doc/sdo.rst with a sentence or two similar to the added code comments.

Also, it would be nice with test for this, and by that I mean preferably to add those tests first (in a separate PR), followed by the behavioural changes (this PR) coupled with amendments to the (presumably broken) tests.

Adjust the EDS test accordingly, since the record length only counts
sub-objects that have an actual description.
Switch from CompactSubObj to actual sub-entries.  Leave out some of
the sub-entries, targeting specific SDO tests.
@acolomb
Copy link
Collaborator Author

acolomb commented Aug 17, 2024

All comments addressed, see #539.

Copy link
Contributor

@erlend-aasland erlend-aasland left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! I can confirm that the added tests cover the affected lines, and that test_record_iter_length expectedly fails if applied on master.

Copy link
Contributor

@erlend-aasland erlend-aasland left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀

@acolomb acolomb merged commit 6bc90a8 into christiansandberg:master Aug 17, 2024
3 checks passed
@acolomb acolomb deleted the sdorecord-skip-count branch August 17, 2024 21:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants