Hello.
Im triying to create a COSEM object class_id = 1 (DLMS_OBJECT_TYPE_DATA) of type structure. This structure will contain 4 different values. First 2 of them will be uint32 and last 2 will be int32.
The way i'm creating this object is the following:
gxData myMEASURES;
static dlmsVARIANT vUA, vIA, vPA, vQA;
uint32_t g_rmsUA, g_rmsIA;
int32_t g_rmsPA, g_rmsQA;
#define MAX_MEASURES 4
static dlmsVARIANT arrElements[MAX_MEASURES];
static variantArray arrBuf;
int addDataObject()
{
int ret;
const unsigned char ln[6] = { 1, 0, 99, 199, 0, 255 };
if ((ret = INIT_OBJECT(myMEASURES, DLMS_OBJECT_TYPE_DATA, ln)) == 0)
{
//Inicializo array de dlmsVariant
arrBuf.data = arrElements;
arrBuf.capacity = MAX_MEASURES;
arrBuf.size = 0;
//Inicializo objeto gurux
va_init(&myMEASURES.value);
myMEASURES.value.vt = DLMS_DATA_TYPE_STRUCTURE;
myMEASURES.value.Arr = &arrBuf;
va_init(&vUA);
vUA.vt = DLMS_DATA_TYPE_UINT32;
GX_UINT32_BYREF(vUA, g_rmsUA);
va_push(myMEASURES.value.Arr, &vUA);
va_init(&vIA);
vIA.vt = DLMS_DATA_TYPE_UINT32;
GX_UINT32_BYREF(vIA, g_rmsIA);
va_push(myMEASURES.value.Arr, &vIA);
va_init(&vPA);
vPA.vt = DLMS_DATA_TYPE_INT32;
GX_INT32_BYREF(vPA, g_rmsPA);
va_push(myMEASURES.value.Arr, &vPA);
va_init(&vQA);
vQA.vt = DLMS_DATA_TYPE_INT32;
GX_INT32_BYREF(vQA, g_rmsQA);
va_push(myMEASURES.value.Arr, &vQA);
}
return ret;
}
On srv preAction function, I'm assigning value to g_rmsUA, g_rmsIA, g_rmsPA and g_rmsQA.
When i try to read with GXDLMSDirector i get the following message.
"Failed to convert data type to DLMS data type. Unknown data type."
The message I'm getting from the server is:
C4 01 C1 00 02 04 20 00 85 00 00 00
When i try to translate with DLMS translator to XML i get the same error.
How should i define the object so i dont get this error?
Thanks!
Pablo
Hi Pablo, I tested your codeā¦
Hi Pablo,
I tested your code this and it works without problems.
You need to update the values on svr_preRead, not in preAction.
https://gurux.fi/Gurux.DLMS.Server
I used this code in svr_preRead to increase values for every read.
++g_rmsUA;
++g_rmsIA;
++g_rmsPA;
++g_rmsQA;
BR,
Mikko