From c9d9271a5263e8b125bcbd78e4ec2635ef760afb Mon Sep 17 00:00:00 2001 From: Michael Zillgith Date: Mon, 29 May 2023 15:40:13 +0100 Subject: [PATCH] - fixed - arrays of complex data attributes not handled correctly (LIB61850-408) --- src/iec61850/server/mms_mapping/mms_mapping.c | 5 +++-- src/iec61850/server/model/dynamic_model.c | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/iec61850/server/mms_mapping/mms_mapping.c b/src/iec61850/server/mms_mapping/mms_mapping.c index 813f9566..8e63e66c 100644 --- a/src/iec61850/server/mms_mapping/mms_mapping.c +++ b/src/iec61850/server/mms_mapping/mms_mapping.c @@ -139,7 +139,7 @@ createNamedVariableFromDataAttribute(DataAttribute* attribute) sizeof(MmsVariableSpecification)); namedVariable = namedVariable->typeSpec.array.elementTypeSpec; - if (attribute->firstChild && ((DataAttribute*)(attribute->firstChild))->type != IEC61850_CONSTRUCTED) { + if (attribute->type != IEC61850_CONSTRUCTED) { isBasicArray = true; } } @@ -160,7 +160,8 @@ createNamedVariableFromDataAttribute(DataAttribute* attribute) DataAttribute* subDataAttribute = (DataAttribute*) attribute->firstChild; int i = 0; - while (subDataAttribute != NULL) { + while (subDataAttribute) + { namedVariable->typeSpec.structure.elements[i] = createNamedVariableFromDataAttribute(subDataAttribute); diff --git a/src/iec61850/server/model/dynamic_model.c b/src/iec61850/server/model/dynamic_model.c index 9b0a53fd..790c9be3 100644 --- a/src/iec61850/server/model/dynamic_model.c +++ b/src/iec61850/server/model/dynamic_model.c @@ -688,7 +688,7 @@ DataAttribute_create(const char* name, ModelNode* parent, DataAttributeType type self->triggerOptions = triggerOptions; self->sAddr = sAddr; - if ((arrayElements > 0) && (type != IEC61850_CONSTRUCTED)) { + if (arrayElements > 0) { int i; for (i = 0; i < arrayElements; i++) { @@ -703,7 +703,7 @@ DataAttribute_create(const char* name, ModelNode* parent, DataAttributeType type arrayElement->fc = fc; arrayElement->firstChild = NULL; arrayElement->mmsValue = NULL; - arrayElement->parent = parent; + arrayElement->parent = (ModelNode*)self; arrayElement->sibling = NULL; arrayElement->triggerOptions = triggerOptions; arrayElement->sAddr = sAddr;