Reset method of the Register class crashing

Project: 
gurux.dlms.c

The reset() method of the Register (ID = 3) class was throwing an unhandled error inside of the function "invoke_register()" in the file “gxinvoke.c” (especially inside the function bb_clear). This issue was momently solved by commenting "bb_clear(e->value, byteArr);" in the "invoke_register" function.

The "var_clear" function in the "invoke_register" function should reset the value of the register, but it did not. The DLMS_DATA_TYPE of the value of the object introduced as an argument for the function "var_clear" was not handled inside.

To solve momently this issue in the server example 2, I added in the file “exampleserver.c” inside the "svr_postAction" function this part of code below to reset the value of the activePowerL1 and it worked:

// Reset activePowerL1 to the initial value
else if (e->target == BASE(activePowerL1) && e->index == 1)
{
activePowerL1Value = 0;
}

Status: 
Closed (works as designed)
Priority: 
Normal
Category: 
Bug report
Component: 
Code
Reporter: 
lara.wakim
Created: 
Thu, 06/11/2020 - 14:40
Updated: 
Mon, 06/15/2020 - 12:42

Comments

Administrator's picture

Status: Active » Closed (fixed)

Hi,

We noticed that you erased the function "bb_clear" in the function "invoke_register" in the file "gxinvoke.c" that has been throwing error previously.

After testing, the old errors are gone but new issues due to the changes have appeared.

In fact, when i tried to read the register value before resetting, it worked fine. But when i reset the value and i tried to read it again, no value appeared in the GXDLMSDirector.

After tracking the code, we are supposing that the error came from: the file "gxset.c" in the function "cosem_getRegister" in the index 2, the function "var_copy" is taking value of type "DLMS_DATA_TYPE_NONE".

Kurumi's picture

Hi,
There is no default value. With some registers default value might be 100 and some it might be 0.
For this reason this must be set to default value in preAction or postAction. This is updated to the next example server.

Document is now improved.
https://www.gurux.fi/Gurux.DLMS.Objects.GXDLMSRegister

BR,
Mikko

Kurumi's picture

Status: Closed (fixed) » Closed (works as designed)

Hi,

In the server example 2, I added in the file “exampleserver.c” inside the "svr_postAction" function this part of code below to reset the value of the activePowerL1 and it worked:

// [LW] : Reset activePowerL1 to the initial value
else if (e->target == BASE(activePowerL1) && e->index == 1)
{
activePowerL1Value = 0;
GX_UINT32_BYREF(activePowerL1.value, activePowerL1Value);
}

Thank you.

Kurumi's picture

Hi,

set e->handled = 1 if you set this by yourself.

BR,
Mikko

Hi,

Okay I will. We have a question.

We realized that the GX DLMS Director is always triggering automatically the reading of the same register object after finishing the reset action. This extra step is only happening for the Register classes. Do you have any specific explanation?

Kurumi's picture

Hi Lara,

Please, ask question in the forum.
Reason for this is that value is changed and it was found very useful when new meters are tested. Sometimes value was not reset in the meter and tester didn't check it.

BR,
Mikko