Hi,
I have an issue when reading the associating list when using the server of the ansi C library.
I have adapted (or at least tried to) the AtMega2560 example using the same serialization functions as the NordicSemiconductor example for a stm32 microcontroller.
When using GXDLMSDirector I can connect it will show all objects but the last one, if I change the order of items, it’s always the last one that won’t appear.
If I try to read the association manually, I get an error indicating that the argument it’s outside the valid value interval (sorry for the bad translation, this error appears in my language). I add the log in a pastebin url to see if it helps. https://pastebin.com/nLRi4guR
Mi gxignore.h looks like this: https://pastebin.com/3rzc8fsL
I have tried:
- Changing order -> always the last one won’t appear when associating after connecting.
- Adding a 0 at end of ALL_OBJECTS list -> Every object appears but the error when reading manually persist.
Thanks in advances, let me know if more info is needed.
Hi,
Thanks for the reply.
In this case the object missing is the clock 0.0.1.0.0.255 (it’s the last one in the ALL_OBJECTS list):
I add the objects to my server following the example (I add a pastebin url so you can see the code). https://pastebin.com/B3RmCit9
I don’t recall adding the object 0.0.40.0.1.255 manually, I guess that it happened internal.
I have tested to add the object to the GXDLMSDirector manually and it works and can read it.
I don’t really understand the serialization part of the code, maybe it’s there the problem, I have added that part to the pastebin too, so I don’t know what you mean by “make sure that the serialization load doesn't hide it”.
Thanks for your time and early response.
Hi,
I fixed the association error about the not valid interval adding the following line:
association.xDLMSContextInfo.conformance = DLMS_CONFORMANCE_GET;
But I still can’t read the last object of the list, I have tried adding a zero at the end of the list and it seems to work until I add more objects and the microcontroller tried to access a non-accessible memory address from preRead in the instruction:
type = (DLMS_OBJECT_TYPE)e->target->objectType;
After that I deleted the zero but the error continues.
Debugging I have seen how the value get filled with some weird values ( see image attached).
This happens when I just connect and read the available objects of my meter. After that If I reset my server and connect again with the objects already discovered I can read them without problem.
Do you have any recommendation to debug this problem?
Thanks for your time
Hello!
In DLMS.c file gxget.c function getLNObjects().
First saving objects quantity in buffer for transmission, next increment this quantity. As result, DLMSDirector does not see last item.
Working correctly with this changes:
e->transaction EndIndex = count;
if (!found) // added
++count;
if ((ret = cosem_set Array(data, count)) != 0)
{
return ret;
}
if (!found)
{
// ++// ++count; // removed
//Count
if ((ret = cosem_set Structure(data, 4)) != 0 ||
Fon Luck is right. Those lines were removed in version 20220127.1 to fix another issue. This is now fixed for the last version. I believe it will also fix Vitaol's problem with scalers and units.
Hi,
Thank you for the new version, it has solved the last element no showing but I still get the crash when reading scalers and units.
I have test it changing the number of elements in the list and I discovered that if I use 5 elements or less it works fine, but if I use 6 or more it crashes.
BR
Scalers and units are read with a different method. How many registers you have added? Can you add a hex trace from GXDLMSDirector so I can try to check what is the problem?
Hi,
Thanks for your time and dedication.
My code is far simpler that the one you posted, I took the atmega example as base:
(https://github.com/Gurux/GuruxDLMS.c/blob/master/Atmel/AtMega2560/Gurux…)
I'll try to complete it with your code. Unfortunately, I can’t test your code directly because I’m not working with Arduino, It will take me some time, I’ll let you know if it works.
Thank you,
BR
Hi,
Hi,
You have added four objects to the association view:
0.0.40.0.0.255
0.0.40.0.1.255
Data: 0.0.42.0.0.255
Register: 1.1.21.25.0.255
Can you share what object is missing?
Have you added COSEM objects for the source code or are you adding them from the GXDLMSDirector?
If you have added one object for the source code make sure that the serialization load doesn't hide it.
BR,
Mikko
Hi,
Hi,
Thanks for the reply.
In this case the object missing is the clock 0.0.1.0.0.255 (it’s the last one in the ALL_OBJECTS list):
I add the objects to my server following the example (I add a pastebin url so you can see the code).
https://pastebin.com/B3RmCit9
I don’t recall adding the object 0.0.40.0.1.255 manually, I guess that it happened internal.
I have tested to add the object to the GXDLMSDirector manually and it works and can read it.
I don’t really understand the serialization part of the code, maybe it’s there the problem, I have added that part to the pastebin too, so I don’t know what you mean by “make sure that the serialization load doesn't hide it”.
Thanks for your time and early response.
Hi,
Hi,
I fixed the association error about the not valid interval adding the following line:
association.xDLMSContextInfo.conformance = DLMS_CONFORMANCE_GET;
But I still can’t read the last object of the list, I have tried adding a zero at the end of the list and it seems to work until I add more objects and the microcontroller tried to access a non-accessible memory address from preRead in the instruction:
type = (DLMS_OBJECT_TYPE)e->target->objectType;
After that I deleted the zero but the error continues.
Debugging I have seen how the value get filled with some weird values ( see image attached).
This happens when I just connect and read the available objects of my meter. After that If I reset my server and connect again with the objects already discovered I can read them without problem.
Do you have any recommendation to debug this problem?
Thanks for your time
Hello!
Hello!
In DLMS.c file gxget.c function getLNObjects().
First saving objects quantity in buffer for transmission, next increment this quantity. As result, DLMSDirector does not see last item.
Working correctly with this changes:
e->transaction EndIndex = count;
if (!found) // added
++count;
if ((ret = cosem_set Array(data, count)) != 0)
{
return ret;
}
if (!found)
{
// ++// ++count; // removed
//Count
if ((ret = cosem_set Structure(data, 4)) != 0 ||
Lot of thanks,
Lot of thanks,
Now I can see al elements but the microcontroller keep crashing at the same function.
Any Idea why could it be?
Thanks again
It seems to be while trying
It seems to be while trying to read scalers and units.
Hi,
Hi,
Fon Luck is right. Those lines were removed in version 20220127.1 to fix another issue. This is now fixed for the last version. I believe it will also fix Vitaol's problem with scalers and units.
BR,
Mikko
Hi,
Hi,
Thank you for the new version, it has solved the last element no showing but I still get the crash when reading scalers and units.
I have test it changing the number of elements in the list and I discovered that if I use 5 elements or less it works fine, but if I use 6 or more it crashes.
BR
Hi,
Hi,
Scalers and units are read with a different method. How many registers you have added? Can you add a hex trace from GXDLMSDirector so I can try to check what is the problem?
BR,
Mikko
Hi,
Hi,
Here you have the trace:
https://pastebin.com/QUhWjKyQ
I have added 8 register, here you have the code:
https://pastebin.com/Q0vTL85z
Thank you
Hi,
Hi,
Your code is now tested 100 times and it worked without problems every time. The source code is here:
https://pastebin.com/dLJbk6xV
Only those lines were commented.
// RMSMeasuresRegs* ptrRMS = ade9000GetRMSPtr();
// TemperatureRegs* ptrTemp = ade9000GetTempPtr();
Can you try this and let me know if you have problems?
BR,
Mikko
Hi!
Hi!
The old code with my corrections works well
Hi,
Hi,
Thanks for your time and dedication.
My code is far simpler that the one you posted, I took the atmega example as base:
(https://github.com/Gurux/GuruxDLMS.c/blob/master/Atmel/AtMega2560/Gurux…)
I'll try to complete it with your code. Unfortunately, I can’t test your code directly because I’m not working with Arduino, It will take me some time, I’ll let you know if it works.
Thank you,
BR
Hi,
Hi,
I got it working. It was my fault, I wasn’t ignoring malloc. Once I ignored it and adapted the Arduino server code it worked.
Thank you.
Hi,
Hi,
Thank you for letting me know this. There are so many settings in DLMS and the reason might be anything.
BR,
Mikko