-
Notifications
You must be signed in to change notification settings - Fork 207
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
Disregard OD variable description in SdoClient.upload() #592
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.
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 |
Anyway, this is v3.0.0 stuff by the way. #594 has higher priority on my agenda, then getting out the release. |
There was a problem hiding this 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.
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 thegeneric
ODVariable
decoding functions.Move the data truncation to the method
SdoVariable.get_data()
, whereaccess 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 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.