Skip to content

Conversation

@justinsg
Copy link
Contributor

Encode fix:

The sub-req file response length is in bytes, not registers, and needs
to also count the reference type byte. We already calculate the correct
value in `FileRecord.response_length` so make use of it here.

Decode fix:

The `count` increment was incorrect, because `response_length` already
includes the 1 byte for reference type. This moved the pointer too far
ahead, leading to incorrect slicing of record_data.

Also corrected the unit test for this; it seems to be copied from the
Modbus spec example but had a typo (repeated \x05) and did not assert
correctness of the second sub-req in the PDU.

The sub-req file response length is in bytes, not registers, and needs
to also count the reference type byte. We already calculate the correct
value in `FileRecord.response_length` so make use of it here.
The `count` increment was incorrect, because `response_length` already
includes the 1 byte for reference type. This moved the pointer too far
ahead, leading to incorrect slicing of record_data.

Also corrected the unit test for this; it seems to be copied from the
Modbus spec example but had a typo (repeated \x05) and did not assert
correctness of the second sub-req in the PDU.
Copy link
Collaborator

@janiversen janiversen left a comment

Choose a reason for hiding this comment

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

LGTM, thanks

@janiversen janiversen merged commit aa7e556 into pymodbus-dev:dev Sep 14, 2024
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