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. Read Data From DLMS_OBJECT_TYPE_DATA

read data from DLMS_OBJECT_TYPE_DATA

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 fery_rz , 1 November, 2019
Forums
General discussion

Hello,

I try to read firmware version from SL7000 meter, using ANSI C. here it's the code:

cosem_init(&data1.base, DLMS_OBJECT_TYPE_DATA, "0.0.142.1.1.255");
ret = com_read(&data1.base, 2);

the response code is "OK".

<Result>
<Data>
<Structure Qty="2" >
<UInt8 Value="4" />
<UInt8 Value="40" />
</Structure>
</Data>
</Result>

then how can I get the value: Uint8 data type "4" and "40"?
what function to get / parse this data? Is there an example?

Thank you,
Best Regard,

Fery

Profile picture for user Kurumi

Kurumi

6 years 7 months ago

Hi,

Hi,

You can access array/structure like this:

dlmsVARIANT* it;
//First value
va_getByIndex(&data1.value.Arr, 0, &it)
ii->bVal
//Second value
va_getByIndex(&data1.value.Arr, 1, &it)
ii->bVal

obj_toString gets content of the object as a string.

BR,
Mikko

fery_rz

6 years 7 months ago

Hey Mikko,

Hey Mikko,
thank you for your reply,
and it's work with removing & from the &data1.value.arr

Best Regards,

Fery_rz

fery_rz

6 years 7 months ago

Hello Mikko,

Hello Mikko,

can you give example to get data from profile generic?

<Result>
<Data>
<Array Qty="0006" >
<Structure Qty="0004" >
<LongUnsigned Value="0003" />
<OctetString Value="01011F0700FF" />
<Integer Value="00" />
<LongUnsigned Value="0000" />
</Structure>
<Structure Qty="0004" >
<LongUnsigned Value="0003" />
<OctetString Value="0101330700FF" />
<Integer Value="00" />
<LongUnsigned Value="0000" />
</Structure>
<Structure Qty="0004" >
<LongUnsigned Value="0003" />
<OctetString Value="0101470700FF" />
<Integer Value="00" />
<LongUnsigned Value="0000" />
</Structure>
<Structure Qty="0004" >
<LongUnsigned Value="0003" />
<OctetString Value="0101200700FF" />
<Integer Value="00" />
<LongUnsigned Value="0000" />
</Structure>
<Structure Qty="0004" >
<LongUnsigned Value="0003" />
<OctetString Value="0101340700FF" />
<Integer Value="00" />
<LongUnsigned Value="0000" />
</Structure>
<Structure Qty="0004" >
<LongUnsigned Value="0003" />
<OctetString Value="0101480700FF" />
<Integer Value="00" />
<LongUnsigned Value="0000" />
</Structure>
</Array>
</Data>
</Result>

for example, I want to get first index of array:
<Structure Qty="0004" >
<LongUnsigned Value="0003" />
<OctetString Value="01011F0700FF" />
<Integer Value="00" />
<LongUnsigned Value="0000" />
</Structure>

what the function use, to read the "0003", "01011F0700FF", "00", and "0000"?

Best regards,

Fery

Profile picture for user Kurumi

Kurumi

6 years 7 months ago

Hi,

Hi,

Check obj_CaptureObjectsToString. It does exactly this.
obj_toString calls it.

BR,

Mikko

fery_rz

6 years 7 months ago

Hello mikko

Hello mikko

unfortunatelly,
I cant find "obj_CaptureObjectsToString" in ANSI C

gxProfileGeneric profile1;

I try to get this, response is OK.
cosem_init(&profile1.base, DLMS_OBJECT_TYPE_PROFILE_GENERIC, "1.1.98.128.4.255");
ret = com_read(&profile1.base, 3);

I check: "profile1.capturedObject.size" = 6, and data Type of the "profile1.capturedObject" is "gxArray"
can we just get the first index of the array, then pass it to "va_getByIndex()"?
then get the value using it->ulVal; for example

if it possible, how to do it?
and also how to get the first index of the array, and what variable Type to store it?

regards,

Fery

Profile picture for user Kurumi

Kurumi

6 years 7 months ago

Hi,

Hi,

obj_CaptureObjectsToString is internal method. obj_toString calls it.

You can also access data like this:

dlmsVARIANT* structure, it;
//First structure
va_getByIndex(&profile1.capturedObject.Arr, 0, &structure);
//First item
va_getByIndex(&structure->.Arr, 0, &it);
//Second item
va_getByIndex(&structure->.Arr, 1, &it);

BR,
Mikko

Profile picture for user Kurumi

Kurumi

6 years 7 months ago

Hi,

Hi,

it->vt tells data type.

BR,
Mikko

fery_rz

6 years 7 months ago

I am Sorry Mikko,

I am Sorry Mikko,
but the &profile1.capturedObject is dont have member .Arr, but .data, and the type is void **data. and the captureObject type is gxArray.
and also arr_getByIndex first parameter is variantArray *arr.

or we need to use arr_getByIndex to handle profile1.capturedObjects ?
is there any solution?

Best Regards,
Fery

fery_rz

6 years 7 months ago

Hello,

Hello,

I've found the obj_CaptureObjectsToString, then I try to implement this

dlmsVARIANT *structure, *it;

arr_getByIndex(&profile1.captureObjects, 0, (void **)&structure);
va_getByIndex(structure->Arr, 0, &it);

but my controller get crash when "va_getByIndex(structure->Arr, 0, &it);" above is added.

just trying to do: printf("%i\r\n", structure->vt);
the result is 1073450804

Regards,
Fery

Profile picture for user Kurumi

Kurumi

6 years 7 months ago

Hi Fery,

Hi Fery,

I'm sorry. This was my mistake. Correct example code is:

gxKey* kv;
arr_getByIndex(&profile1.capturedObject, 0, &kv);
gxObject* obj = (gxObject*)kv->key;

Attribute and data index you can get from value.
gxTarget* t = (gxTarget*)kv->value

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