From 135a8f8165a701bda027f87a1e336723e397cbb2 Mon Sep 17 00:00:00 2001 From: Floris Romeijn Date: Thu, 14 Dec 2023 14:53:18 +0100 Subject: [PATCH] fix for closing tcp connections and watchdog timeout Signed-off-by: aleks --- freemodbus/tcp_master/port/port_tcp_master.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/freemodbus/tcp_master/port/port_tcp_master.c b/freemodbus/tcp_master/port/port_tcp_master.c index f0d3367..7e2d2f7 100644 --- a/freemodbus/tcp_master/port/port_tcp_master.c +++ b/freemodbus/tcp_master/port/port_tcp_master.c @@ -236,7 +236,6 @@ static BOOL xMBTCPPortMasterCloseConnection(MbSlaveInfo_t *pxInfo) static void xMBTCPPortMasterShutdown(void) { xSemaphoreGive(xShutdownSema); - vTaskDelete(NULL); xMbPortConfig.xMbTcpTaskHandle = NULL; for (USHORT ucCnt = 0; ucCnt < MB_TCP_PORT_MAX_CONN; ucCnt++) { @@ -251,6 +250,7 @@ static void xMBTCPPortMasterShutdown(void) } } free(xMbPortConfig.pxMbSlaveInfo); + vTaskDelete(NULL); } void vMBTCPPortMasterSetNetOpt(void *pvNetIf, eMBPortIpVer xIpVersion, eMBPortProto xProto) @@ -754,6 +754,7 @@ static void vMBTCPPortMasterTask(void *pvParameters) break; } putchar(ucDot); + vTaskDelay(pdMS_TO_TICKS(100)); /* if we don't yield we run the risk of hogging CPU */ xErr = xMBTCPPortMasterConnect(pxInfo); switch(xErr) {