Repository navigation
[MIX][FEAT] Warn when ARRAY elements have different access attributes (CANopenNode V4) - #242
Open
NobseVomBerg wants to merge 1 commit into
Open
NobseVomBerg wants to merge 1 commit into
NobseVomBerg wants to merge 1 commit into
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changes
EDSsharp.VerifyArrayElementAttributes(). It returns one message for every enabled ARRAY whose elements (sub-index 1 and above) differ in SDO, PDO or SRDO access.Prepare_arrreports 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, soEDSSharpneeded no change.Tests/ArrayElementAttributeTests.csand one case inEditorRegressionTests.Why
CANopenNode V4 stores an ARRAY as
OD_obj_array_t, which hasattribute0for sub-index 0 and oneattributefor 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, 2ro, 3rwis 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:
Now:
Nothing warned when such a file was opened in the editor; the problem only showed up at export time.
Decisions
VerifyArrayElementAttributes()comparesAccessSDO(),AccessPDO()andCO_accessSRDO, which are what the V4 exporter turns into attribute flags.roandconstare bothODA_SDO_Rand are not reported. Different data types already have their own exporter warning and are not part of this check.WARNING_BUILD, so "Show Build Warnings" in the preferences turns it off.ExporterTestsV4andIssueRegressionTestsgot[Collection("Warnings")]: they run the V4 exporter, which writes to the staticWarnings.warning_listthat 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=trueanddotnet 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 theCliTestcases; they fail the same way on unchangedmainon my machine (the CLI executable is not found when the project is run this way).EditorRegressionTests\run-tests.ps1 -Platform x64 -Configuration Debugagainst 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 inopenEDSfileis removed.wo, 2ro, 3rw),EDSSharp --infile mixed.eds --outfile OD.c --type CanOpenNodeV4prints 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