Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added function getInvokeId #447

Open
wants to merge 2 commits into
base: v1.5
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
96 changes: 47 additions & 49 deletions src/iec61850/client/ied_connection.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -675,6 +672,15 @@ IedConnection_getRequestTimeout(IedConnection self)
return 0;
}

uint32_t
IedConnection_getInvokeId(IedConnection self)
{
if (self->connection) {
return MmsConnection_getInvokeId(self->connection);
}
else
return 0;
}
void
IedConnection_setTimeQuality(IedConnection self, bool leapSecondKnown, bool clockFailure, bool clockNotSynchronized, int subsecondPrecision)
{
Expand Down Expand Up @@ -905,7 +911,7 @@ IedConnection_getVariableSpecification(IedConnection self, IedClientError* error
*error = IED_ERROR_OK;
else
*error = iedConnection_mapMmsErrorToIedError(mmsError);

cleanup_and_exit:

return varSpec;
Expand Down Expand Up @@ -1247,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;
}

Expand Down Expand Up @@ -2464,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];
Expand All @@ -2475,7 +2484,7 @@ IedConnection_getLogicalNodeDirectory(IedConnection self, IedClientError* error,

if (ldSep == NULL) {
*error = IED_ERROR_USER_PROVIDED_INVALID_ARGUMENT;
return NULL;
return ' ';
}

*ldSep = 0;
Expand All @@ -2494,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 */

Expand All @@ -2515,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();
Expand Down Expand Up @@ -2615,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];

Expand All @@ -2632,7 +2641,7 @@ IedConnection_getLogicalNodeVariables(IedConnection self, IedClientError* error,

if (ldSep == NULL) {
*error = IED_ERROR_OBJECT_REFERENCE_INVALID;
return NULL;
return ' ';
}

*ldSep = 0;
Expand Down Expand Up @@ -2660,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)
Expand Down Expand Up @@ -2698,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];

Expand All @@ -2723,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);
Expand All @@ -2734,7 +2743,7 @@ getDataDirectory(IedConnection self, IedClientError* error,

if (dataNamePartLen < 1) {
*error = IED_ERROR_OBJECT_REFERENCE_INVALID;
return NULL;
return ' ';
}

StringUtils_replace(dataNamePart, '.', '$');
Expand Down Expand Up @@ -3297,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];
Expand Down Expand Up @@ -3352,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);
Expand Down Expand Up @@ -3380,22 +3391,16 @@ IedConnection_createDataSetAsync(IedConnection self, IedClientError* error, cons
&mmsError, domainId, itemId, dataSetEntries, createDataSetAsyncHandler, self);
}

invokeId = call->invokeId;

*error = iedConnection_mapMmsErrorToIedError(mmsError);

cleanup_list:
/* delete list and all elements */
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 /* <char*> */
Expand Down Expand Up @@ -3520,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)
Expand All @@ -3532,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);

Expand Down Expand Up @@ -3587,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);

Expand All @@ -3596,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
Expand Down
10 changes: 10 additions & 0 deletions src/iec61850/inc/iec61850_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,16 @@ IedConnection_setRequestTimeout(IedConnection self, uint32_t timeoutInMs);
LIB61850_API uint32_t
IedConnection_getRequestTimeout(IedConnection self);

/**
* \brief get current InvokeId
*
* \param self the connection object
*
* \return current InvokeId
*/
LIB61850_API uint32_t
IedConnection_getInvokeId(IedConnection self);

/**
* \brief Set the time quality for all timestamps generated by this IedConnection instance
*
Expand Down
10 changes: 10 additions & 0 deletions src/mms/inc/mms_client_connection.h
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,16 @@ MmsConnection_setRequestTimeout(MmsConnection self, uint32_t timeoutInMs);
LIB61850_API uint32_t
MmsConnection_getRequestTimeout(MmsConnection self);

/**
* \brief Get current invokeId
*
* \param self MmsConnection instance to operate on
*
* \return current invokeId
*/
LIB61850_API uint32_t
MmsConnection_getInvokeId(MmsConnection self);

/**
* \brief Set the connect timeout in ms for this connection instance
*
Expand Down
6 changes: 6 additions & 0 deletions src/mms/iso_mms/client/mms_client_connection.c
Original file line number Diff line number Diff line change
Expand Up @@ -1658,6 +1658,12 @@ MmsConnection_getRequestTimeout(MmsConnection self)
return self->requestTimeout;
}

uint32_t
MmsConnection_getInvokeId(MmsConnection self)
{
return self->nextInvokeId;
}

void
MmsConnection_setConnectTimeout(MmsConnection self, uint32_t timeoutInMs)
{
Expand Down