工具/软件:Starterware
你好! 我使用 TI DSP 6748芯片 与 采用 UDP LWIP_IGMP 协议的 PC 通信,有两个端口用于接收由 PC 以 5Hz 频率发送的数据 ,两个端口用于以 2Hz 频率向 PC 发送数据 ;
与 starterWare 中的示例(enet_lwip)一样、UDP 初始化代码为:
//--UDP 接收--
IGMP_JOINGROUP (IP_ADDR_ANY、&Computer_B_ipaddr);
User2_1pcb = udp_new();
User2_1pcb->multicing_IP = Computer_B_ipaddr;
UDP_BIND (user2_1pcb、IP_ADDR_ANY、Board_Port_B_1);
UDP_CONNECT (user2_1pcb、IP_ADDR_ANY、Computer_B_1_Rx_Port);
udp_recv (user2_1pcb、UDP2_1Receive, NULL);
User2_2pcb = udp_new();
User2_2pcb->multicing_IP = Computer_B_ipaddr;
UDP_BIND (user2_2pcb、IP_ADDR_ANY、Board_Port_B_2);
UDP_CONNECT (user2_2pcb、IP_ADDR_ANY、Computer_B_2_Rx_Port);
UDP_recv (user2_2pcb、UDP2_2Receive、NULL);
//--UDP 发送--
LocalMonitor1_PCB = UDP_NEW ();
LocalMonitor1_PCB/多播_IP = Computer_LocalMonitor_ipaddr;
Antanna_TS_PCB = UDP_NEW ();
Antanna TS_PCPCB ->组播_IP = Computer_Antenna_TS_ipaddr;
///----------------------------------------------
两个接收端口可以接收180帧的数据、但此后会中断;
在调试中、我发现 UDP 发送过程中出现了问题:
在函数 udp_sendto (),中有 一段代码:
Netif = ip_route ((ip_addr_ismulticast (dst_ip))?(&(pcb ->组播_ip)):(dst_ip));
在 函数 IP_route 中:它 始终在以下代码中运行,因此发送和接收端口不起作用;
/*通过 NEFifs 迭代*/
for (netif = netif_list;netif!= NULL;netif = netif->next){
/*网络掩码匹配? *
if (netif_is _up (netif)){
if (ip_addr_netcmp (dest、&(netif->ip_addr)、&(netif->netmask))){
//返回要转发 IP 数据包的主题*/
退换货;
}
}
}
///--------------------------------
那么 、如何 解决 这个 问题呢?