File tree Expand file tree Collapse file tree 1 file changed +4
-2
lines changed
freemodbus/tcp_master/port Expand file tree Collapse file tree 1 file changed +4
-2
lines changed Original file line number Diff line number Diff line change @@ -236,8 +236,6 @@ static BOOL xMBTCPPortMasterCloseConnection(MbSlaveInfo_t *pxInfo)
236236static void xMBTCPPortMasterShutdown (void )
237237{
238238 xSemaphoreGive (xShutdownSema );
239- vTaskDelete (NULL );
240- xMbPortConfig .xMbTcpTaskHandle = NULL ;
241239
242240 for (USHORT ucCnt = 0 ; ucCnt < MB_TCP_PORT_MAX_CONN ; ucCnt ++ ) {
243241 MbSlaveInfo_t * pxInfo = xMbPortConfig .pxMbSlaveInfo [ucCnt ];
@@ -251,6 +249,8 @@ static void xMBTCPPortMasterShutdown(void)
251249 }
252250 }
253251 free (xMbPortConfig .pxMbSlaveInfo );
252+ vTaskDelete (NULL );
253+ xMbPortConfig .xMbTcpTaskHandle = NULL ;
254254}
255255
256256void vMBTCPPortMasterSetNetOpt (void * pvNetIf , eMBPortIpVer xIpVersion , eMBPortProto xProto )
@@ -754,6 +754,8 @@ static void vMBTCPPortMasterTask(void *pvParameters)
754754 break ;
755755 }
756756 putchar (ucDot );
757+ // if we don't yield we run the risk of hogging CPU
758+ vTaskDelay (pdMS_TO_TICKS (MB_TCP_CONNECTION_TIMEOUT_MS ));
757759 xErr = xMBTCPPortMasterConnect (pxInfo );
758760 switch (xErr )
759761 {
You can’t perform that action at this time.
0 commit comments