Disregard OD variable description in SdoClient.upload()#592
Merged
acolomb merged 11 commits intocanopen-python:masterfrom Aug 18, 2025
Merged
Disregard OD variable description in SdoClient.upload()#592acolomb merged 11 commits intocanopen-python:masterfrom
acolomb merged 11 commits intocanopen-python:masterfrom
Conversation
When an OD entry is found in SdoClient.upload(), the truncation is currently skipped only for those types explicitly listed as variable length data (domain, strings). That causes unknown types to be truncated to whatever their length indicates, which is usually one byte. Invert the condition to check all types with an explicitly known size, a.k.a. those listed in STRUCT_TYPES where the required length can be deduced from the structure format. Re-enable the unit tests which were skipped based on the previously buggy behavior.
The upload method should behave as a raw producer of byte data. Interpretation of the returned data based on the Object Dictionary is the responsibility of the SdoVariable class, which delegates to the generic ODVariable decoding functions. Move the data truncation to the method SdoVariable.get_data(), where access to the ODVariable is certain. The only truncation that still happens is based on the response size specified by the server, which might be smaller for e.g. expedited upload. Extend the upload() function docstring to clarify the changed behavior. Adjust the test case for expedited upload with unspecified size in the response, which is the only incompatible change.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
The existing test response is actually wrong, since the standard mandates four bytes "data" regardless of the other flags.
Member
Author
|
Alright, this is ready for prime time with now complete test coverage. Would still like to postpone it past the next release, as it significantly changes the return value of |
sveinse
requested changes
Jun 22, 2025
Member
Author
|
Anyway, this is v3.0.0 stuff by the way. #594 has higher priority on my agenda, then getting out the release. |
sveinse
approved these changes
Jun 22, 2025
Collaborator
sveinse
left a comment
There was a problem hiding this comment.
These changes looks good. There are probably more corner cases that can be pursued for SDO transfers, but that will have to be addressed in other PRs. Approved.
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.
The upload method should behave as a raw producer of byte data.
Interpretation of the returned data based on the Object Dictionary is
the responsibility of the
SdoVariableclass, which delegates to thegeneric
ODVariabledecoding functions.Move the data truncation to the method
SdoVariable.get_data(), whereaccess to the
ODVariableis certain.The only truncation that still happens is based on the response size
specified by the server, which might be smaller for e.g. expedited
upload. Extend the
upload()function docstring to clarify the changedbehavior. Adjust the test case for expedited upload with unspecified
size in the response, which is the only incompatible change.
This is based on, and includes the changes of, #591.