From 550b5ddc07cf28e3d9458843e2415568b6e796f9 Mon Sep 17 00:00:00 2001 From: Dmitry Yatcenko Date: Thu, 16 Mar 2023 12:58:25 +0500 Subject: [PATCH] =?UTF-8?q?1=20=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D0=B0=20=D1=84=D1=83=D0=BD=D0=BA=D1=86=D0=B8=D1=8F?= =?UTF-8?q?=20IedConnection=5FreadObject.=20=D0=94=D0=BE=D0=B1=D0=B0=D0=B2?= =?UTF-8?q?=D0=BB=D0=B5=D0=BD=D0=B0=20=D0=BF=D1=80=D0=BE=D0=B2=D0=B5=D1=80?= =?UTF-8?q?=D0=BA=D0=B0=20=D0=B7=D0=BD=D0=B0=D1=87=D0=B5=D0=BD=D0=B8=D1=8F?= =?UTF-8?q?=202=20=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB=D0=B5=D0=BD?= =?UTF-8?q?=D1=8B=20IedConnetion=5FgetDataDirectory,=20IedConnection=5Fget?= =?UTF-8?q?LogicalNodeDirectory.=20=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2?= =?UTF-8?q?=D0=BB=D0=B5=D0=BD=20=D0=B2=D1=8B=D0=B2=D0=BE=D0=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/iec61850/client/ied_connection.c | 88 ++++++++++++---------------- 1 file changed, 38 insertions(+), 50 deletions(-) diff --git a/src/iec61850/client/ied_connection.c b/src/iec61850/client/ied_connection.c index c97c3894..f2960f35 100644 --- a/src/iec61850/client/ied_connection.c +++ b/src/iec61850/client/ied_connection.c @@ -105,9 +105,6 @@ iedConnection_mapMmsErrorToIedError(MmsError mmsError) case MMS_ERROR_DEFINITION_OBJECT_UNDEFINED: return IED_ERROR_OBJECT_UNDEFINED; - case MMS_ERROR_ACCESS_TEMPORARILY_UNAVAILABLE: - return IED_ERROR_TEMPORARILY_UNAVAILABLE; - default: return IED_ERROR_UNKNOWN; } @@ -684,7 +681,6 @@ IedConnection_getInvokeId(IedConnection self) else return 0; } - void IedConnection_setTimeQuality(IedConnection self, bool leapSecondKnown, bool clockFailure, bool clockNotSynchronized, int subsecondPrecision) { @@ -915,7 +911,7 @@ IedConnection_getVariableSpecification(IedConnection self, IedClientError* error *error = IED_ERROR_OK; else *error = iedConnection_mapMmsErrorToIedError(mmsError); - + cleanup_and_exit: return varSpec; @@ -1257,6 +1253,9 @@ IedConnection_readObject(IedConnection self, IedClientError* error, const char* else *error = iedConnection_mapMmsErrorToIedError(mmsError); + if (MmsValue_getType(value) == MMS_DATA_ACCESS_ERROR) + *error = iedConnection_mapDataAccessErrorToIedError(MmsValue_getDataAccessError(value)); + return value; } @@ -2474,7 +2473,7 @@ IedConnection_getLogicalNodeDirectory(IedConnection self, IedClientError* error, if (strlen(logicalNodeReference) > 129) { *error = IED_ERROR_OBJECT_REFERENCE_INVALID; - return NULL; + return ' '; } char lnRefCopy[130]; @@ -2485,7 +2484,7 @@ IedConnection_getLogicalNodeDirectory(IedConnection self, IedClientError* error, if (ldSep == NULL) { *error = IED_ERROR_USER_PROVIDED_INVALID_ARGUMENT; - return NULL; + return ' '; } *ldSep = 0; @@ -2504,7 +2503,7 @@ IedConnection_getLogicalNodeDirectory(IedConnection self, IedClientError* error, IedConnection_getDeviceModelFromServer(self, error); if (*error != IED_ERROR_OK) - return NULL; + return ' '; /* search for logical device */ @@ -2525,7 +2524,7 @@ IedConnection_getLogicalNodeDirectory(IedConnection self, IedClientError* error, if (ld == NULL) { *error = IED_ERROR_OBJECT_REFERENCE_INVALID; - return NULL; + return ' '; } LinkedList lnDirectory = LinkedList_create(); @@ -2625,14 +2624,14 @@ IedConnection_getLogicalNodeVariables(IedConnection self, IedClientError* error, if (strlen(logicalNodeReference) > 129) { *error = IED_ERROR_OBJECT_REFERENCE_INVALID; - return NULL; + return ' '; } if (self->logicalDevices == NULL) IedConnection_getDeviceModelFromServer(self, error); if (*error != IED_ERROR_OK) - return NULL; + return ' '; char lnRefCopy[130]; @@ -2642,7 +2641,7 @@ IedConnection_getLogicalNodeVariables(IedConnection self, IedClientError* error, if (ldSep == NULL) { *error = IED_ERROR_OBJECT_REFERENCE_INVALID; - return NULL; + return ' '; } *ldSep = 0; @@ -2670,7 +2669,7 @@ IedConnection_getLogicalNodeVariables(IedConnection self, IedClientError* error, if (ld == NULL) { *error = IED_ERROR_OBJECT_REFERENCE_INVALID; - return NULL; + return ' '; } if (DEBUG_IED_CLIENT) @@ -2708,14 +2707,14 @@ getDataDirectory(IedConnection self, IedClientError* error, if (strlen(dataReference) > 129) { *error = IED_ERROR_OBJECT_REFERENCE_INVALID; - return NULL; + return ' '; } if (self->logicalDevices == NULL) IedConnection_getDeviceModelFromServer(self, error); if (*error != IED_ERROR_OK) - return NULL; + return ' '; char dataRefCopy[130]; @@ -2733,7 +2732,7 @@ getDataDirectory(IedConnection self, IedClientError* error, if (logicalNodeNameEnd == NULL) { *error = IED_ERROR_OBJECT_REFERENCE_INVALID; - return NULL; + return ' '; } int logicalNodeNameLen = (int)(logicalNodeNameEnd - logicalNodeName); @@ -2744,7 +2743,7 @@ getDataDirectory(IedConnection self, IedClientError* error, if (dataNamePartLen < 1) { *error = IED_ERROR_OBJECT_REFERENCE_INVALID; - return NULL; + return ' '; } StringUtils_replace(dataNamePart, '.', '$'); @@ -3307,18 +3306,7 @@ uint32_t IedConnection_createDataSetAsync(IedConnection self, IedClientError* error, const char* dataSetReference, LinkedList /* char* */ dataSetElements, IedConnection_GenericServiceHandler handler, void* parameter) { - MmsError mmsError = MMS_ERROR_NONE; - - IedConnectionOutstandingCall call = iedConnection_allocateOutstandingCall(self); - - if (call == NULL) { - *error = IED_ERROR_OUTSTANDING_CALL_LIMIT_REACHED; - goto exit_function; - } - - call->callback = handler; - call->callbackParameter = parameter; - call->invokeId = 0; + uint32_t invokeId = 0; char domainIdBuffer[65]; char itemIdBuffer[DATA_SET_MAX_NAME_LENGTH + 1]; @@ -3362,6 +3350,19 @@ IedConnection_createDataSetAsync(IedConnection self, IedClientError* error, cons isAssociationSpecific = true; } + MmsError mmsError; + + IedConnectionOutstandingCall call = iedConnection_allocateOutstandingCall(self); + + if (call == NULL) { + *error = IED_ERROR_OUTSTANDING_CALL_LIMIT_REACHED; + goto exit_function; + } + + call->callback = handler; + call->callbackParameter = parameter; + call->invokeId = 0; + LinkedList dataSetEntries = LinkedList_create(); LinkedList dataSetElement = LinkedList_getNext(dataSetElements); @@ -3390,6 +3391,8 @@ IedConnection_createDataSetAsync(IedConnection self, IedClientError* error, cons &mmsError, domainId, itemId, dataSetEntries, createDataSetAsyncHandler, self); } + invokeId = call->invokeId; + *error = iedConnection_mapMmsErrorToIedError(mmsError); cleanup_list: @@ -3397,15 +3400,7 @@ cleanup_list: LinkedList_destroyDeep(dataSetEntries, (LinkedListValueDeleteFunction) MmsVariableAccessSpecification_destroy); exit_function: - - if (*error != IED_ERROR_OK) { - iedConnection_releaseOutstandingCall(self, call); - - return 0; - } - else { - return call->invokeId; - } + return invokeId; } LinkedList /* */ @@ -3530,8 +3525,6 @@ getDataSetDirectoryAsyncHandler(uint32_t invokeId, void* parameter, MmsError mms if (handler) handler(call->invokeId, call->callbackParameter, err, dataSetMembers, deletable); - - iedConnection_releaseOutstandingCall(self, call); } if (specs) @@ -3542,7 +3535,7 @@ uint32_t IedConnection_getDataSetDirectoryAsync(IedConnection self, IedClientError* error, const char* dataSetReference, IedConnection_GetDataSetDirectoryHandler handler, void* parameter) { - MmsError mmsError = MMS_ERROR_NONE; + uint32_t invokeId = 0; IedConnectionOutstandingCall call = iedConnection_allocateOutstandingCall(self); @@ -3597,6 +3590,9 @@ IedConnection_getDataSetDirectoryAsync(IedConnection self, IedClientError* error isAssociationSpecific = true; } + MmsError mmsError = MMS_ERROR_NONE; + + if (isAssociationSpecific) MmsConnection_readNamedVariableListDirectoryAssociationSpecificAsync(self->connection, &(call->invokeId), &mmsError, itemId, getDataSetDirectoryAsyncHandler, self); @@ -3606,15 +3602,7 @@ IedConnection_getDataSetDirectoryAsync(IedConnection self, IedClientError* error *error = iedConnection_mapMmsErrorToIedError(mmsError); exit_function: - - if (*error != IED_ERROR_OK) { - iedConnection_releaseOutstandingCall(self, call); - - return 0; - } - else { - return call->invokeId; - } + return invokeId; } ClientDataSet