cancel
Showing results for 
Search instead for 
Did you mean: 

UDP communication does not work if the cable is plugged in after initialization

Bajocasse
Associate II

Hi,

I have an UDP Server on a STM32H743ZI. It works very good only if the ethernet cable is already connected when I power on the board.

However, if I connect the cable after powering on the board, UDP Server does not receive any message.

FreeRTOS is used on my project and I have added LWIP_NETIF_LINK_CALLBACK 1 to lwipopts.h but I never go in callback function even if I connect/disconnect the ehernet cable.

Where's the problem?
what should I add to detect the cable connection?

Thanks a lot!

Kind regards.

1 ACCEPTED SOLUTION

Accepted Solutions

I solved my problem by changing the priority in the MX_LWIP_Init function

 

I set

/* USER CODE BEGIN H7_OS_THREAD_NEW_CMSIS_RTOS_V2 */
memset(&attributes, 0x0, sizeof(osThreadAttr_t));
attributes.name = "EthLink";
attributes.stack_size = INTERFACE_THREAD_STACK_SIZE;
attributes.priority = osPriorityNormal;
osThreadNew(ethernet_link_thread, &gnetif, &attributes);
/* USER CODE END H7_OS_THREAD_NEW_CMSIS_RTOS_V2 */

rather than osPriorityBelowNormal

 

and so The ethernet_link_thread function is then called during cable connections/disconnections

View solution in original post

2 REPLIES 2
ASEHST
ST Employee

Hello @Bajocasse,

Have you called the netif_set_link_callback() function as demonstrated in the following snippet? 

#if LWIP_NETIF_LINK_CALLBACK
netif_set_link_callback(&netif, ethernet_link_status_updated);
#endif

By calling this function, your application will be able to dynamically respond to changes in the network link status, such as when the Ethernet cable is plugged in or unplugged.

With Regards,

If your question is answered, please close this topic by clicking "Accept as Solution".

I solved my problem by changing the priority in the MX_LWIP_Init function

 

I set

/* USER CODE BEGIN H7_OS_THREAD_NEW_CMSIS_RTOS_V2 */
memset(&attributes, 0x0, sizeof(osThreadAttr_t));
attributes.name = "EthLink";
attributes.stack_size = INTERFACE_THREAD_STACK_SIZE;
attributes.priority = osPriorityNormal;
osThreadNew(ethernet_link_thread, &gnetif, &attributes);
/* USER CODE END H7_OS_THREAD_NEW_CMSIS_RTOS_V2 */

rather than osPriorityBelowNormal

 

and so The ethernet_link_thread function is then called during cable connections/disconnections