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

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

@ -1162,9 +1162,21 @@ ClientReportControlBlock_setDataSetReference(ClientReportControlBlock self, cons
uint32_t uint32_t
ClientReportControlBlock_getConfRev(ClientReportControlBlock self); 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 int
ClientReportControlBlock_getOptFlds(ClientReportControlBlock self); 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 void
ClientReportControlBlock_setOptFlds(ClientReportControlBlock self, int optFlds); ClientReportControlBlock_setOptFlds(ClientReportControlBlock self, int optFlds);

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

@ -1314,19 +1314,31 @@ MmsConnection_connect(MmsConnection self, MmsError* mmsError, const char* server
waitForConnectResponse(self); waitForConnectResponse(self);
if (DEBUG_MMS_CLIENT) 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) { 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");
releaseResponse(self); setAssociationState(self, MMS_STATE_CLOSED);
setConnectionState(self, MMS_CON_ASSOCIATION_FAILED);
}
else {
setAssociationState(self, MMS_STATE_CONNECTED); setAssociationState(self, MMS_STATE_CONNECTED);
} }
else
releaseResponse(self);
}
else {
setAssociationState(self, MMS_STATE_CLOSED); setAssociationState(self, MMS_STATE_CLOSED);
setConnectionState(self, MMS_CON_IDLE); setConnectionState(self, MMS_CON_ASSOCIATION_FAILED);
}
if (DEBUG_MMS_CLIENT) if (DEBUG_MMS_CLIENT)
printf("MmsConnection_connect: states: con %i ass %i\n", getConnectionState(self), getAssociationState(self)); 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 bool
mmsClient_parseInitiateResponse(MmsConnection self) mmsClient_parseInitiateResponse(MmsConnection self)
{ {
bool result = false; bool result = true;
self->parameters.maxPduSize = CONFIG_MMS_MAXIMUM_PDU_SIZE; self->parameters.maxPduSize = CONFIG_MMS_MAXIMUM_PDU_SIZE;
self->parameters.dataStructureNestingLevel = DEFAULT_DATA_STRUCTURE_NESTING_LEVEL; self->parameters.dataStructureNestingLevel = DEFAULT_DATA_STRUCTURE_NESTING_LEVEL;
@ -236,6 +236,5 @@ mmsClient_parseInitiateResponse(MmsConnection self)
bufPos += length; bufPos += length;
} }
return result; return result;
} }

Loading…
Cancel
Save