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 3 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 3 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 3 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 3 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 3 months ago

In reply to Hi, by Kurumi

That works perfectly! Thank

That works perfectly! Thank you!

balaramjenagate

7 years 3 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 3 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

  • Mon, 07/27/2026 - 12:37
    gurux.dlms.cpp 9.0.2607.2701
  • Thu, 07/23/2026 - 16:19
    gurux.dlms.java 4.0.96
  • Thu, 07/09/2026 - 14:34
    Gurux.DLMS.Python 1.0.201
  • Fri, 06/26/2026 - 16:32
    Gurux.Service 3.0.2606.2601
  • Wed, 06/24/2026 - 08:36
    Gurux.DLMS.Python 1.0.200

New forum topics

  • Version mismatch between Gurux.DLMS 9.x and Gurux.Common/Gurux.Serial 8.x
  • Service not known error on gprs communication
  • Help Needed: Interfacing Saral 100 Energy Meter with Microcontroller via RS232
  • Connecting Meter to Agent via serial
  • Reading block profile with Compact array
More

Who's new

  • dermida
  • Justinpeent
  • cYzhesWhQAIeYenRgH
  • MLWGzTbGsyBIaJ…
  • Rolling-Slots-PL
RSS feed
Privacy FAQ GXDN Issues Contact
Follow Gurux on Twitter Follow Gurux on Linkedin