- fixed problem with write access to data attribute of type array (LIB61850-336)

v1.6_develop_rgoose_sntp
Michael Zillgith 3 years ago
parent 30f10f6c6d
commit 82e52881f9

@ -236,6 +236,7 @@ static void
installDefaultValuesForDataAttribute(IedServer self, LogicalDevice* ld, DataAttribute* dataAttribute, installDefaultValuesForDataAttribute(IedServer self, LogicalDevice* ld, DataAttribute* dataAttribute,
char* objectReference, int position, int idx, char* componentId, int compIdPos) char* objectReference, int position, int idx, char* componentId, int compIdPos)
{ {
if (dataAttribute->name) {
if (idx == -1) { if (idx == -1) {
sprintf(objectReference + position, ".%s", dataAttribute->name); sprintf(objectReference + position, ".%s", dataAttribute->name);
} }
@ -245,6 +246,7 @@ installDefaultValuesForDataAttribute(IedServer self, LogicalDevice* ld, DataAttr
else else
sprintf(componentId + compIdPos, "$%s", dataAttribute->name); sprintf(componentId + compIdPos, "$%s", dataAttribute->name);
} }
}
char mmsVariableName[65]; /* maximum size is 64 according to 61850-8-1 */ char mmsVariableName[65]; /* maximum size is 64 according to 61850-8-1 */
@ -384,10 +386,12 @@ installDefaultValuesInCache(IedServer self)
{ {
IedModel* model = self->model; IedModel* model = self->model;
char objectReference[130];
char componentId[130]; char componentId[130];
componentId[0] = 0; componentId[0] = 0;
char objectReference[130];
LogicalDevice* logicalDevice = model->firstChild; LogicalDevice* logicalDevice = model->firstChild;
while (logicalDevice != NULL) { while (logicalDevice != NULL) {
@ -409,6 +413,7 @@ installDefaultValuesInCache(IedServer self)
int refPosition = strlen(objectReference); int refPosition = strlen(objectReference);
while (dataObject != NULL) { while (dataObject != NULL) {
componentId[0] = 0;
installDefaultValuesForDataObject(self, logicalDevice, dataObject, objectReference, refPosition, -1, componentId, 0); installDefaultValuesForDataObject(self, logicalDevice, dataObject, objectReference, refPosition, -1, componentId, 0);
dataObject = (DataObject*) dataObject->sibling; dataObject = (DataObject*) dataObject->sibling;

@ -117,19 +117,30 @@ createNamedVariableFromDataAttribute(DataAttribute* attribute)
{ {
MmsVariableSpecification* origNamedVariable = (MmsVariableSpecification*) GLOBAL_CALLOC(1, MmsVariableSpecification* origNamedVariable = (MmsVariableSpecification*) GLOBAL_CALLOC(1,
sizeof(MmsVariableSpecification)); sizeof(MmsVariableSpecification));
if (attribute->name)
origNamedVariable->name = StringUtils_copyString(attribute->name); origNamedVariable->name = StringUtils_copyString(attribute->name);
else
origNamedVariable->name = NULL;
MmsVariableSpecification* namedVariable = origNamedVariable; MmsVariableSpecification* namedVariable = origNamedVariable;
if (attribute->elementCount > 0) { bool isBasicArray = false;
if (attribute->elementCount > 0)
{
namedVariable->type = MMS_ARRAY; namedVariable->type = MMS_ARRAY;
namedVariable->typeSpec.array.elementCount = attribute->elementCount; namedVariable->typeSpec.array.elementCount = attribute->elementCount;
namedVariable->typeSpec.array.elementTypeSpec = (MmsVariableSpecification*) GLOBAL_CALLOC(1, namedVariable->typeSpec.array.elementTypeSpec = (MmsVariableSpecification*) GLOBAL_CALLOC(1,
sizeof(MmsVariableSpecification)); sizeof(MmsVariableSpecification));
namedVariable = namedVariable->typeSpec.array.elementTypeSpec; namedVariable = namedVariable->typeSpec.array.elementTypeSpec;
if (attribute->firstChild && ((DataAttribute*)(attribute->firstChild))->type != IEC61850_CONSTRUCTED) {
isBasicArray = true;
}
} }
if (attribute->firstChild != NULL) { if ((attribute->firstChild != NULL) && (isBasicArray == false)) {
namedVariable->type = MMS_STRUCTURE; namedVariable->type = MMS_STRUCTURE;
int componentCount = ModelNode_getChildCount((ModelNode*) attribute); int componentCount = ModelNode_getChildCount((ModelNode*) attribute);

@ -680,7 +680,6 @@ exit_error:
static void static void
handleAsyncResponse(MmsConnection self, ByteBuffer* response, uint32_t bufPos, MmsOutstandingCall outstandingCall, MmsError err) handleAsyncResponse(MmsConnection self, ByteBuffer* response, uint32_t bufPos, MmsOutstandingCall outstandingCall, MmsError err)
{ {
if (outstandingCall->type == MMS_CALL_TYPE_READ_VARIABLE) { if (outstandingCall->type == MMS_CALL_TYPE_READ_VARIABLE) {
MmsConnection_ReadVariableHandler handler = MmsConnection_ReadVariableHandler handler =

@ -111,6 +111,8 @@ mmsClient_parseListOfAccessResults(AccessResult_t** accessResultList, int listSi
if (componentCount > 0) { if (componentCount > 0) {
value = (MmsValue*) GLOBAL_CALLOC(1, sizeof(MmsValue)); value = (MmsValue*) GLOBAL_CALLOC(1, sizeof(MmsValue));
if (value) {
value->type = MMS_STRUCTURE; value->type = MMS_STRUCTURE;
value->value.structure.size = componentCount; value->value.structure.size = componentCount;
value->value.structure.components = (MmsValue**) GLOBAL_CALLOC(componentCount, sizeof(MmsValue*)); value->value.structure.components = (MmsValue**) GLOBAL_CALLOC(componentCount, sizeof(MmsValue*));
@ -132,7 +134,7 @@ mmsClient_parseListOfAccessResults(AccessResult_t** accessResultList, int listSi
} }
} }
} }
}
} }
else { else {
if (DEBUG_MMS_CLIENT) if (DEBUG_MMS_CLIENT)

@ -29,6 +29,9 @@
void void
MmsVariableSpecification_destroy(MmsVariableSpecification* typeSpec) MmsVariableSpecification_destroy(MmsVariableSpecification* typeSpec)
{ {
if (typeSpec == NULL)
return;
if (typeSpec->name != NULL) if (typeSpec->name != NULL)
GLOBAL_FREEMEM(typeSpec->name); GLOBAL_FREEMEM(typeSpec->name);

@ -173,19 +173,18 @@ searchCacheForValueEx(MmsValueCache self, const char* itemId, char* parentId, in
const char* childId = getChildSubString(itemId, parentId); const char* childId = getChildSubString(itemId, parentId);
if (childId) { if (childId) {
MmsVariableSpecification* typeSpec = MmsDomain_getNamedVariable(self->domain, parentId); MmsVariableSpecification* typeSpec = MmsDomain_getNamedVariable(self->domain, parentId);
value = MmsVariableSpecification_getChildValue(typeSpec, cacheEntry->value, childId); value = MmsVariableSpecification_getChildValue(typeSpec, cacheEntry->value, childId);
if (value) { if (value) {
if (idx != -1) { if (idx != -1) {
if (MmsValue_getType(value) == MMS_ARRAY) { if (MmsValue_getType(value) == MMS_ARRAY) {
MmsValue* elementValue = MmsValue_getElement(value, idx); MmsValue* elementValue = MmsValue_getElement(value, idx);
if (elementValue) { if (elementValue) {
if (componentId) { if ((componentId != NULL) && (componentId[0] != 0)) {
MmsVariableSpecification* childSpec = MmsVariableSpecification_getNamedVariableRecursive(typeSpec, childId); MmsVariableSpecification* childSpec = MmsVariableSpecification_getNamedVariableRecursive(typeSpec, childId);
if (childSpec) { if (childSpec) {

Loading…
Cancel
Save