Skip to content

Disregard OD variable description in SdoClient.upload() #592

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Aug 18, 2025

Conversation

acolomb
Copy link
Member

@acolomb acolomb commented Jun 15, 2025

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.

This is based on, and includes the changes of, #591.

acolomb added 2 commits June 15, 2025 18:09
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.
Copy link

codecov bot commented Jun 15, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@acolomb
Copy link
Member Author

acolomb commented Jun 16, 2025

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 SdoClient.upload() in case an OD description is available.

@acolomb acolomb added this to the v3.0.0 milestone Jun 18, 2025
@acolomb
Copy link
Member Author

acolomb commented Jun 22, 2025

Anyway, this is v3.0.0 stuff by the way. #594 has higher priority on my agenda, then getting out the release.

Copy link
Collaborator

@sveinse sveinse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@acolomb acolomb merged commit be9c56d into canopen-python:master Aug 18, 2025
4 of 5 checks passed
@acolomb acolomb deleted the sdo-upload-disregard-od branch August 18, 2025 20:51
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