From b8a4e8c7b067a488a40c774f40d4d6fb4fc0352d Mon Sep 17 00:00:00 2001 From: Michael Zillgith Date: Mon, 28 Nov 2016 19:27:08 +0100 Subject: [PATCH] - some fixes --- CHANGELOG | 5 +++++ dotnet/IEC61850forCSharp/IEC61850ClientAPI.cs | 1 - dotnet/IEC61850forCSharp/IEC61850CommonAPI.cs | 21 +++++++++++++++++++ dotnet/IEC61850forCSharp/IEC61850ServerAPI.cs | 18 ---------------- dotnet/IEC61850forCSharp/MmsValue.cs | 11 ++++++++++ dotnet/tests/Test.cs | 8 +++---- examples/server_example2/complexModel.icd | 4 ++-- examples/server_example_config_file/model.cfg | 2 +- src/iec61850/inc/iec61850_client.h | 1 - src/iec61850/server/impl/ied_server.c | 2 +- .../server/model/config_file_parser.c | 3 +-- src/mms/inc_private/mms_common_internal.h | 5 ++--- 12 files changed, 48 insertions(+), 33 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index d05100f..bf84029 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,8 @@ +Changes to version 1.0.1 +------------------------ +- .NET API: fixed bug in client readValue functions +- .NET API: added MmsValue.GetDataAccessError() method + Changes to version 1.0.0 ------------------------ - MMS client/server: implemented obtainFile service diff --git a/dotnet/IEC61850forCSharp/IEC61850ClientAPI.cs b/dotnet/IEC61850forCSharp/IEC61850ClientAPI.cs index b9e01bc..ef6173c 100644 --- a/dotnet/IEC61850forCSharp/IEC61850ClientAPI.cs +++ b/dotnet/IEC61850forCSharp/IEC61850ClientAPI.cs @@ -266,7 +266,6 @@ namespace IEC61850 [DllImport ("iec61850", CallingConvention=CallingConvention.Cdecl)] static extern void MmsValue_delete (IntPtr self); - [DllImport ("iec61850", CallingConvention=CallingConvention.Cdecl)] static extern int MmsValue_getDataAccessError(IntPtr self); diff --git a/dotnet/IEC61850forCSharp/IEC61850CommonAPI.cs b/dotnet/IEC61850forCSharp/IEC61850CommonAPI.cs index ac08ca4..6024dc1 100644 --- a/dotnet/IEC61850forCSharp/IEC61850CommonAPI.cs +++ b/dotnet/IEC61850forCSharp/IEC61850CommonAPI.cs @@ -49,6 +49,27 @@ namespace IEC61850 } } + /// + /// MMS data access error for MmsValue type MMS_DATA_ACCESS_ERROR + /// + public enum MmsDataAccessError { + NO_RESPONSE = -2, /* for server internal purposes only! */ + SUCCESS = -1, + OBJECT_INVALIDATED = 0, + HARDWARE_FAULT = 1, + TEMPORARILY_UNAVAILABLE = 2, + OBJECT_ACCESS_DENIED = 3, + OBJECT_UNDEFINED = 4, + INVALID_ADDRESS = 5, + TYPE_UNSUPPORTED = 6, + TYPE_INCONSISTENT = 7, + OBJECT_ATTRIBUTE_INCONSISTENT = 8, + OBJECT_ACCESS_UNSUPPORTED = 9, + OBJECT_NONE_EXISTENT = 10, + OBJECT_VALUE_INVALID = 11, + UNKNOWN = 12, + } + [Flags] public enum TriggerOptions { NONE = 0, diff --git a/dotnet/IEC61850forCSharp/IEC61850ServerAPI.cs b/dotnet/IEC61850forCSharp/IEC61850ServerAPI.cs index 72ee6de..5dde698 100644 --- a/dotnet/IEC61850forCSharp/IEC61850ServerAPI.cs +++ b/dotnet/IEC61850forCSharp/IEC61850ServerAPI.cs @@ -197,24 +197,6 @@ namespace IEC61850 ACCESS_POLICY_DENY = 1 } - public enum MmsDataAccessError { - DATA_ACCESS_ERROR_NO_RESPONSE = -2, /* for server internal purposes only! */ - DATA_ACCESS_ERROR_SUCCESS = -1, - DATA_ACCESS_ERROR_OBJECT_INVALIDATED = 0, - DATA_ACCESS_ERROR_HARDWARE_FAULT = 1, - DATA_ACCESS_ERROR_TEMPORARILY_UNAVAILABLE = 2, - DATA_ACCESS_ERROR_OBJECT_ACCESS_DENIED = 3, - DATA_ACCESS_ERROR_OBJECT_UNDEFINED = 4, - DATA_ACCESS_ERROR_INVALID_ADDRESS = 5, - DATA_ACCESS_ERROR_TYPE_UNSUPPORTED = 6, - DATA_ACCESS_ERROR_TYPE_INCONSISTENT = 7, - DATA_ACCESS_ERROR_OBJECT_ATTRIBUTE_INCONSISTENT = 8, - DATA_ACCESS_ERROR_OBJECT_ACCESS_UNSUPPORTED = 9, - DATA_ACCESS_ERROR_OBJECT_NONE_EXISTENT = 10, - DATA_ACCESS_ERROR_OBJECT_VALUE_INVALID = 11, - DATA_ACCESS_ERROR_UNKNOWN = 12 - } - public enum DataAttributeType { BOOLEAN = 0, INT8 = 1, diff --git a/dotnet/IEC61850forCSharp/MmsValue.cs b/dotnet/IEC61850forCSharp/MmsValue.cs index 08298c2..ed9787a 100644 --- a/dotnet/IEC61850forCSharp/MmsValue.cs +++ b/dotnet/IEC61850forCSharp/MmsValue.cs @@ -164,6 +164,9 @@ namespace IEC61850 [DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)] static extern ulong MmsValue_getBinaryTimeAsUtcMs (IntPtr self); + [DllImport ("iec61850", CallingConvention=CallingConvention.Cdecl)] + static extern int MmsValue_getDataAccessError(IntPtr self); + internal IntPtr valueReference; /* reference to native MmsValue instance */ private bool responsableForDeletion; /* if .NET wrapper is responsable for the deletion of the native MmsValue instance */ @@ -424,6 +427,14 @@ namespace IEC61850 throw new MmsValueException ("Value is of wrong type"); } + + public MmsDataAccessError GetDataAccessError () + { + int errorCode = MmsValue_getDataAccessError (valueReference); + + return (MmsDataAccessError)errorCode; + } + /// /// Gets the timestamp value as UTC time in s (UNIX time stamp). /// diff --git a/dotnet/tests/Test.cs b/dotnet/tests/Test.cs index 1ff1cce..2b9f4e4 100644 --- a/dotnet/tests/Test.cs +++ b/dotnet/tests/Test.cs @@ -257,14 +257,14 @@ namespace tests iedServer.HandleWriteAccess (opDlTmms, delegate(IEC61850.Server.DataAttribute dataAttr, MmsValue value, ClientConnection con, object parameter) { opDlTmmsValue = value.ToInt32(); - return MmsDataAccessError.DATA_ACCESS_ERROR_SUCCESS; + return MmsDataAccessError.SUCCESS; }, null); iedServer.HandleWriteAccess (rsDlTmms, delegate(IEC61850.Server.DataAttribute dataAttr, MmsValue value, ClientConnection con, object parameter) { if (value.ToInt32() > 1000) - return MmsDataAccessError.DATA_ACCESS_ERROR_OBJECT_VALUE_INVALID; + return MmsDataAccessError.OBJECT_VALUE_INVALID; else - return MmsDataAccessError.DATA_ACCESS_ERROR_SUCCESS; + return MmsDataAccessError.SUCCESS; }, null); iedServer.Start (10002); @@ -310,7 +310,7 @@ namespace tests IedServer iedServer = new IedServer (iedModel); iedServer.HandleWriteAccess (opDlTmms, delegate(IEC61850.Server.DataAttribute dataAttr, MmsValue value, ClientConnection con, object parameter) { - return MmsDataAccessError.DATA_ACCESS_ERROR_SUCCESS; + return MmsDataAccessError.SUCCESS; }, null); diff --git a/examples/server_example2/complexModel.icd b/examples/server_example2/complexModel.icd index 9d5ccea..52cfec6 100644 --- a/examples/server_example2/complexModel.icd +++ b/examples/server_example2/complexModel.icd @@ -18,8 +18,8 @@ - - + + diff --git a/examples/server_example_config_file/model.cfg b/examples/server_example_config_file/model.cfg index ecfea16..7070762 100644 --- a/examples/server_example_config_file/model.cfg +++ b/examples/server_example_config_file/model.cfg @@ -25,7 +25,7 @@ DA(configRev 0 20 5 0 0); DA(ldNs 0 20 11 0 0); } DS(Events){ -DE(GGIO1$ST$SPCSO1$stVal); +DE(simpleIOGenericIO/GGIO1$ST$SPCSO1$stVal); DE(GGIO1$ST$SPCSO2$stVal); DE(GGIO1$ST$SPCSO3$stVal); DE(GGIO1$ST$SPCSO4$stVal); diff --git a/src/iec61850/inc/iec61850_client.h b/src/iec61850/inc/iec61850_client.h index 5cda044..879ae56 100644 --- a/src/iec61850/inc/iec61850_client.h +++ b/src/iec61850/inc/iec61850_client.h @@ -30,7 +30,6 @@ extern "C" { #include "libiec61850_common_api.h" #include "iec61850_common.h" -#include "goose_subscriber.h" #include "mms_value.h" #include "mms_client_connection.h" #include "linked_list.h" diff --git a/src/iec61850/server/impl/ied_server.c b/src/iec61850/server/impl/ied_server.c index 9272532..e407666 100644 --- a/src/iec61850/server/impl/ied_server.c +++ b/src/iec61850/server/impl/ied_server.c @@ -1242,7 +1242,7 @@ IedServer_setWriteAccessPolicy(IedServer self, FunctionalConstraint fc, AccessPo self->writeAccessPolicies &= ~ALLOW_WRITE_ACCESS_SV; break; case IEC61850_FC_SE: - self->writeAccessPolicies &= ALLOW_WRITE_ACCESS_SE; + self->writeAccessPolicies &= ~ALLOW_WRITE_ACCESS_SE; break; default: /* ignore - request is invalid */ break; diff --git a/src/iec61850/server/model/config_file_parser.c b/src/iec61850/server/model/config_file_parser.c index 1d4b67d..cd034e0 100644 --- a/src/iec61850/server/model/config_file_parser.c +++ b/src/iec61850/server/model/config_file_parser.c @@ -242,8 +242,7 @@ ConfigFileParser_createModelFromConfigFile(FileHandle fileHandle) if (matchedItems < 1) goto exit_error; /* remove trailing ')' character */ - int nameLen = strlen(nameString); - nameString[nameLen - 1] = 0; + strtok(nameString, ")"); Log_create(nameString, currentLN); } diff --git a/src/mms/inc_private/mms_common_internal.h b/src/mms/inc_private/mms_common_internal.h index 9552d13..0c97dde 100644 --- a/src/mms/inc_private/mms_common_internal.h +++ b/src/mms/inc_private/mms_common_internal.h @@ -44,9 +44,8 @@ typedef struct { FileHandle fileHandle; } MmsFileReadStateMachine; -//TODO already defined in public API mms_connection.h -typedef void -(*MmsFileReadHandler) (void* parameter, int32_t frsmId, uint8_t* buffer, uint32_t bytesReceived); +/* include for MmsFileReadHandler definition */ +#include "mms_client_connection.h" bool mmsMsg_parseFileOpenResponse(uint8_t* buffer, int bufPos, int maxBufPos, int32_t* frsmId, uint32_t* fileSize, uint64_t* lastModified);