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
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?
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];
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
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
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
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
Hi,
Hi,
This is just released. Get the latest version.
BR,
Mikko
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
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
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
Hi,
Hi,
No problem.
Thank you for this tip, we will try it later if we find difficulties in reading.
Best Regards,
Lara Wakim