Skip to content

Commit bf271f4

Browse files
committed
modbus master tcp port: fix to close sockets correctly, minor additions for the PR
#44
1 parent 135a8f8 commit bf271f4

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

freemodbus/tcp_master/port/port_tcp_master.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,6 @@ static BOOL xMBTCPPortMasterCloseConnection(MbSlaveInfo_t *pxInfo)
236236
static void xMBTCPPortMasterShutdown(void)
237237
{
238238
xSemaphoreGive(xShutdownSema);
239-
xMbPortConfig.xMbTcpTaskHandle = NULL;
240239

241240
for (USHORT ucCnt = 0; ucCnt < MB_TCP_PORT_MAX_CONN; ucCnt++) {
242241
MbSlaveInfo_t* pxInfo = xMbPortConfig.pxMbSlaveInfo[ucCnt];
@@ -251,6 +250,7 @@ static void xMBTCPPortMasterShutdown(void)
251250
}
252251
free(xMbPortConfig.pxMbSlaveInfo);
253252
vTaskDelete(NULL);
253+
xMbPortConfig.xMbTcpTaskHandle = NULL;
254254
}
255255

256256
void vMBTCPPortMasterSetNetOpt(void *pvNetIf, eMBPortIpVer xIpVersion, eMBPortProto xProto)
@@ -754,7 +754,8 @@ static void vMBTCPPortMasterTask(void *pvParameters)
754754
break;
755755
}
756756
putchar(ucDot);
757-
vTaskDelay(pdMS_TO_TICKS(100)); /* if we don't yield we run the risk of hogging CPU */
757+
// if we don't yield we run the risk of hogging CPU
758+
vTaskDelay(pdMS_TO_TICKS(MB_TCP_CONNECTION_TIMEOUT_MS));
758759
xErr = xMBTCPPortMasterConnect(pxInfo);
759760
switch(xErr)
760761
{

0 commit comments

Comments
 (0)