Skip to content

[MIX][FEAT] Warn when ARRAY elements have different access attributes (CANopenNode V4) - #242

Open
NobseVomBerg wants to merge 1 commit into
CANopenNode:mainfrom
NobseVomBerg:array-element-attributes-warning
Open

NobseVomBerg wants to merge 1 commit into
CANopenNode:mainfrom
NobseVomBerg:array-element-attributes-warning

Conversation

@NobseVomBerg

@NobseVomBerg NobseVomBerg commented Nov 23, 2026 •

Copy link
Copy Markdown

What changes

  • libEDSsharp: new EDSsharp.VerifyArrayElementAttributes(). It returns one message for every enabled ARRAY whose elements (sub-index 1 and above) differ in SDO, PDO or SRDO access.
  • CANopenNode V4 exporter: Prepare_arr reports one warning per ARRAY instead of one line per differing element. The warning names the index, the object name, the differing sub-indexes, the consequence and the remedy. The CLI and the GUI export show it through the existing warning list, so EDSSharp needed no change.
  • EDSEditorGUI: the same warning is shown in the warnings window when an EDS or XDD file is opened, if the exporter selected in the preferences is CANopenNode V4.
  • Tests: unit tests in Tests/ArrayElementAttributeTests.cs and one case in EditorRegressionTests.

Why

CANopenNode V4 stores an ARRAY as OD_obj_array_t, which has attribute0 for sub-index 0 and one attribute for all elements. The editor and the EDS allow every sub-index of an ARRAY to have its own access, and the exporter writes the attribute of the first element for all of them.

Example: an ARRAY with sub-index 1 wo, 2 ro, 3 rw is exported as .attribute = ODA_SDO_W | ODA_MB. On the device no element can be read and the read-only element can be written, while the EDS generated from the same project says something else.

The exporter already warned about this, but the text was easy to miss and did not say what happens:

WARNING :Error in 0x2000: Attributes of elements in ARRAY must be equal
WARNING :Error in 0x2000: Attributes of elements in ARRAY must be equal

Now:

WARNING :Error in 0x2000 "Mixed array": Attributes of elements in ARRAY must be equal, but sub-indexes 0x02, 0x03 differ from sub-index 0x01. CANopenNode stores one attribute for all elements of an ARRAY, so the attribute of sub-index 0x01 is used for all of them. Make the access of all elements equal or change the object type to RECORD.

Nothing warned when such a file was opened in the editor; the problem only showed up at export time.

Decisions

  • The exporter still compares the attribute strings it really writes; only the reporting changed. The phrase "Attributes of elements in ARRAY must be equal" is kept, so existing log filters still match.
  • VerifyArrayElementAttributes() compares AccessSDO(), AccessPDO() and CO_accessSRDO, which are what the V4 exporter turns into attribute flags. ro and const are both ODA_SDO_R and are not reported. Different data types already have their own exporter warning and are not part of this check.
  • The warning on open is limited to the CANopenNode V4 exporter setting (the default), because different access per element is valid in an EDS for other stacks. It uses the class WARNING_BUILD, so "Show Build Warnings" in the preferences turns it off.
  • No warning on edit. Saving an element of an ARRAY already copies its access to all elements, and the "Object Type" box is disabled, so the editor itself cannot create such an ARRAY; it can only come from a file.
  • ExporterTestsV4 and IssueRegressionTests got [Collection("Warnings")]: they run the V4 exporter, which writes to the static Warnings.warning_list that the new exporter test reads.

Related issues

I found no open or closed issue or PR on this topic.

Tests

  • dotnet build EDSEditor.sln -p:BuildNet8=true and dotnet build EDSEditor.Windows.sln -p:BuildNet481=true: 0 errors.
  • dotnet test Tests\Tests.csproj -p:BuildNet8=true: 202 passed, 0 failed (194 before this change).
  • dotnet test Tests\Tests.csproj -p:BuildNet481=true: 197 passed, 5 failed. The five are the CliTest cases; they fail the same way on unchanged main on my machine (the CLI executable is not found when the project is run this way).
  • EditorRegressionTests\run-tests.ps1 -Platform x64 -Configuration Debug against the net481 editor build: all cases pass, including the new one (opening an EDS with a mixed ARRAY shows the warning once, the same elements as a RECORD do not). The new case fails when the call in openEDSfile is removed.
  • Manual: a small EDS with an ARRAY 0x2000 (sub-index 1 wo, 2 ro, 3 rw), EDSSharp --infile mixed.eds --outfile OD.c --type CanOpenNodeV4 prints the warning shown above once.

I have read the contributing guidelines, I agree to following them and I agree to the Developer's Certificate of Origin 1.1

🤖 Generated with Claude Code

CANopenNode V4 stores one attribute set (OD_obj_array_t) for all
elements of an ARRAY, so the exporter writes the attributes of the
first element for every element. The existing warning was one terse
line per differing element and did not say which attribute was used.

- Add EDSsharp.VerifyArrayElementAttributes(), which compares SDO, PDO
  and SRDO access of ARRAY elements and returns one message per ARRAY.
- The V4 exporter now reports one warning per ARRAY. It gives the
  index, the object name, the differing sub-indexes, the sub-index
  whose attributes are used, and what to do (equal access or RECORD).
- Show the same warning when an EDS or XDD file is opened, if the
  selected exporter is CANopenNode V4. Nothing changes when the legacy
  exporter is selected.
- Add unit tests and a GUI regression test. ExporterTestsV4,
  IssueRegressionTests and the new ArrayElementAttributeTests share the
  "Warnings" xUnit collection, because Warnings.warning_list is static.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>

This branch has not been deployed

No deployments
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.

1 participant