gxObject* is 16 because you are using 16 bytes addressing. You need to remove it and replace it with the original code. Not your gxData is not fully initialized.
Mikko,
Thanks for your answer, but I don't understand...
I've try to add __ptr32 before to cast in 32 bits the addressing :
gxObject* __ptr32 object,
But it's already in 32 bits addressing ! On CVI, I can use only 32 or 64 bits addressing, not 16.
Yvan
But size, which is int size = cosem_getObjectSize(type) ; where type = DLMS_OBJECT_TYPE_DATA
is : size = sizeof(gxData);
And gxData is :
typedef struct
{
/**
* Base class where class is derived.
*/
gxObject base;
dlmsVARIANT value;
} gxData;
Each : gxObject and dlmsVARIANT is 16, so size is really 32.
But the memset(object, 0, size);, where object is a gxObject* object, is not possible... except if you want to clear object and the next 16 bytes in the RAM.
Yes, the purpose is clear the content of the object. In this case content of the gxData.
I believe that you have missed the base object. The size of the base object is 16 bytes.
I think we are not talking about the same thing ;)
gxData is 32 bytes and gxObject is 16 bytes
We can not use memset of 32 bytes on a 16 bytes buffer.
Some compiler will clear the gxObject and ... 16 other unknown RAM bytes.
My compiler don't want to and break on error.
OK. :-)
I'll ask to install National Instruments CVI and make test build with this code:
const unsigned char ln[6] = { 0, 0, 42, 0, 0, 255 };
gxData data;
cosem_init2(BASE(data), DLMS_OBJECT_TYPE_DATA, ln);
The size of gxData is 32 and this is current and everything works like expected, but what seems to be happening is that CVI is treating object as a pointer to an gxObject and not gxData. This is causing the error. There was an article that if gxObject* is replaced with void* it will solve this. This was tried, but this error is still there. I hope that there is a way to handle this bug id 461C7P34.
There are changes in the source code for the LabWindows/CVI. Get the latest version. There is also an client example for the LabWindows/CVI. You must define objects like this in LabWindows/CVI:
Hi,
Hi,
gxObject* is 16 because you are using 16 bytes addressing. You need to remove it and replace it with the original code. Not your gxData is not fully initialized.
BR,
Mikko
Mikko,
Mikko,
Thanks for your answer, but I don't understand...
I've try to add __ptr32 before to cast in 32 bits the addressing :
gxObject* __ptr32 object,
But it's already in 32 bits addressing ! On CVI, I can use only 32 or 64 bits addressing, not 16.
Yvan
Mikko,
Mikko,
gxObject* object, => 16 bytes
But size, which is int size = cosem_getObjectSize(type) ; where type = DLMS_OBJECT_TYPE_DATA
is : size = sizeof(gxData);
And gxData is :
typedef struct
{
/**
* Base class where class is derived.
*/
gxObject base;
dlmsVARIANT value;
} gxData;
Each : gxObject and dlmsVARIANT is 16, so size is really 32.
But the memset(object, 0, size);, where object is a gxObject* object, is not possible... except if you want to clear object and the next 16 bytes in the RAM.
Am I right ?
Yvan
Hi Yvan,
Hi Yvan,
Yes, the purpose is clear the content of the object. In this case content of the gxData.
I believe that you have missed the base object. The size of the base object is 16 bytes.
const unsigned char ln[6] = { 0, 0, 42, 0, 0, 255 };
gxData data;
cosem_init2(BASE(data), DLMS_OBJECT_TYPE_DATA, ln);
BR,
Mikko
I think we are not talking
I think we are not talking about the same thing ;)
gxData is 32 bytes and gxObject is 16 bytes
We can not use memset of 32 bytes on a 16 bytes buffer.
Some compiler will clear the gxObject and ... 16 other unknown RAM bytes.
My compiler don't want to and break on error.
Hi,
Hi,
OK. :-)
I'll ask to install National Instruments CVI and make test build with this code:
const unsigned char ln[6] = { 0, 0, 42, 0, 0, 255 };
gxData data;
cosem_init2(BASE(data), DLMS_OBJECT_TYPE_DATA, ln);
I'll let you know the results later today.
BR,
Mikko
Hi,
Hi,
The size of gxData is 32 and this is current and everything works like expected, but what seems to be happening is that CVI is treating object as a pointer to an gxObject and not gxData. This is causing the error. There was an article that if gxObject* is replaced with void* it will solve this. This was tried, but this error is still there. I hope that there is a way to handle this bug id 461C7P34.
BR,
Mikko
Mikko,
Mikko,
Thanks for your answer.
I'm trying today to use the server on STM32 target (GCC compiler).
I'll be back with the behavior of this config !
Yvan
Hi Yvan,
Hi Yvan,
There are changes in the source code for the LabWindows/CVI. Get the latest version. There is also an client example for the LabWindows/CVI. You must define objects like this in LabWindows/CVI:
const unsigned char ln[6] = { 0, 0, 42, 0, 0, 255 };
gxData data;
INIT_OBJECT(data, DLMS_OBJECT_TYPE_DATA, ln);
BR,
Mikko
Mikko,
Mikko,
Porting server stack (Nordic Semi directory) on STM32 successful !
No need to change anything in your code.
Now, I have to configure reals COSEM objects and add security...
Yvan
Hi,
Hi,
The source code should work with other compilers. LabWindows/CVI was interesting, but it should work now.
BR,
Mikko