Skip to main content
Home
for DLMS smart meters
Open source solutions for DLMS smart metering

Main navigation

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

Breadcrumb

  1. Home
  2. Forums
  3. How To Read DLMS Without Using GXNet Nor GXSerial

How to read DLMS without using GXNet nor GXSerial

Forum Rules

Before commenting read Forum rules

Don't comment the topic if you have a new question.

You can create a new topic selecting correct category from Gurux Forum and then create a new topic selecting "New Topic" from the top left.

By khun_panya , 5 April, 2019
Forums
Gurux.DLMS

This page https://github.com/Gurux/Gurux.DLMS.Net
says that Gurux.Net nor Gurux.Serial is not necessary.
But the examples have extensively used GXSerial and GXNet.
How can we implement ReadDLMSPacket method by using just simple TcpClient ?
Please show some example. Thanks.

khun_panya

7 years 2 months ago

How to read DLMS without using GXNet nor GXSerial

OK. Here is my progress. I write a sub

private static byte[] SendAndReceive(TcpClient net, byte[] command)
{
var ns = net.GetStream();
ns.Write(command, 0, command.Length);
System.Threading.Thread.Sleep(100);
var buff = new byte[1024];
using (var ms = new System.IO.MemoryStream())
{
int len;
while (ns.DataAvailable)
{
len = ns.Read(buff, 0, buff.Length);
ms.Write(buff, 0, len);
}
return ms.ToArray();
}
}

And here is my main program

var net = new TcpClient();
net.Connect("xxx.xxx.xxx.xxx", 6001); // Landis+Gyr meter

var client = new GXDLMSClient();
client.UseLogicalNameReferencing = false;
client.InterfaceType = InterfaceType.HDLC;
client.ServerAddress = 1;
client.ClientAddress = 16;

var send = client.SNRMRequest();
var recv = SendAndReceive(net, send);
client.ParseUAResponse(new GXByteBuffer(recv));

But now the problem is ParseUAResponse throws GXDLMSException("Invalid Exception.").
Why is that? Lines below are send and recv binary.

7E A0 07 03 21 93 0F 01 7E
7E A0 1E 21 03 73 C3 7A 81 80 12 05 01 80 06 01 3E 07 04 00 00 00 01 08 04 00 00 00 01 07 22 7E

Profile picture for user Kurumi

Kurumi

7 years 2 months ago

Hi,

Hi,

Your code looks good and your settings are correct. What version from gurux.dlms.java you are using?
I just tested this and it worked like should be. I was using the same settings that you are.
Check what is reply data in new GXByteBuffer(recv).

BR,
Mikko

khun_panya

7 years 2 months ago

In reply to Hi, by Kurumi

Hi,

Hi,
I'm using latest Gurux.DLMS for C# v8.5.1904.401. Downloaded from NuGet.
It looks like the exception was thrown because the 5th byte of GXByteBuffer data was 03
which is not listed in switch-case within GXDLMS.ParseSnrmUaResponse(…).

Profile picture for user Kurumi

Kurumi

7 years 2 months ago

Hi,

Hi,

Now I believe what it the reason. Before you call ParseUAResponse you need to call GetData.
GXReplyData reply = new GXReplyData();
client.GetData(recv, reply);
client.ParseUAResponse(reply.Data);

BR,
Mikko

khun_panya

7 years 2 months ago

In reply to Hi, by Kurumi

That works perfectly! Thank

That works perfectly! Thank you!

balaramjenagate

7 years 2 months ago

while I am running Gurux

while I am running Gurux.Serial.Android Master android app error: cannot find symbol method getPorts() is coming

Profile picture for user Kurumi

Kurumi

7 years 2 months ago

In reply to while I am running Gurux by balaramjenagate

Hi,

Hi,

When you have new question, please, create a new topic. Have you imported serial port in to your android app? What version you are using from Android Studio?

BR,
Mikko

  • Create new account
  • Reset your password

Hire Us!

Latest Releases

  • Tue, 06/09/2026 - 11:16
    gurux.dlms.java 4.0.95
  • Tue, 06/09/2026 - 10:03
    Gurux.DLMS.Python 1.0.199
  • Mon, 06/08/2026 - 13:39
    gurux.dlms.cpp 9.0.2606.0801
  • Mon, 06/01/2026 - 10:15
    gurux.dlms.cpp 9.0.2606.0101
  • Thu, 05/28/2026 - 16:06
    gurux.dlms.java 4.0.94

New forum topics

  • Error reading L&G Meter
  • Pass a TCP Client to GXNet
  • Australian EDMI Mk10D (Essential Energy area)
  • Strange mix of data notificiation vs get response
  • DLMS Connection
More

Who's new

  • Tuanhgg
  • Adel
  • charnon
  • Paddles
  • Miguel Ángel
RSS feed
Privacy FAQ GXDN Issues Contact
Follow Gurux on Twitter Follow Gurux on Linkedin