2020-05-03 11:58 PM
I used example from STM324xG_EVAL\Applications\LwIP\LwIP_UDP_Echo_Server\Src.
I add lwIP into the project using CubeMX.
ping test is good.
I sent the message using Hercules tool. but Necleo didn't receive massages .
there are CubeMX setting value.
I also change GATEWAY ADDRESS to 192.168.42.1, not working too.
/* lwIP.c*/
void MX_LWIP_Init(void)
{
/* IP addresses initialization */
IP_ADDRESS[0] = 192;
IP_ADDRESS[1] = 168;
IP_ADDRESS[2] = 42;
IP_ADDRESS[3] = 51;
NETMASK_ADDRESS[0] = 255;
NETMASK_ADDRESS[1] = 255;
NETMASK_ADDRESS[2] = 255;
NETMASK_ADDRESS[3] = 0;
GATEWAY_ADDRESS[0] = 0;
GATEWAY_ADDRESS[1] = 0;
GATEWAY_ADDRESS[2] = 0;
GATEWAY_ADDRESS[3] = 0;
/* Initilialize the LwIP stack without RTOS */
....
..
}
/*udp_echoserver.c */
void udp_echoserver_receive_callback(void *arg, struct udp_pcb *upcb, struct pbuf *p, const ip_addr_t *addr, u16_t port)
{
/* Connect to the remote client */
udp_connect(upcb, addr, UDP_CLIENT_PORT);
/* Tell the client that we have accepted it */
udp_send(upcb, p);
/* free the UDP connection, so we can accept new clients */
udp_disconnect(upcb);
/* Free the p buffer */
pbuf_free(p);
}
/*main.c*/
int main(void)
{
/* Reset of all peripherals, Initializes the Flash interface and the Systick. */
HAL_Init();
/* USER CODE BEGIN Init */
/* tcp echo server Init */
udp_echoserver_init();
/* USER CODE END Init */
/* Configure the system clock */
SystemClock_Config();
/* Initialize all configured peripherals */
MX_GPIO_Init();
MX_USART3_UART_Init();
MX_USB_OTG_FS_PCD_Init();
MX_LWIP_Init();
/* Infinite loop */
/* USER CODE BEGIN WHILE */
while (1)
{
/* USER CODE END WHILE */
/* USER CODE BEGIN 3 */
ethernetif_input(&gnetif);
/* Handle timeouts */
sys_check_timeouts();
}
/* USER CODE END 3 */
}
I want to work udp_echoserver_receive_callback fuction when I send a message.
Solved! Go to Solution.
2020-05-04 01:24 AM
You are calling udp_echoserver_init() before MX_LWIP_Init(). :)
Also be warned...
2020-05-04 01:24 AM
You are calling udp_echoserver_init() before MX_LWIP_Init(). :)
Also be warned...
2020-05-04 05:28 AM
Thank you.
I modifed it under MX_LWIP_Init(). and I can receive the message.
2020-12-07 10:14 AM
Hi
Im trying to run echo server on stm32h743z nucleo without any success
int main(void)
{
/* USER CODE BEGIN 1 */
/* USER CODE END 1 */
/* Enable D-Cache---------------------------------------------------------*/
SCB_EnableDCache();
/* MCU Configuration--------------------------------------------------------*/
/* Reset of all peripherals, Initializes the Flash interface and the Systick. */
HAL_Init();
/* USER CODE BEGIN Init */
/* USER CODE END Init */
/* Configure the system clock */
SystemClock_Config();
/* USER CODE BEGIN SysInit */
/* USER CODE END SysInit */
/* Initialize all configured peripherals */
MX_GPIO_Init();
MX_SPI3_Init();
MX_USART3_UART_Init();
MX_USB_OTG_FS_PCD_Init();
MX_LWIP_Init();
/* USER CODE BEGIN 2 */
/* USER CODE END 2 */
/* Infinite loop */
/* USER CODE BEGIN WHILE */
udp_echoserver_init();
while (1)
{
/* USER CODE END WHILE */
/* USER CODE BEGIN 3 */
ethernetif_input(&gnetif);
/* Handle timeouts */
sys_check_timeouts();
}
/* USER CODE END 3 */
}
any help ?
2021-07-02 04:47 AM
Hello @BPark.4,
I am facing the same issue like you. Ping test is also working and my echo_init in the right place but nucleo can't receive messages using Hercules.
Any idea ?