From 4c0466c8587a397e7cb181c0e7e74ccbcb6333c1 Mon Sep 17 00:00:00 2001 From: Michael Zillgith Date: Tue, 24 Nov 2015 15:23:26 +0100 Subject: [PATCH] - fixed bug in report timestamp in buffered reporting: was using UTC_TIME instead of BINARY_TIME --- config/stack_config.h | 2 +- dotnet/IEC61850forCSharp/ReportControlBlock.cs | 4 ++-- src/iec61850/client/client_report.c | 4 ++++ src/iec61850/server/mms_mapping/reporting.c | 8 ++++++-- 4 files changed, 13 insertions(+), 5 deletions(-) diff --git a/config/stack_config.h b/config/stack_config.h index aba11f10..b842089c 100644 --- a/config/stack_config.h +++ b/config/stack_config.h @@ -18,7 +18,7 @@ #define DEBUG_ISO_SERVER 0 #define DEBUG_ISO_CLIENT 0 #define DEBUG_IED_SERVER 0 -#define DEBUG_IED_CLIENT 1 +#define DEBUG_IED_CLIENT 0 #define DEBUG_MMS_CLIENT 0 #define DEBUG_MMS_SERVER 0 #define DEBUG_GOOSE_SUBSCRIBER 0 diff --git a/dotnet/IEC61850forCSharp/ReportControlBlock.cs b/dotnet/IEC61850forCSharp/ReportControlBlock.cs index 889e8d61..f4b4a699 100644 --- a/dotnet/IEC61850forCSharp/ReportControlBlock.cs +++ b/dotnet/IEC61850forCSharp/ReportControlBlock.cs @@ -372,6 +372,8 @@ namespace IEC61850 IedConnection_setRCBValues (connection, out error, self, parametersMask, singleRequest); + resetSendFlags(); + if (error != 0) throw new IedConnectionException ("setRCBValues service failed", error); @@ -382,8 +384,6 @@ namespace IEC61850 InstallReportHandler(this.reportHandler, this.reportHandlerParameter); } } - - resetSendFlags(); } /// diff --git a/src/iec61850/client/client_report.c b/src/iec61850/client/client_report.c index f930c4cd..20cc3c1b 100644 --- a/src/iec61850/client/client_report.c +++ b/src/iec61850/client/client_report.c @@ -397,11 +397,15 @@ private_IedConnection_handleReport(IedConnection self, MmsValue* value) /* has report-timestamp */ if (MmsValue_getBitStringBit(optFlds, 2) == true) { + MmsValue* timeStampValue = MmsValue_getElement(value, inclusionIndex); if (MmsValue_getType(timeStampValue) == MMS_BINARY_TIME) { matchingReport->hasTimestamp = true; matchingReport->timestamp = MmsValue_getBinaryTimeAsUtcMs(timeStampValue); + + if (DEBUG_IED_CLIENT) + printf("DEBUG_IED_CLIENT: report has timestamp %llu\n", matchingReport->timestamp); } inclusionIndex++; diff --git a/src/iec61850/server/mms_mapping/reporting.c b/src/iec61850/server/mms_mapping/reporting.c index e10865df..37ad50b0 100644 --- a/src/iec61850/server/mms_mapping/reporting.c +++ b/src/iec61850/server/mms_mapping/reporting.c @@ -1178,6 +1178,8 @@ checkReportBufferForEntryID(ReportControl* rc, MmsValue* value) retVal = true; break; } + + entry = entry->next; } return retVal; @@ -2002,8 +2004,10 @@ sendNextReportEntry(ReportControl* self) if (timeOfEntry == NULL) goto return_out_of_memory; timeOfEntry->deleteValue = 0; - timeOfEntry->type = MMS_UTC_TIME; - MmsValue_setUtcTimeMs(timeOfEntry, report->timeOfEntry); + timeOfEntry->type = MMS_BINARY_TIME; + timeOfEntry->value.binaryTime.size = 6; + + MmsValue_setBinaryTime(timeOfEntry, report->timeOfEntry); if (MemAllocLinkedList_add(reportElements, timeOfEntry) == NULL) goto return_out_of_memory;