Skip to content

eds: fix LowLimit/HighLimit parsing for all signed integer types#658

Open
friederschueler wants to merge 2 commits intocanopen-python:masterfrom
friederschueler:fix/eds-limit-parsing
Open

eds: fix LowLimit/HighLimit parsing for all signed integer types#658
friederschueler wants to merge 2 commits intocanopen-python:masterfrom
friederschueler:fix/eds-limit-parsing

Conversation

@friederschueler
Copy link
Copy Markdown
Collaborator

Fixes incomplete signed integer handling for LowLimit/HighLimit in EDS parsing, as noted in #352.

Changes

  • Replace _calc_bit_length() (only handled INTEGER8/16/32/64) with a lookup dict _SIGNED_BIT_LENGTHS covering all 8 SIGNED_TYPES (INTEGER8/16/24/32/40/48/56/64)
  • Log a warning instead of silently ignoring invalid limit values (except ValueError: pass)
  • Add EDS test entries in sample.eds for INTEGER24/40/48/56 with hex-encoded negative limits
  • Extend test_record_with_limits and add test_invalid_limit_logs_warning

Note on formatting

eds.py and test_eds.py were reformatted with black. If a purely functional diff is preferred, the formatting commits can be dropped — the functional changes are small and easy to separate.

Closes part of #352.

@codecov
Copy link
Copy Markdown

codecov Bot commented May 6, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@acolomb
Copy link
Copy Markdown
Member

acolomb commented May 7, 2026

Please always separate style changes from functional changes. Except of course fixing in the immediate vicinity of the functional changes.

Comment thread canopen/objectdictionary/eds.py
Comment thread canopen/objectdictionary/eds.py Outdated
Comment thread test/test_eds.py Outdated
- Replace _calc_bit_length() (only handled INTEGER8/16/32/64) with a
  lookup dict _SIGNED_BIT_LENGTHS covering all 8 SIGNED_TYPES
  (INTEGER8/16/24/32/40/48/56/64)
- Log a warning instead of silently ignoring invalid limit values
  (except ValueError: pass)
- Add EDS test entries in sample.eds for INTEGER24/40/48/56 with
  hex-encoded negative limits
- Extend test_record_with_limits and add test_invalid_limit_logs_warning

Closes part of canopen-python#352.
@friederschueler friederschueler force-pushed the fix/eds-limit-parsing branch from 27e94d8 to f65a1fb Compare May 7, 2026 20:15
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.

2 participants