Skip to content

Fix fragmented protected requests over Serial HDLC - #53

Open
stefan-andrejevic wants to merge 2 commits into
Gurux:masterfrom
stefan-andrejevic:fix/hdlc-fragmented-requests
Open

Fix fragmented protected requests over Serial HDLC#53
stefan-andrejevic wants to merge 2 commits into
Gurux:masterfrom
stefan-andrejevic:fix/hdlc-fragmented-requests

Conversation

@stefan-andrejevic

Copy link
Copy Markdown

Summary

Protected requests may span multiple HDLC transport frames when the generated payload exceeds the negotiated HDLC frame size.

The current implementation truncates the generated transport frame sequence by returning only the first frame. As a result, incomplete requests are transmitted over Serial HDLC.

The example client also clears the accumulated GXReplyData while processing fragmented transport frames, causing previously received protocol state to be discarded before the exchange is complete.

Changes

Transport layer

  • Return the complete transport frame sequence from GXDLMS.getSnMessages()
  • Return the complete request generated by GXDLMSClient._read() instead of only the first transport frame

Example client

  • Preserve the same GXReplyData instance while processing fragmented transport frames
  • Remove unnecessary reply.clear() calls in GXDLMSReader

Why

Large protected DLMS requests can legitimately span multiple HDLC transport frames.

Returning only the first generated frame prevents the complete request from being transmitted, while clearing GXReplyData between frames discards the accumulated protocol state required to process the complete exchange.

These changes allow fragmented protected requests to be transmitted and processed correctly while remaining fully backward compatible for requests that already fit into a single transport frame.

Validation

Verified using protected requests over Serial HDLC where the generated request spans multiple transport frames.

Requests that fit into a single transport frame remain unaffected.

Stefan Andrejevic added 2 commits August 6, 2026 15:36
Return the complete transport frame sequence generated for protected
requests instead of truncating it to the first transport frame.

Large protected APDUs may span multiple HDLC transport frames.
Returning only the first generated frame causes incomplete request
transmission over Serial HDLC.

This change preserves the generated frame sequence so callers can
transmit every generated transport frame.
Preserve the same GXReplyData instance while processing fragmented
transport frames.

Removing reply.clear() prevents previously received protocol state from
being discarded before the complete request or response exchange has
been processed.

This aligns the example client with the transport layer behavior when
protected requests span multiple HDLC frames.
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.

1 participant