我正在尝试在stm32 NUCLEO-F746ZG板上建立UDP通信。但我无法ping通。收到消息“目标主机不可达”。程序不进入udp_echoserver_receive_callback()函数。
int main(void)
{
HAL_Init();
SystemClock_Config();
MX_GPIO_Init();
MX_LWIP_Init();
while (1)
{
MX_LWIP_Process();
}
}
void udp_echoserver_init(void)
{
struct udp_pcb *upcb;
err_t err;
upcb = udp_new();
if (upcb)
{
ip_set_option(upcb, SOF_BROADCAST);
err = udp_bind(upcb, IP_ADDR_ANY, 80);
if(err == ERR_OK)
{
udp_recv(upcb, udp_echoserver_receive_callback, NULL);
}
else
{
udp_remove(upcb);
}
}
}
void udp_echoserver_receive_callback(void *arg, struct udp_pcb *upcb, struct pbuf *p, const ip_addr_t *addr, u16_t port)
{
pc = (char*)p->payload;
pbuf_free(p);
}