- IEC 61850 client: fixed problem - IedConnection cannot be reused after IedConnection_close (github #124)

pull/147/head
Michael Zillgith 7 years ago
parent b755bb90a4
commit 1e1d649aae

@ -116,9 +116,13 @@ main(int argc, char** argv)
LinkedList_destroy(dataObjects);
printf("IedConnection_getLogicalNodeDirectory(%s)\n", lnRef);
LinkedList dataSets = IedConnection_getLogicalNodeDirectory(con, &error, lnRef,
ACSI_CLASS_DATA_SET);
if (error != IED_ERROR_OK)
printf("get logical node data sets --> error: %i\n", error);
LinkedList dataSet = LinkedList_getNext(dataSets);
while (dataSet != NULL) {
@ -193,7 +197,7 @@ main(int argc, char** argv)
LinkedList_destroy(deviceList);
IedConnection_close(con);
IedConnection_abort(con, &error);
}
else {
printf("Connection failed!\n");

@ -617,8 +617,8 @@ void
IedConnection_close(IedConnection self)
{
if (IedConnection_getState(self) == IED_STATE_CONNECTED) {
MmsConnection_close(self->connection);
IedConnection_setState(self, IED_STATE_CLOSED);
MmsConnection_close(self->connection);
}
}

@ -1162,9 +1162,21 @@ ClientReportControlBlock_setDataSetReference(ClientReportControlBlock self, cons
uint32_t
ClientReportControlBlock_getConfRev(ClientReportControlBlock self);
/**
* \brief Gets the OptFlds parameter of the RCB (decides what information to include in a report)
*
* \param self the RCB instance
* \return bit field representing the optional fields of a report (uses flags from \ref REPORT_OPTIONS)
*/
int
ClientReportControlBlock_getOptFlds(ClientReportControlBlock self);
/**
* \brief Set the OptFlds parameter of the RCB (decides what information to include in a report)
*
* \param self the RCB instance
* \param optFlds bit field representing the optional fields of a report (use flags from \ref REPORT_OPTIONS)
*/
void
ClientReportControlBlock_setOptFlds(ClientReportControlBlock self, int optFlds);

@ -141,6 +141,9 @@ connectionHandlingThread(IsoClientConnection self)
Thread_sleep(1);
if (self->stopHandlingThread) {
if (DEBUG_ISO_CLIENT)
printf("ISO_CLIENT_CONNECTION: stop thread requested\n");
packetState = TPKT_ERROR;
break;
}
@ -292,6 +295,9 @@ IsoClientConnection_associate(IsoClientConnection self, IsoConnectionParameters
Socket_setConnectTimeout(self->socket, connectTimeoutInMs);
self->stopHandlingThread = false;
self->destroyHandlingThread = false;
#if (CONFIG_ACTIVATE_TCP_KEEPALIVE == 1)
Socket_activateTcpKeepAlive(self->socket,
CONFIG_TCP_KEEPALIVE_IDLE,
@ -599,6 +605,9 @@ IsoClientConnection_abort(IsoClientConnection self)
IsoSession_createAbortSpdu(self->session, sessionBuffer, presentationBuffer);
if (DEBUG_ISO_CLIENT)
printf("ISO_CLIENT: send abort message\n");
CotpConnection_sendDataMessage(self->cotpConnection, sessionBuffer);
Semaphore_post(self->transmitBufferMutex);
@ -643,6 +652,9 @@ IsoClientConnection_release(IsoClientConnection self)
IsoSession_createFinishSpdu(NULL, sessionBuffer, presentationBuffer);
if (DEBUG_ISO_CLIENT)
printf("ISO_CLIENT: send release message\n");
CotpConnection_sendDataMessage(self->cotpConnection, sessionBuffer);
Semaphore_post(self->transmitBufferMutex);

@ -1314,19 +1314,31 @@ MmsConnection_connect(MmsConnection self, MmsError* mmsError, const char* server
waitForConnectResponse(self);
if (DEBUG_MMS_CLIENT)
printf("MmsConnection_connect: received response conState: %i\n", getConnectionState(self));
printf("MmsConnection_connect: received response conState: %i assocState: %i\n", getConnectionState(self), getAssociationState(self));
if (getConnectionState(self) == MMS_CON_ASSOCIATED) {
mmsClient_parseInitiateResponse(self);
if (mmsClient_parseInitiateResponse(self) == false) {
if (DEBUG_MMS_CLIENT)
printf("MmsConnection_connect: failed to parse initiate response\n");
setAssociationState(self, MMS_STATE_CLOSED);
setConnectionState(self, MMS_CON_ASSOCIATION_FAILED);
}
else {
setAssociationState(self, MMS_STATE_CONNECTED);
}
releaseResponse(self);
setAssociationState(self, MMS_STATE_CONNECTED);
}
else
else {
setAssociationState(self, MMS_STATE_CLOSED);
setConnectionState(self, MMS_CON_IDLE);
setConnectionState(self, MMS_CON_ASSOCIATION_FAILED);
}
if (DEBUG_MMS_CLIENT)
printf("MmsConnection_connect: states: con %i ass %i\n", getConnectionState(self), getAssociationState(self));

@ -162,7 +162,7 @@ parseInitResponseDetail(MmsConnection self, uint8_t* buffer, int bufPos, int max
bool
mmsClient_parseInitiateResponse(MmsConnection self)
{
bool result = false;
bool result = true;
self->parameters.maxPduSize = CONFIG_MMS_MAXIMUM_PDU_SIZE;
self->parameters.dataStructureNestingLevel = DEFAULT_DATA_STRUCTURE_NESTING_LEVEL;
@ -236,6 +236,5 @@ mmsClient_parseInitiateResponse(MmsConnection self)
bufPos += length;
}
return result;
}

Loading…
Cancel
Save