Hello,
I’ve successfully developed a DLMS host in C using the Gurux ANSI C library. It runs on a microcontroller with limited resources.
In the provided examples, the library uses dynamic memory (malloc()/free()). As you probably know, is not ideal on a microcontroller because memory fragmentation can happen.
To make the host more robust, I uncommented #DLMS_IGNORE_MALLOC in gxignore.h.
My problem is that I still need several functions declared in client.h, and those prototypes are only available when DLMS_IGNORE_MALLOC is not defined.
My question is, is it possible to implement a host without using malloc() and free()?
If so, is there anay example available?
Thanks
Pablo
Hi Pablo, If you need to…
Hi Pablo,
If you need to implement the client-side, you need malloc.
The reason is that the client is unaware of the type of data the meter is returning, and it needs to allocate the memory after the data is read from the meter.
The meter side can be implemented without malloc, because the meter defines what data it wants to offer and in what format.
BR,
Mikko
Hello Kurumi, thank you so…
Hello Kurumi, thank you so much for your answer.
Is it possible to create variables with a fixed size so that, if the data received is larger than the available space, an error is returned?
Would it be possible to modify the client.h functions to work this way, or is that too messy and not recommended?
Could we get support with these modifications?
Thanks!
Pablo
Hi Pablo, The meter can…
Hi Pablo,
The meter can return any kind of data. If you want to implement a gateway, etc, where the client reads data from the meter and then sends the received data to the HES, you don't need to parse data. You can just send it to the HES without parsing.
You can ignore the cl_updateValue and send the received bytes.
Parsing data might take a lot of memory, and if you want to parse the data on an MCU, it must be done in parts.
BR,
Mikko