Skip to content

eds: Add first-class support for CiA 306 ObjFlags and Denotation#654

Open
bizfsc wants to merge 1 commit intocanopen-python:masterfrom
bizfsc:feat/cia306-objflags-denotation-v2
Open

eds: Add first-class support for CiA 306 ObjFlags and Denotation#654
bizfsc wants to merge 1 commit intocanopen-python:masterfrom
bizfsc:feat/cia306-objflags-denotation-v2

Conversation

@bizfsc
Copy link
Copy Markdown
Collaborator

@bizfsc bizfsc commented May 4, 2026

ObjFlags (UNSIGNED32 bitfield) and Denotation (DCF-only string) are standard CiA 306 fields that were previously silently dropped. This PR adds first-class support for both.

Changes

  • ODVariable, ODRecord and ODArray gain an obj_flags: int = 0 attribute.
  • ODVariable gains a denotation: str = "" attribute.
  • New _get_obj_flags(eds, section) helper reads and validates the ObjFlags integer value.
  • ObjFlags is parsed for VAR/DOMAIN (via build_variable()), ARRAY and RECORD top-level objects.
  • ObjFlags is exported whenever non-zero.
  • Denotation is read in build_variable() and written only in DCF mode (device_commisioning=True), matching the CiA 306 specification.

Tests

  • test_reading_obj_flags — VAR with ObjFlags=0x1 reads back correctly
  • test_reading_obj_flags_default — standard objects default to 0
  • test_roundtrip_obj_flags — full EDS export/import cycle preserves obj_flags
  • test_denotation_roundtrip_dcfdenotation survives a DCF round-trip
  • test_denotation_not_exported_in_eds_modedenotation is absent in plain EDS export

@codecov
Copy link
Copy Markdown

codecov Bot commented May 4, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@bizfsc bizfsc force-pushed the feat/cia306-objflags-denotation-v2 branch from 5dff918 to 90dbe07 Compare May 4, 2026 08:52
ObjFlags (UNSIGNED32 bitfield) and Denotation (DCF-only string) are
standard CiA 306 fields that are now parsed and exported explicitly.

Changes:
  * ODVariable, ODRecord and ODArray gain an obj_flags: int = 0 attribute.
  * ODVariable gains a denotation: str = '' attribute.
  * _get_obj_flags() helper reads and validates the ObjFlags integer value.
  * ObjFlags is parsed for VAR/DOMAIN (via build_variable), ARRAY and RECORD.
  * ObjFlags is exported whenever non-zero.
  * Denotation is read in build_variable() and written only in DCF mode
    (device_commisioning=True), matching the CiA 306 specification.
  * Adds test object 0x3060 (ObjFlags=0x1) to sample.eds and four new tests
    covering read, round-trip and DCF export for both fields.

Co-authored-by: FedericoSpada <FedericoSpada@users.noreply.github.com>
@bizfsc bizfsc force-pushed the feat/cia306-objflags-denotation-v2 branch from 90dbe07 to bccbd5c Compare May 4, 2026 09:00
@bizfsc
Copy link
Copy Markdown
Collaborator Author

bizfsc commented May 8, 2026

Is this YAGNI?

@acolomb
Copy link
Copy Markdown
Member

acolomb commented May 8, 2026

Frankly, I never heard of it. But now that I have, I had an immediate idea where it could be used in my code, replacing a previous workaround.

Some controllers have extra objects for "user variables" which can be utilized in a user-supplied small PLC program on the device. The function of this custom program defines what the variable is really used for (denotation), yet the device manufacturer can only assign a generic name of "user variable 1" in the generic device EDS. That sounds like a perfect application of this less widespread option.

The ObjFlags option also seems to solve a problem I've previously worked around by hard-coding objects to skip.

I'll have to take a deeper look to really judge if it works like I imagine. And get better acquainted with their definition in CiA 306.

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