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. Node
  3. Old Data Doesn't Disappear On Second Request In DLMSDirector With .NET Gurux DLMServer

Old data doesn't disappear on Second Request in DLMSDirector with .NET Gurux DLMServer

By liemoon , 1 November, 2024
Forums
Gurux.DLMS

Hello,
I’m building a DLMServer in .NET and testing it with DLMSDirector. On the first read of a profile generic, two data entries appear as expected. However, on the second request, the old data doesn’t clear, resulting in four entries showing up in DLMSDirector. In the preread section of DLMServer, I’ve tried clearing the buffer before adding new data, but the issue persists. How can I ensure the old data is cleared properly before each new read request?

Here's my code to handle the profile generic:
[LogicalName("1.97.99.98.1.255")]
public class TestController(ILogger<TestController> logger) : DLMSControllerBase
{
private static GXDLMSProfileGeneric pf = new();
public override GXDLMSObject gxObject => new GXDLMSProfileGeneric
{
LogicalName = logicalName,
CaptureObjects = [
new(new GXDLMSClock(),new GXDLMSCaptureObject(2,0)),
new(new GXDLMSRegister("0.0.96.6.3.255"),new GXDLMSCaptureObject(2,0)),
]
};
private static DateTime now = DateTime.Now;
public override void ReadHandler(ValueEventArgs e)
{
try
{
if (e.Index == 2)
{
var obj = (GXDLMSProfileGeneric)e.Target;
obj.Buffer.Clear();
obj.Buffer.AddRange([[now.AddDays(-2), 123], [now, 1234]]);
}
}
catch (Exception ex)
{
logger.LogError(ex.Message);
}
}
}

Profile picture for user Kurumi

Kurumi

1 year 10 months ago

Hi, I get the latest version…

Hi, I got the latest version from GitHub and it worked without problems. Check your code.

 

protected override void PreRead(ValueEventArgs[] args)
{
    foreach (ValueEventArgs e in args)
    {
        //Framework will handle profile generic automatically.
        if (e.Target is GXDLMSProfileGeneric)
        {
            if (e.Index == 2)
            {
        	    //Client reads buffer.
        	    GXDLMSProfileGeneric p = (GXDLMSProfileGeneric)e.Target;
        	    var obj = (GXDLMSProfileGeneric)e.Target;
        	    obj.Buffer.Clear();
        	    DateTime now = DateTime.Now;
        	    obj.Buffer.Add(new object[] { now.AddDays(-2), 123 });
        	    obj.Buffer.Add(new object[] { now, 1234 });
            }
        }
    }
}

BR,

Mikko

  • Create new account
  • Reset your password

Hire Us!

Latest Releases

  • Wed, 08/26/2026 - 09:04
    Gurux.DLMS.Python 1.0.203
  • Mon, 08/17/2026 - 11:28
    Gurux.DLMS.Python 1.0.202
  • Mon, 08/17/2026 - 09:47
    gurux.dlms.cpp 9.0.2608.1701
  • Mon, 08/17/2026 - 09:25
    gurux.dlms.c 9.0.2608.1701
  • Mon, 07/27/2026 - 12:37
    gurux.dlms.cpp 9.0.2607.2701

New forum topics

  • Security vulnerability report — request for a private contact (GuruxDLMS.c / ANSI C)
  • Topic: Insufficient Memory Error When Reading Class 7 Profile Generic Objects
  • SN ReadResponse returns all-null values when response spans multiple HDLC frames
  • Gurux.Serial.Android 3.0.6 – CH340 (HL-340) USB-Serial Adapter Not Working,
  • Trying to talk to a L&G E360 meter (Using Python Gurux)
More
RSS feed
Privacy FAQ GXDN Issues Contact
Follow Gurux on Twitter Follow Gurux on Linkedin