Skip to content

PdoBase: Forbid getting item with zero index (fixes #581) #609

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

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

acolomb
Copy link
Member

@acolomb acolomb commented Aug 5, 2025

The PdoBase mapping uses an enumeration starting from one for the individual PDOs. Requesting index 0 (zero) accidentally will return the first PdoVariable in the first PDO. This is coincidental, because the PDOs are tried in turn and with a PDO, the numeric index lookup is zero-based.

To avoid hard-to-debug errors, simply forbid the value zero completely in the lookup, which does not make sense for any of the supported lookup methods.

Copy link

codecov bot commented Aug 5, 2025

Codecov Report

❌ Patch coverage is 72.72727% with 3 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
canopen/pdo/base.py 72.72% 1 Missing and 2 partials ⚠️

📢 Thoughts on this report? Let us know!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant