|
500汤圆
1.上次那个问题,组播太大,导致lwip挂掉ping不同。
经过测试发现是无法接收数据,可以发送数据。后面我改了组播过滤,貌似解决了问题。。两三天不出问题
2.到了后面,发现还有部分设备直接挂掉,无法ping通。我觉得发送挂掉了。
排除最原始的组播报文导致设备挂掉竞争因素造成,我将接收中断由大循环处理,可以仍然会受大量数据冲击挂掉情况。也就是问题1,不是接收竞争引起的。
我的lwip就使能了DHCP,IGMP,UDP,UDP我是同时开启了两个PCB进行接收,指定PCB2发送,初始化以及发送如下。发送是在任意时候发送,接收目前也是已经修改为大循环接收。
现在不知道在哪些地方可能会卡死,目前lwip版本为2.1.2的版本,此事已困扰我很久。恳请各位了解的能帮忙分析解决一下。
- /**
- ******************************************************************************
- * @file server.c
- * @author MCD Application Team
- * @version V1.0.0
- * @date 11/20/2009
- * @brief A sample UDP/TCP server application.
- ******************************************************************************
- * @copy
- *
- * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
- * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
- * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
- * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
- * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
- * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
- *
- * <h2><center>© COPYRIGHT 2009 STMicroelectronics</center></h2>
- */
- /* Includes ------------------------------------------------------------------*/
- #include "main.h"
- #include "lwip/pbuf.h"
- #include "lwip/udp.h"
- #include "lwip/tcp.h"
- #include "lwip/igmp.h"
- #include <string.h>
- #include <stdio.h>
- #define UDP_SERVER_PORT 8888/* define the UDP local connection port */
- #define UDP_CLIENT_PORT 8888/* define the UDP remote connection port */
- void udp_server_callback( void *arg, struct udp_pcb *upcb, struct pbuf *p, const ip_addr_t *addr, u16_t port );
- void udp2_server_callback( void *arg, struct udp_pcb *upcb, struct pbuf *p, const ip_addr_t *addr, u16_t port );
- struct udp_pcb *upcbSer;
- struct udp_pcb *upcbSer2;
- u16_t LastPort;
- ip_addr_t LastAddress;
- void UdpServer_init( void )
- {
- upcbSer = udp_new();
-
- udp_bind( upcbSer, IP_ADDR_ANY, UDP_SERVER_PORT );
- udp_recv( upcbSer, udp_server_callback, NULL );
- upcbSer2=udp_new();
- udp_bind( upcbSer2, IP_ADDR_ANY, UDP_SERVER_PORT );
- udp_recv( upcbSer2, udp2_server_callback, NULL );
- upcbSer2->local_port=3671;
- }
- void udp_server_callback( void *arg, struct udp_pcb *upcb, struct pbuf *p, const ip_addr_t *addr, u16_t port )
- {
-
-
- Remote_IPPort = port;
- Remote_IPAddress[3]=((addr->addr>>24)&0xFF);
- Remote_IPAddress[2]=((addr->addr>>16)&0xFF);
- Remote_IPAddress[1]=((addr->addr>>8)&0xFF);
- Remote_IPAddress[0]=((addr->addr>>0)&0xFF);
-
- UCHAR *pBuffer;
- pBuffer=(unsigned char *) p->payload;
-
- //处理数据部分
- pbuf_free( p );
- }
- #if USE_SEC_UDP
- void udp2_server_callback( void *arg, struct udp_pcb *upcb, struct pbuf *p, const ip_addr_t *addr, u16_t port )
- {
-
- Remote_IPPort = port;
- Remote_IPAddress[3]=((addr->addr>>24)&0xFF);
- Remote_IPAddress[2]=((addr->addr>>16)&0xFF);
- Remote_IPAddress[1]=((addr->addr>>8)&0xFF);
- Remote_IPAddress[0]=((addr->addr>>0)&0xFF);
-
- UCHAR *pBuffer;
- pBuffer=(unsigned char *) p->payload;
-
-
- //处理数据部分
- pbuf_free( p );
- }
- #endif
- void udp_server_send_data(UCHAR *pBuffer,USHORT pLength,UCHAR *pDestAddr,USHORT pDestPort)
- {
- struct pbuf * p;
- ip_addr_t nIpAddr;
- p = pbuf_alloc( PBUF_TRANSPORT, pLength, PBUF_ROM );
- p->payload = pBuffer;
-
- nIpAddr.addr=(pDestAddr[3]<<24)|(pDestAddr[2]<<16)|(pDestAddr[1]<<8)|(pDestAddr[0]);
-
- udp_connect( upcbSer2, &nIpAddr, pDestPort);
- udp_send( upcbSer2, p );
- udp_disconnect( upcbSer2 );
- udp_bind( upcbSer2, IP_ADDR_ANY, UDP_SERVER_PORT );
- udp_recv( upcbSer2, udp2_server_callback, NULL );
-
- pbuf_free( p );
-
- }
复制代码 |
阿莫论坛20周年了!感谢大家的支持与爱护!!
一只鸟敢站在脆弱的枝条上歇脚,它依仗的不是枝条不会断,而是自己有翅膀,会飞。
|