Fix fragmented protected requests over Serial HDLC - #53
Open
stefan-andrejevic wants to merge 2 commits into
Open
Fix fragmented protected requests over Serial HDLC#53stefan-andrejevic wants to merge 2 commits into
stefan-andrejevic wants to merge 2 commits into
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
GXReplyDatawhile processing fragmented transport frames, causing previously received protocol state to be discarded before the exchange is complete.Changes
Transport layer
GXDLMS.getSnMessages()GXDLMSClient._read()instead of only the first transport frameExample client
GXReplyDatainstance while processing fragmented transport framesreply.clear()calls inGXDLMSReaderWhy
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
GXReplyDatabetween 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.