Skip to content

Correlate S7CommPlus responses and route unsolicited frames separately #833

Description

@gijzelaerr

Problem

send_request() decodes the response opcode, function code and sequence number only for logging. It does not verify that the frame matches the outstanding request.

Notifications, SystemEvents, delayed responses or otherwise unexpected frames can consequently be consumed as an ordinary request response. This also blocks a correct subscription API. SystemEvent payload parsing has a related report in #827.

Scope

  • Require response opcode/function/sequence to match the outstanding request.
  • Recognize and route Notification and SystemEvent frames without treating them as responses.
  • Reject unexpected or duplicate response frames with a protocol-specific error.
  • Serialize sync requests per connection or otherwise guarantee unambiguous correlation.
  • Use the same dispatcher model as the foundation for sync and async clients.

Acceptance criteria

  • A mismatched sequence or function never satisfies a request.
  • A notification arriving before the response is preserved and dispatched.
  • A SystemEvent produces the behavior decided in _parse_read_response does not raise an exception in case of a SystemEvent #827 rather than being parsed as data.
  • Concurrent sync calls cannot interleave wire requests unsafely.
  • Tests cover notification-before-response, wrong sequence, wrong function, duplicate response and connection close.

Out of scope

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions