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. Ansi.C Issue Reading Asociation List

Ansi.C issue reading asociation list

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 Vitaol , 13 May, 2022
Forums
Gurux.DLMS

Hi,
I have an issue when reading the associating list when using the server of the ansi C library.
I have adapted (or at least tried to) the AtMega2560 example using the same serialization functions as the NordicSemiconductor example for a stm32 microcontroller.
When using GXDLMSDirector I can connect it will show all objects but the last one, if I change the order of items, it’s always the last one that won’t appear.
If I try to read the association manually, I get an error indicating that the argument it’s outside the valid value interval (sorry for the bad translation, this error appears in my language). I add the log in a pastebin url to see if it helps. https://pastebin.com/nLRi4guR
Mi gxignore.h looks like this: https://pastebin.com/3rzc8fsL
I have tried:
- Changing order -> always the last one won’t appear when associating after connecting.
- Adding a 0 at end of ALL_OBJECTS list -> Every object appears but the error when reading manually persist.
Thanks in advances, let me know if more info is needed.

Profile picture for user Kurumi

Kurumi

4 years ago

Hi,

Hi,

You have added four objects to the association view:

0.0.40.0.0.255
0.0.40.0.1.255
Data: 0.0.42.0.0.255
Register: 1.1.21.25.0.255

Can you share what object is missing?

Have you added COSEM objects for the source code or are you adding them from the GXDLMSDirector?

If you have added one object for the source code make sure that the serialization load doesn't hide it.

BR,
Mikko

Vitaol

4 years ago

Hi,

Hi,
Thanks for the reply.
In this case the object missing is the clock 0.0.1.0.0.255 (it’s the last one in the ALL_OBJECTS list):
I add the objects to my server following the example (I add a pastebin url so you can see the code).
https://pastebin.com/B3RmCit9
I don’t recall adding the object 0.0.40.0.1.255 manually, I guess that it happened internal.
I have tested to add the object to the GXDLMSDirector manually and it works and can read it.
I don’t really understand the serialization part of the code, maybe it’s there the problem, I have added that part to the pastebin too, so I don’t know what you mean by “make sure that the serialization load doesn't hide it”.
Thanks for your time and early response.

Vitaol

4 years ago

Hi,

Hi,
I fixed the association error about the not valid interval adding the following line:
association.xDLMSContextInfo.conformance = DLMS_CONFORMANCE_GET;
But I still can’t read the last object of the list, I have tried adding a zero at the end of the list and it seems to work until I add more objects and the microcontroller tried to access a non-accessible memory address from preRead in the instruction:
type = (DLMS_OBJECT_TYPE)e->target->objectType;
After that I deleted the zero but the error continues.
Debugging I have seen how the value get filled with some weird values ( see image attached).

This happens when I just connect and read the available objects of my meter. After that If I reset my server and connect again with the objects already discovered I can read them without problem.
Do you have any recommendation to debug this problem?
Thanks for your time

Image

fon Luck

4 years ago

Hello!

Hello!
In DLMS.c file gxget.c function getLNObjects().
First saving objects quantity in buffer for transmission, next increment this quantity. As result, DLMSDirector does not see last item.

Working correctly with this changes:

e->transaction EndIndex = count;

if (!found) // added
++count;
if ((ret = cosem_set Array(data, count)) != 0)
{
return ret;
}

if (!found)
{
// ++// ++count; // removed
//Count
if ((ret = cosem_set Structure(data, 4)) != 0 ||

Vitaol

4 years ago

In reply to Hello! by fon Luck

Lot of thanks,

Lot of thanks,
Now I can see al elements but the microcontroller keep crashing at the same function.
Any Idea why could it be?

Thanks again

Vitaol

4 years ago

In reply to Lot of thanks, by Vitaol

It seems to be while trying

It seems to be while trying to read scalers and units.

Profile picture for user Kurumi

Kurumi

4 years ago

Hi,

Hi,

Fon Luck is right. Those lines were removed in version 20220127.1 to fix another issue. This is now fixed for the last version. I believe it will also fix Vitaol's problem with scalers and units.

BR,
Mikko

Vitaol

4 years ago

In reply to Hi, by Kurumi

Hi,

Hi,
Thank you for the new version, it has solved the last element no showing but I still get the crash when reading scalers and units.
I have test it changing the number of elements in the list and I discovered that if I use 5 elements or less it works fine, but if I use 6 or more it crashes.
BR

Profile picture for user Kurumi

Kurumi

4 years ago

Hi,

Hi,

Scalers and units are read with a different method. How many registers you have added? Can you add a hex trace from GXDLMSDirector so I can try to check what is the problem?

BR,
Mikko

Vitaol

4 years ago

Hi,

Hi,
Here you have the trace:
https://pastebin.com/QUhWjKyQ
I have added 8 register, here you have the code:
https://pastebin.com/Q0vTL85z
Thank you

Profile picture for user Kurumi

Kurumi

4 years ago

Hi,

Hi,

Your code is now tested 100 times and it worked without problems every time. The source code is here:
https://pastebin.com/dLJbk6xV

Only those lines were commented.

// RMSMeasuresRegs* ptrRMS = ade9000GetRMSPtr();
// TemperatureRegs* ptrTemp = ade9000GetTempPtr();

Can you try this and let me know if you have problems?

BR,
Mikko

fon Luck

4 years ago

In reply to Hi, by Vitaol

Hi!

Hi!
The old code with my corrections works well

Vitaol

4 years ago

In reply to Hi, by Kurumi

Hi,

Hi,
Thanks for your time and dedication.
My code is far simpler that the one you posted, I took the atmega example as base:
(https://github.com/Gurux/GuruxDLMS.c/blob/master/Atmel/AtMega2560/Gurux…)
I'll try to complete it with your code. Unfortunately, I can’t test your code directly because I’m not working with Arduino, It will take me some time, I’ll let you know if it works.
Thank you,
BR

Vitaol

4 years ago

Hi,

Hi,
I got it working. It was my fault, I wasn’t ignoring malloc. Once I ignored it and adapted the Arduino server code it worked.
Thank you.

Profile picture for user Kurumi

Kurumi

4 years ago

Hi,

Hi,

Thank you for letting me know this. There are so many settings in DLMS and the reason might be anything.

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