From 287769dcbaaffac09e02aad3801467d87d1baa44 Mon Sep 17 00:00:00 2001 From: Michael Zillgith Date: Tue, 12 Mar 2019 15:19:08 +0100 Subject: [PATCH] - IEC 61850 client: handle reason code correctly when report contains data with different reason code (see github #133) --- src/iec61850/client/client_report.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/iec61850/client/client_report.c b/src/iec61850/client/client_report.c index 41683a41..425db7ad 100644 --- a/src/iec61850/client/client_report.c +++ b/src/iec61850/client/client_report.c @@ -686,8 +686,6 @@ iedConnection_handleReport(IedConnection self, MmsValue* value) if (hasReasonForInclusion) matchingReport->hasReasonForInclusion = true; - int reasonForInclusionIndex = valueIndex + includedElements; - for (i = 0; i < dataSetSize; i++) { if (MmsValue_getBitStringBit(inclusion, i) == true) { @@ -710,10 +708,8 @@ iedConnection_handleReport(IedConnection self, MmsValue* value) if (DEBUG_IED_CLIENT) printf("IED_CLIENT: update element value type: %i\n", MmsValue_getType(newElementValue)); - valueIndex++; - if (hasReasonForInclusion) { - MmsValue* reasonForInclusion = MmsValue_getElement(value, reasonForInclusionIndex); + MmsValue* reasonForInclusion = MmsValue_getElement(value, includedElements + valueIndex); if ((reasonForInclusion == NULL) || (MmsValue_getType(reasonForInclusion) != MMS_BIT_STRING)) { if (DEBUG_IED_CLIENT) @@ -736,6 +732,8 @@ iedConnection_handleReport(IedConnection self, MmsValue* value) else { matchingReport->reasonForInclusion[i] = IEC61850_REASON_UNKNOWN; } + + valueIndex++; } else { matchingReport->reasonForInclusion[i] = IEC61850_REASON_NOT_INCLUDED;