Skip to main content
Home
for DLMS smart meters

Main navigation

  • Home
  • Products
  • About us
  • Open Source
  • Community
  • Forum
  • Downloads
User account menu
  • Log in

Breadcrumb

  1. Home
  2. Need Help Implementing DLMS-HDLC Translator For Optical/RS232 Meter and Bare DLMS HES Packets

Need help implementing DLMS-HDLC translator for optical/RS232 meter and bare DLMS HES packets

By rakeshpatil1983, 5 September, 2025
Forums
Gurux DLMS for ANSI C

Hello Gurux Community,

I have a meter that uses HDLC over DLMS/COSEM via optical or RS232 interface, working well with Gurux tools.

My backend HES sends and receives bare DLMS packets without HDLC framing or addressing. For example, a raw DLMS packet from HES looks like this:

00 01 00 30 00 01 00 70 60 6E A1 09 06 07 60 85 74 05 08 01 03
A6 0A 04 08 31 90 97 EB C7 77 DF A1 8A 02 07 80 8B 07 60 85 74
05 08 02 02 AC 12 80 10 6B 59 55 67 72 78 36 44 44 38 4F 4F 66
52 36 30 BE 34 04 32 21 30 30 00 00 00 0E 5D 62 95 19 4A 9E EB
2B D0 A1 37 87 8B 63 75 0B 43 B3 D9 83 37 5A 1E A7 D4 8B 64
88 B2 A1 65 9C BE 84 08 31 98 CF B4 28 D0 F4 99

My goal:

Wrap bare DLMS packets into correct HDLC frames (with addressing and CRC) to send to the meter.

Strip HDLC framing/addressing from meter replies and send bare DLMS upstream.

Important:

The first 8 bytes of DLMS packets contain 4 bytes addressing + 4 bytes metadata.

These must be extracted and used as HDLC address and control bytes when framing.

On parsing, the HDLC layer should extract and prepend these 8 bytes back into the DLMS payload.

What I have done:

Manual HDLC framing/parsing following Gurux style (frame format, length, dest/src addresses, control, CRC16).

Truncate/prepend addressing + metadata correctly.

Handle byte stuffing and multiple concatenated frames.

But still face shifting addresses, DLMS offsets, and zeros replacing metadata on replied packets.

Requesting:

Guidance or sample code on correctly extracting/reinserting first 8 bytes during DLMS↔HDLC translation.

Best practices for clean and lossless handling of address and metadata bytes.

Confirmation of exact DLMS bytes that map to HDLC address/control fields.

References or examples from Gurux DLMS for this translator logic.

Tips on debugging and validating such layered conversions.

Thanks for your time and help!

Profile picture for user Kurumi

Kurumi

5 months 1 week ago

Hi, Your HES is using…

Hi,

Your HES is using WRAPPER framing. You need to remove the WRAPPER part and then connect to the meter. After establishing the connection to the meter, you will know the maximum HDLC frame size. Then you need to split the PDU into the max frame size and send HDLC frames to the meter. You should check the dlms_getHdlcFrame.

This is possible, but it requires a deeper understanding of communicating with DLMS and a lot of time. It's good to get the DLMS standards and study them.

BR,
Mikko

rakeshpatil1983

5 months ago

Thanks for the quick Reply, …

Thanks for the quick Reply,

I'm using gurux C implementation and trying to prototype on esp32, and the communcation and all is working well for all the ports and getting the desired results.

Now coming to the translation part kindly guide me to encapsulate bare DLMS to HDLC if there are any functions in c implementation and viceversa, the goal is take raw DLMS encapsulate to HDLC and back, pleae guide me to the necessary functions that i can look into . appreciate your help .

Profile picture for user Kurumi

Kurumi

5 months ago

Hi, DLMS data is sent in…

Hi,

DLMS data is sent in HDLC frames, and they are totally different things. I have to say, this is trickier to implement than it looks.

You can use dlms_getHdlcFrame fo make HDLC frame to the PDU. Then send and receive it in the normal way as you make the read operation.

BR,
Mikko

rakeshpatil1983

5 months ago

i have been experimenting…

i have been experimenting with this and have been able to reach where i'm successfully getting to AARQ to the meter where the setup is, i'm using gurux directory in that i'm setting it as indian standard, PC default and HDLC, here over HDLC In dlms i get this DLMS C0 01 C1 00 01 00 00 60 01 00 FF 02 00 where as if i change the settings to use wrapper with all other remaining the same i get this C0 01 C1 00 0F 00 00 28 00 00 FF 02 00 as you can see both are different obis codes and both class IDs are different. why are they different ? what has to be taken care of in this case ? Just to test i tried with both Arduino as Server iwth HDLC and WRAPPER both results are the same in directory. is it supposed to happen ? I was not able to map this while i was building the translator from dlms wrapper to HDLC and back.

Profile picture for user Kurumi

Kurumi

5 months ago

Hi, You try to read…

Hi,

You try to read different objects. WIth HDLC you are reading 0.0.96.1.0.255 and with WRAPPER 0.0.40.0.0.255. You can view the converted XML by selecting the PDU tab in GXDLMSDirector, adding a PDU, and pressing the Convert button.

BR,
Mikko

  • Create new account
  • Reset your password

Hire Us!

Latest Releases

  • Sun, 02/01/2026 - 19:47
    gurux.dlms.cpp 9.0.2602.0101
  • Tue, 01/20/2026 - 10:38
    gurux.dlms.java 4.0.89
  • Wed, 01/14/2026 - 14:29
    Gurux.DLMS.Python 1.0.196
  • Mon, 12/29/2025 - 10:38
    Gurux.Serial.Android 3.0.5
  • Mon, 12/15/2025 - 08:11
    Gurux.DLMS.Net 4.0.87

New forum topics

  • Asynchronous support in Gurux DLMS stack (.NET)?
  • Multiple meter loop On OFF Problem
  • Python GXDLMSTranslator
  • Issue with KWH Value Reading Using Gurux DLMS Library.
  • CEWE Prometer 100
More
RSS feed
Privacy FAQ GXDN Issues Contact
Follow Gurux on Twitter Follow Gurux on Linkedin