Skip to content

mask_write_register command processes partial responses #881

@mickstevens1

Description

@mickstevens1

Versions

  • Python: 3.10.0
  • OS: Win 10
  • Pymodbus: 3.0.0.dev3 (also 2.5.3)
  • Modbus Hardware (if used): Custom

Pymodbus Specific

  • Client: rtu - sync/async

Description

The mask_write_register command processes partial responses resulting in error:

Modbus Error: [Input/Output] No Response received from the remote unit/Unable to decode response

The issue is traced back to the class MaskWriteRegisterResponse which does not include the get_response_pdu_size method. As a result, the client does not wait for the full response and only the initial data in the receive buffer is processed. A race condition results with unpredictable failures.

Adding the following method to the class resolves the problem.

Code and Logs

def get_response_pdu_size(self):
    """
    Func_code (1 byte) + Starting Address (2 byte) + And_mask (2 Bytes) + OrMask (2 Bytes)
    :return:
    """
    return 1 + 2 + 2 + 2

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions