We downloaded the latest version and we started the testing. The register activation and script table issues are both solved.
In fact, the tariffication script table will be used in the future to change the active mask depending on the current tariff (by checking the activity calendar). So the action type of this script should be "DLMS_SCRIPT_ACTION_TYPE_WRITE" and not "DLMS_SCRIPT_ACTION_TYPE_EXECUTE" in order to write the active mask of the register activation. So after replacing the action type of the script as following:
ARR_ATTACH(SCRIPTS[0].actions, ACTIONS1, 1);
ACTIONS1[0].type = DLMS_SCRIPT_ACTION_TYPE_WRITE;
ACTIONS1[0].target = BASE(registerActivation);
ACTIONS1[0].index = 4;
We found 2 issues:
1 - We tested and tried to execute the script id 1 from the GXDLMSDirector, an exception was thrown (check the picture). So we followed the code: in the gxinvoke.c file in invoke_ScriptTable() -> if (sa->type == DLMS_SCRIPT_ACTION_TYPE_WRITE) -> cosem_setValue() -> cosem_setRegisterActivation() in the gxsetignoremalloc.c file -> else if (index == 4) -> cosem_getOctetString() -> bb_getUInt8() is throwing an exception "read access violation arr was nullptr". This is the first issue to solve.
2 - We added in the svr_prewrite() the following:
else if (e->target == BASE(registerActivation) && e->index == 4)
{
e->handled = 1;
}
so back in the gxinvoke.c file in invoke_ScriptTable() -> if (sa->type == DLMS_SCRIPT_ACTION_TYPE_WRITE) -> svr_preWrite() -> after that it was supposd not enter cosem_setValue() and svr_postWrite() because e->handled = 1 but it was entering so after checking we noticed that the condition if (!e->handled) should be if (!e1->handled) (replace e by e1 in both cases DLMS_SCRIPT_ACTION_TYPE_WRITE and DLMS_SCRIPT_ACTION_TYPE_EXECUTE). If you can please check it and be sure that this is the problem.
We downloaded the latest release and we were testing the svr_handleActivityCalendar() function.
The season and week profile are working like expected. It is checking also the dayId correctly. What is going wrong is when we are filling the argument of the svr_invoke() function. In the code it is written like this:
(ret = svr_invoke( settings,
(gxObject*)da->script,
(unsigned char)da->scriptSelector,
time,
&tm,
NULL,
&object->executedTime,
next)) != 0)
The third argument of the svr_invoke() function is commonly the index of the method of the object or here we are filling the third argument with the script selector that could be a random number in our example equal to 4.
So when the svr_invoke() function is executed
e->target = target;
e->index = index; (it will be equal to the script selector in our case 2)
so when triggering cosem_invoke(settings, e) ->if (e->index < 1 || e->index > obj_methodCount(e->target)): the function obj_methodCount(e->target) = 1 because the script table has only one method "execute" (index 1). So when checking the condition it will return "DLMS_ERROR_CODE_INVALID_PARAMETER" because e->index = 4 different to 1. So the desired script known by its selector will never be triggered.
Was the explanation of the issue clear enough? or do you need more explanation?
Let me add some information concerning the issue number #1 in the post #1:
- When we try to write directly the active mask of the register activation from the GXDLMSDirector everything is going right without any exception: cosem_setRegisterActivation() -> index = 4 -> cosem_getOctetString(value->byteArr, &object->activeMask) or the value->byteArr is filled with the new active mask correctly
- Back to our issue, when we try to write the active mask by triggering the execute method of the tariffication script as "DLMS_SCRIPT_ACTION_TYPE_WRITE" it is throwing an exception because the value->byteArr is empty and is not filled with any relevant data. So you should fill it with the new active mask before triggering cosem_getOctetString().
Hi,
Hi,
The saving and loading of the object with type value array of bit-string and octet-string are solved.
Thank you!
Best Regards,
Lara Wakim
Hi Lara,
Hi Lara,
Thank you for this info.
BR,
Mikko
Hello Mikko,
Hello Mikko,
We downloaded the latest release and we were testing the svr_handleActivityCalendar() function.
The season and week profile are working like expected. It is checking also the dayId correctly. What is going wrong is when we are filling the argument of the svr_invoke() function. In the code it is written like this:
(ret = svr_invoke( settings,
(gxObject*)da->script,
(unsigned char)da->scriptSelector,
time,
&tm,
NULL,
&object->executedTime,
next)) != 0)
The third argument of the svr_invoke() function is commonly the index of the method of the object or here we are filling the third argument with the script selector that could be a random number in our example equal to 4.
So when the svr_invoke() function is executed
e->target = target;
e->index = index; (it will be equal to the script selector in our case 2)
so when triggering cosem_invoke(settings, e) ->if (e->index < 1 || e->index > obj_methodCount(e->target)): the function obj_methodCount(e->target) = 1 because the script table has only one method "execute" (index 1). So when checking the condition it will return "DLMS_ERROR_CODE_INVALID_PARAMETER" because e->index = 4 different to 1. So the desired script known by its selector will never be triggered.
Was the explanation of the issue clear enough? or do you need more explanation?
Best Regards,
Lara Wakim
Hi,
THESE INFORMATION ARE LINKED TO THE POST #1
Hi,
Let me add some information concerning the issue number #1 in the post #1:
- When we try to write directly the active mask of the register activation from the GXDLMSDirector everything is going right without any exception: cosem_setRegisterActivation() -> index = 4 -> cosem_getOctetString(value->byteArr, &object->activeMask) or the value->byteArr is filled with the new active mask correctly
- Back to our issue, when we try to write the active mask by triggering the execute method of the tariffication script as "DLMS_SCRIPT_ACTION_TYPE_WRITE" it is throwing an exception because the value->byteArr is empty and is not filled with any relevant data. So you should fill it with the new active mask before triggering cosem_getOctetString().
Best Regards,
Lara Wakim
Hi,
Hi,
Tariffication script table write issue is fixed. Get the latest version.
BR,
Mikko
Hi,
Hi,
You are right. This is now fixed. This is tested tomorrow and a new version is released after that.
BR,
Mikko