STM32F429开发板,有个无操作系统移植LWIP的例程。PC机发送一个1000字节长度的包,开发板已经完整接收到(查看tot_len =1000), 但是接收程序仅仅接收了pbuf链表的第一个pbuf数据,只有460字节,而链表后面的pbuf数据没有接收?? static err_t tcp_echoclient_recv(void *arg,struct tcp_pcb *tpcb, struct pbuf *p, err_t err) { char*recdata=0; struct echoclient *es; err_t ret_err; LWIP_ASSERT("arg != NULL",arg != NULL); es= (struct echoclient *)arg; if(p == NULL) // 远程主机关闭了连接 { es->state = ES_CLOSING; if(es->pbuf_tx == NULL) tcp_echoclient_connection_close(tpcb, es); else tcp_echoclient_send(tpcb, es); ret_err = ERR_OK; } else if(err != ERR_OK) //接收到数据,但是有错误 { pbuf_free(p); ret_err = err; } else if(es->state == ES_CONNECTED) { tcp_recved(tpcb, p->tot_len); /* 总长度 */ recdata=(char *)malloc(p->len*sizeof(char));// 仅仅第一个长度分配空间 if(recdata!=NULL) { memcpy(recdata,p->payload,p->len);// 仅仅COPY第一个pbuf ?? #ifdef SERIAL_DEBUG if(recdata!=NULL) printf("\r\n%s",recdata);// #endif free(recdata); } pbuf_free(p); ret_err = ERR_OK; } else /* data received whenconnection already closed */ { tcp_recved(tpcb, p->tot_len); /* Acknowledge data reception */ pbuf_free(p); /* free pbuf and donothing */ ret_err = ERR_OK; } return ret_err; }
|