You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The __getitem__ implementation for PdoBase has following check:
ifisinstance(key, int) and (0x1A00<=key<=0x1BFFor# By TPDO ID (512)0x1600<=key<=0x17FFor# By RPDO ID (512)0<key<=512): # By PDO Indexreturnself.map[key]
Suggesting that one could get the PDO with the Mapping Parameter Index
you see that the key is a normal index counting up the PdoMap added. So an access by the Mapping Parameter isn't possible.
Additionally I think an access via the Communication Parameter in addition to the Mapping Parameter could make sense. Either way, either the check in the PdoBase needs to be redacted to only check 0 < key <= 512 or (what I think makes more sense) the __getitem__ in PdoMaps needs to be changed.
This was previously reported in #581 and a (partial) fix is up for review in #602. Please chime in there, whether the approach would suit you.
Looking at the code again, we really do seem to be missing the actual code to support looking up by parameter object index (0x1400, 0x1600, etc.). Even though it doesn't work right now (maybe it did at some point and we have a regression?), I think we should keep the mechanism as it's cheap to implement. We can just add the same PdoMap object to the PdoMaps collection under different keys. Just need to filter when getting an iterator, so the PdoMap objects are not returned multiple times.
And we should definitely add some unit tests regarding the lookup by parameter object index. Will resume work on this when time permits.
No PR #613 is not fully production-ready. Although PdoBase.getitem allows access using mapping and communication parameter record IDs (such as 0x1600 and 0x1A00), PdoMaps.getitem still performs a direct dictionary lookup without translating these record IDs into internal indices. The maps dictionary is populated only with sequential keys (1 to 512), so lookups using record IDs will fail. This means the fix is incomplete and the advertised functionality is not actually implemented, making the solution incorrect and not production-ready.
@dihjaywyper if you want to talk about actual issues, please look at the most recent commit and do your homework. Happy to discuss any issues you find, filed as such on GitHub. But please don't abuse this issue with outdated comments.
Activity
acolomb commentedon Aug 1, 2025
This was previously reported in #581 and a (partial) fix is up for review in #602. Please chime in there, whether the approach would suit you.
Looking at the code again, we really do seem to be missing the actual code to support looking up by parameter object index (0x1400, 0x1600, etc.). Even though it doesn't work right now (maybe it did at some point and we have a regression?), I think we should keep the mechanism as it's cheap to implement. We can just add the same
PdoMapobject to thePdoMapscollection under different keys. Just need to filter when getting an iterator, so thePdoMapobjects are not returned multiple times.And we should definitely add some unit tests regarding the lookup by parameter object index. Will resume work on this when time permits.
acolomb commentedon Aug 5, 2025
Please refer to #609 now, which supersedes #602. Had to reopen the PR to target the master branch.
Fix and extend PDO selection by record IDs (fixes canopen-python#607) (…
Fix and extend PDO selection by record IDs (fixes canopen-python#607)
dihjaywyper commentedon Apr 3, 2026
No PR #613 is not fully production-ready. Although PdoBase.getitem allows access using mapping and communication parameter record IDs (such as 0x1600 and 0x1A00), PdoMaps.getitem still performs a direct dictionary lookup without translating these record IDs into internal indices. The maps dictionary is populated only with sequential keys (1 to 512), so lookups using record IDs will fail. This means the fix is incomplete and the advertised functionality is not actually implemented, making the solution incorrect and not production-ready.
Fix issue canopen-python#607: Support lookup by record IDs
acolomb commentedon Apr 7, 2026
@dihjaywyper if you want to talk about actual issues, please look at the most recent commit and do your homework. Happy to discuss any issues you find, filed as such on GitHub. But please don't abuse this issue with outdated comments.
pdo: fix index access via CiA 301 parameter record indices