From 9b977e2e4f6ec12264979b1674d9f52923684b09 Mon Sep 17 00:00:00 2001 From: Michael Zillgith Date: Tue, 3 Jan 2023 12:20:08 +0000 Subject: [PATCH] - updated error handling in IedConnection_getDataSetDirectoryAsync/IedConnection_createDataSetAsync (LIB61850-379) --- src/iec61850/client/ied_connection.c | 34 ++++++++++++++-------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/src/iec61850/client/ied_connection.c b/src/iec61850/client/ied_connection.c index b7395c7b..807037be 100644 --- a/src/iec61850/client/ied_connection.c +++ b/src/iec61850/client/ied_connection.c @@ -3294,6 +3294,19 @@ 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; + char domainIdBuffer[65]; char itemIdBuffer[DATA_SET_MAX_NAME_LENGTH + 1]; @@ -3336,19 +3349,6 @@ IedConnection_createDataSetAsync(IedConnection self, IedClientError* error, cons isAssociationSpecific = true; } - 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; - LinkedList dataSetEntries = LinkedList_create(); LinkedList dataSetElement = LinkedList_getNext(dataSetElements); @@ -3385,7 +3385,7 @@ cleanup_list: exit_function: - if (mmsError != MMS_ERROR_NONE) { + if (*error != IED_ERROR_OK) { iedConnection_releaseOutstandingCall(self, call); return 0; @@ -3529,6 +3529,8 @@ uint32_t IedConnection_getDataSetDirectoryAsync(IedConnection self, IedClientError* error, const char* dataSetReference, IedConnection_GetDataSetDirectoryHandler handler, void* parameter) { + MmsError mmsError = MMS_ERROR_NONE; + IedConnectionOutstandingCall call = iedConnection_allocateOutstandingCall(self); if (call == NULL) { @@ -3582,8 +3584,6 @@ 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); @@ -3594,7 +3594,7 @@ IedConnection_getDataSetDirectoryAsync(IedConnection self, IedClientError* error exit_function: - if (mmsError != MMS_ERROR_NONE) { + if (*error != IED_ERROR_OK) { iedConnection_releaseOutstandingCall(self, call); return 0;