- Client: response timeout for connection setup now configurable (default timeout now 5 s instead of 1 s )

- removed configuration option CONFIG_TCP_READ_TIMEOUT_MS
pull/182/head
Michael Zillgith 6 years ago
parent aad53f380e
commit 17205ed874

@ -68,9 +68,6 @@
/* maximum COTP (ISO 8073) TPDU size - valid range is 1024 - 8192 */ /* maximum COTP (ISO 8073) TPDU size - valid range is 1024 - 8192 */
#define CONFIG_COTP_MAX_TPDU_SIZE 8192 #define CONFIG_COTP_MAX_TPDU_SIZE 8192
/* timeout while reading from TCP stream in ms */
#define CONFIG_TCP_READ_TIMEOUT_MS 1000
/* Ethernet interface ID for GOOSE and SV */ /* Ethernet interface ID for GOOSE and SV */
#define CONFIG_ETHERNET_INTERFACE_ID "eth0" #define CONFIG_ETHERNET_INTERFACE_ID "eth0"
//#define CONFIG_ETHERNET_INTERFACE_ID "vboxnet0" //#define CONFIG_ETHERNET_INTERFACE_ID "vboxnet0"

@ -63,9 +63,6 @@
/* maximum COTP (ISO 8073) TPDU size - valid range is 1024 - 8192 */ /* maximum COTP (ISO 8073) TPDU size - valid range is 1024 - 8192 */
#define CONFIG_COTP_MAX_TPDU_SIZE 8192 #define CONFIG_COTP_MAX_TPDU_SIZE 8192
/* timeout while reading from TCP stream in ms */
#define CONFIG_TCP_READ_TIMEOUT_MS 1000
/* Ethernet interface ID for GOOSE and SV */ /* Ethernet interface ID for GOOSE and SV */
#define CONFIG_ETHERNET_INTERFACE_ID "eth0" #define CONFIG_ETHERNET_INTERFACE_ID "eth0"
//#define CONFIG_ETHERNET_INTERFACE_ID "vboxnet0" //#define CONFIG_ETHERNET_INTERFACE_ID "vboxnet0"

@ -59,7 +59,7 @@ LIB61850_INTERNAL void
IsoClientConnection_destroy(IsoClientConnection self); IsoClientConnection_destroy(IsoClientConnection self);
LIB61850_INTERNAL bool LIB61850_INTERNAL bool
IsoClientConnection_associateAsync(IsoClientConnection self, uint32_t connectTimeoutInMs); IsoClientConnection_associateAsync(IsoClientConnection self, uint32_t connectTimeoutInMs, uint32_t readTimeoutInMs);
/** /**
* called by tick function * called by tick function

@ -77,6 +77,7 @@ struct sIsoClientConnection
volatile int state; volatile int state;
Semaphore stateMutex; Semaphore stateMutex;
uint32_t readTimeoutInMs; /* read timeout in ms */
uint64_t nextReadTimeout; /* timeout value for read and connect */ uint64_t nextReadTimeout; /* timeout value for read and connect */
Socket socket; Socket socket;
@ -322,7 +323,7 @@ IsoClientConnection_handleConnection(IsoClientConnection self)
if (socketState == SOCKET_STATE_CONNECTED) { if (socketState == SOCKET_STATE_CONNECTED) {
if (sendConnectionRequestMessage(self)) { if (sendConnectionRequestMessage(self)) {
self->nextReadTimeout = Hal_getTimeInMs() + CONFIG_TCP_READ_TIMEOUT_MS; self->nextReadTimeout = Hal_getTimeInMs() + self->readTimeoutInMs;
nextState = INT_STATE_WAIT_FOR_COTP_CONNECT_RESP; nextState = INT_STATE_WAIT_FOR_COTP_CONNECT_RESP;
} }
else { else {
@ -392,7 +393,7 @@ IsoClientConnection_handleConnection(IsoClientConnection self)
else { else {
sendAcseInitiateRequest(self); sendAcseInitiateRequest(self);
self->nextReadTimeout = Hal_getTimeInMs() + CONFIG_TCP_READ_TIMEOUT_MS; self->nextReadTimeout = Hal_getTimeInMs() + self->readTimeoutInMs;
nextState = INT_STATE_WAIT_FOR_ACSE_RESP; nextState = INT_STATE_WAIT_FOR_ACSE_RESP;
} }
@ -426,7 +427,7 @@ IsoClientConnection_handleConnection(IsoClientConnection self)
self->callback(ISO_IND_ASSOCIATION_FAILED, self->callbackParameter, NULL); self->callback(ISO_IND_ASSOCIATION_FAILED, self->callbackParameter, NULL);
nextState = INT_STATE_ERROR; nextState = INT_STATE_CLOSE_ON_ERROR;
} }
else { else {
@ -634,7 +635,7 @@ IsoClientConnection_handleConnection(IsoClientConnection self)
bool bool
IsoClientConnection_associateAsync(IsoClientConnection self, uint32_t connectTimeoutInMs) IsoClientConnection_associateAsync(IsoClientConnection self, uint32_t connectTimeoutInMs, uint32_t readTimeoutInMs)
{ {
Semaphore_wait(self->tickMutex); Semaphore_wait(self->tickMutex);
@ -659,6 +660,9 @@ IsoClientConnection_associateAsync(IsoClientConnection self, uint32_t connectTim
CONFIG_TCP_KEEPALIVE_CNT); CONFIG_TCP_KEEPALIVE_CNT);
#endif #endif
/* set read timeout */
self->readTimeoutInMs = readTimeoutInMs;
/* set timeout for connect */ /* set timeout for connect */
self->nextReadTimeout = Hal_getTimeInMs() + connectTimeoutInMs; self->nextReadTimeout = Hal_getTimeInMs() + connectTimeoutInMs;

@ -1741,7 +1741,7 @@ MmsConnection_connectAsync(MmsConnection self, MmsError* mmsError, const char* s
} }
#endif /* (CONFIG_MMS_RAW_MESSAGE_LOGGING == 1) */ #endif /* (CONFIG_MMS_RAW_MESSAGE_LOGGING == 1) */
if (IsoClientConnection_associateAsync(self->isoClient, self->connectTimeout)) { if (IsoClientConnection_associateAsync(self->isoClient, self->connectTimeout, self->requestTimeout)) {
setConnectionState(self, MMS_CONNECTION_STATE_CONNECTING); setConnectionState(self, MMS_CONNECTION_STATE_CONNECTING);
*mmsError = MMS_ERROR_NONE; *mmsError = MMS_ERROR_NONE;
} }

Loading…
Cancel
Save