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. Add Object Type Data With Value Type Equal To An Array

Add object type data with value type equal to an array

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 lara.wakim , 25 November, 2020
Forums
General discussion

Hello Mikko,

We want to create and add two object of type gxData (id = 1).

1- The value of this object should be an Array[2] of bit-string[256], how are we supposed to write this in the add function?

2- The value of this object should be an Array[3] of octet-string[12], how are we supposed to write this in the add function?

Best Regards,

Lara Wakim

Profile picture for user Kurumi

Kurumi

5 years 6 months ago

Hi,

Hi,

Support for bit-string is missing at the moment. It's now added and a new version is released in next week.

BR,
Mikko

lara.wakim

5 years 6 months ago

Hi Mikko,

Hi Mikko,

This is a great news. Thank you.

Meanwhile can you tell us how we can write a value of type : Array[3] of octet-string[12]?

Best Regards,

Lara Wakim

Profile picture for user Kurumi

Kurumi

5 years 6 months ago

Hi,

Hi,

Your version is different than what we are using, but the idea is this:

You can do it like this for bit-string.

static gxData d;
const unsigned char ln[6] = { ...};
INIT_OBJECT(d, DLMS_OBJECT_TYPE_DATA, ln)
static unsigned char BUFFER[3][1];
BUFFER[0][0] = 2;
BUFFER[1][0] = 4;
BUFFER[2][0] = 5;
static dlmsVARIANT ARRAY[3];
GX_BIT_STRING(ARRAY[0], BUFFER, 2);
GX_BIT_STRING(ARRAY[1], BUFFER, 4);
GX_BIT_STRING(ARRAY[2], BUFFER, 5);
static variantArray tmp;
VA_ATTACH(tmp, ARRAY, 3);
GX_ARRAY(d.value, tmp);

and for octet-string like this:

static unsigned char BUFFER[3][12];
BUFFER[0][0] = Update data;
static dlmsVARIANT ARRAY[3];
GX_OCTECT_STRING(ARRAY[0], BUFFER[0], sizeof(BUFFER[0]));
GX_OCTECT_STRING(ARRAY[1], BUFFER[1], sizeof(BUFFER[0]));
GX_OCTECT_STRING(ARRAY[2], BUFFER[2], sizeof(BUFFER[0]));
static variantArray tmp;
VA_ATTACH(tmp, ARRAY, 3);
GX_ARRAY(d, tmp);

What you need to do is this:

1. Allocate memory for bit-string or octet-string.
static unsigned char BUFFER[3][1];
2. Allocate memory for variants.
static dlmsVARIANT ARRAY[3];
3. Attach allocated memory to variant. The last number tells the maximum bit count.
GX_BIT_STRING(ARRAY[0], BUFFER[0], 8);
2. Allocate memory for variantarray.
static variantArray tmp;
4. Attach variant buffer to variant array.
VA_ATTACH(tmp, ARRAY, 3);
5. Join variant array to gxData value.
GX_ARRAY(ldn.value, tmp);

You can use all data types like this. Ex. UInt16.
static dlmsVARIANT ARRAY[2];
GX_INT16(ARRAY[0]) = 1;
static variantArray tmp;
VA_ATTACH(tmp, ARRAY, 1);
GX_ARRAY(d.value, tmp);
BR,
Mikko

lara.wakim

5 years 6 months ago

Hi Mikko,

Hi Mikko,

Thank you for the explanation.

Sure we were not able to test it because the GX_BIT_STRING() and GX_ARRAY() functions is still not implemented.

When are you expecting to release the new version supporting this new type?

Best Regards,

Lara Wakim

Profile picture for user Kurumi

Kurumi

5 years 6 months ago

Hi,

Hi,

This is just released. Get the latest version.

BR,

Mikko

lara.wakim

5 years 6 months ago

Hello,

Hello,

We downloaded the latest release and we are testing the type array of bit-string and array of octet-string. We were able to create both successfully but we were not able to understand how to manipulate it.

In fact, we want to create an Array [2] of Bit-string[256] with:
- Array[0] = Default value : 1 for all bits
- Array[1] = Default value : 0 for all bits

We were not able to assign the desired values and initialize the array created. How are we supposed to access each bit of the bit-string to set it to 1 or 0?

INIT_OBJECT(eventLogFilter_standardEventLog, DLMS_OBJECT_TYPE_DATA, ln)
static uint32_t BUFFER[2][1];
BUFFER[0][0] = 0;
BUFFER[1][0] = 0xffffffff;
static dlmsVARIANT ARRAY[2];
GX_BIT_STRING(ARRAY[0], BUFFER[0], 256);
GX_BIT_STRING(ARRAY[1], BUFFER[1], 256);
static variantArray tmp;
VA_ATTACH(tmp, ARRAY, 2);
GX_ARRAY(eventLogFilter_standardEventLog.value, tmp);

We wrote this above code expecting to have the result described but we obtained another result (check the picture).

Can you guide us or correct us to obtain what we want? We are not sure if it is a bug or we are not understanding how to use it right.

Best Regards,

Lara Wakim

Image

lara.wakim

5 years 6 months ago

Hello Mikko,

Hello Mikko,

Just want to tell you that we solve the above problem by writing this code:

INIT_OBJECT(eventLogFilter_standardEventLog, DLMS_OBJECT_TYPE_DATA, ln)
static char BUFFER[2][32];
for (int i = 0; i < 32; i++)
{
BUFFER[0][i] = 0xff;
BUFFER[1][i] = 0;
}
static dlmsVARIANT ARRAY[2];
GX_BIT_STRING(ARRAY[0], BUFFER[0], 256);
GX_BIT_STRING(ARRAY[1], BUFFER[1], 256);
static variantArray tmp;
VA_ATTACH(tmp, ARRAY, 2);
GX_ARRAY(eventLogFilter_standardEventLog.value, tmp);

You can check the result in the attached picture.

Best Regards,

Lara Wakim

Image
Profile picture for user Kurumi

Kurumi

5 years 6 months ago

Hi,

Hi,

I'm sorry for the slow reply. I was out of the office yesterday.
You can also create different buffers if you like to. Reading might be easier.
static char BUFFER_1[32];
static char BUFFER_2[32];

BR,
Mikko

lara.wakim

5 years 6 months ago

Hi,

Hi,

No problem.

Thank you for this tip, we will try it later if we find difficulties in reading.

Best Regards,

Lara Wakim

  • 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