cancel
Showing results for 
Search instead for 
Did you mean: 

recvfrom() is not working on stm32H7B3I-DK. How to resolve recvfrom() issue on STM32_Network_Library.

IChoi.2
Associate

I'm using stm32H7B3I-DK board.

  • FreeRTOS
  • STM32_Network_Library
  • ES_WIFI (BSP)

When I tested UDP socket, sendto() was working.

But recvfrom() was not working, it was blocked for ES_WIFI_MAX_SO_TIMEOUT.

The remote received an ICMP (Port unreachable).

This is my tested codes

/**

static void ecrio_udp_test(void)

{

int32_t sock = 0;

int32_t ret = 0;

sockaddr_in_t ServerIp;

sockaddr_in_t LocalIp;

net_ip4_addr_t addr;

net_ip_addr_t ip;

uint8_t received[1024];

uint32_t fromlen = 0;

memset((char *)&ServerIp, 0, sizeof(ServerIp));

sock = net_socket(NET_AF_INET, NET_SOCK_DGRAM ,NET_IPPROTO_UDP );

if (sock < 0)

{

printf("net_socket error=%d\r\n", sock);

}

printf("net_socket success\r\n");

ip4_addr_set_u32(&addr, NET_ATON_R("192.168.45.15"));

NET_IP4ADDR_PORT_TO_SOCKADDR(&ServerIp, &addr, 10000);

{

net_ip_addr_t remote;

remote = net_get_ip_addr(&ServerIp);

printf("remote ip = %s\r\n", net_ntoa(&remote));

printf("remote port = %d\r\n", 10000);

}

net_if_get_ip_address(&netif, &ip);

NET_IP4ADDR_PORT_TO_SOCKADDR(&LocalIp, (net_ip4_addr_t *)&ip, 20000);

printf("local ip = %s\r\n", net_ntoa(&ip));

printf("local port = %d\r\n", 20000);

ret = net_bind(sock, (sockaddr_t *)&LocalIp, LocalIp.sin_len);

if (ret != NET_OK)

{

printf("net_bind error=%d\r\n", ret);

}

printf("net_bind success\r\n");

ret = net_sendto( sock, "Hello!!", sizeof("Hello!!"), 0, (sockaddr_t *)&ServerIp, sizeof(ServerIp));

if (ret < 0)

{

printf("net_sendto error=%d\r\n", ret);

}

printf("net_sendto success sent=%d bytes\r\n", ret);

memset((char *)received, 0, 1024);

ret = net_recvfrom( sock, received, sizeof(received), 0, (sockaddr_t *)&ServerIp, &fromlen);

if (ret < 0)

{

printf("net_recvfrom error=%d\r\n", ret);

}

printf("net_recvfrom success received= %s, (%d) bytes\r\n", ret);

}

**/

Please find the attached. It is terminal log with ES_WIFI_DEBUG_MODE.

BR,

jee.

0 REPLIES 0