標(biāo)題:
關(guān)于stm32嵌入lwip以太網(wǎng)udp升級(jí)傳輸大數(shù)據(jù)包問(wèn)題
[打印本頁(yè)]
作者:
heila
時(shí)間:
2015-12-9 01:20
標(biāo)題:
關(guān)于stm32嵌入lwip以太網(wǎng)udp升級(jí)傳輸大數(shù)據(jù)包問(wèn)題
問(wèn)題描述
使用stm32的以太網(wǎng)嵌入lwip網(wǎng)絡(luò)協(xié)議和pc電腦通訊,主要傳輸升級(jí)數(shù)據(jù),涉及到的是fpga數(shù)據(jù),所以量有點(diǎn)大。
發(fā)現(xiàn)一個(gè)問(wèn)題,每次傳輸只能傳輸12包,到12包之后就沒(méi)有收到數(shù)據(jù)包了,這個(gè)現(xiàn)象是固定的,也就是根本進(jìn)不了回調(diào)函數(shù)如下函數(shù)
/******* 這是一個(gè)回調(diào)函數(shù),當(dāng)有UDP數(shù)據(jù)收到時(shí)會(huì)被調(diào)用********/
// addr:筆記本的IP地址(存放向開(kāi)發(fā)板發(fā)送數(shù)據(jù)的PC的IP地址)
// port:筆記本的端口號(hào)(遠(yuǎn)端端口號(hào))
void Udp_Test_Receive(void *arg,struct udp_pcb *pcb,struct pbuf *p,struct ip_addr *addr,u16_t port)
{}
很是疼痛,網(wǎng)絡(luò)菜鳥(niǎo),不斷找代碼的Bug,解決問(wèn)題可就是解決不了。
經(jīng)過(guò)比較發(fā)現(xiàn),在回調(diào)函數(shù)里忘記釋放指針了。
比較標(biāo)準(zhǔn)的回調(diào)函數(shù)如下
void Udp_Test_Receive(void *arg,struct udp_pcb *pcb,struct pbuf *p,struct ip_addr *addr,u16_t port)
{
//struct ip_addr destAddr = *addr;
//unsigned char g_tData[256];
struct pbuf *p1;
unsigned char *nptr; //指向UDP接收緩存區(qū)的指針
short len; //接收到的UDP數(shù)據(jù)包長(zhǎng)度
unsigned short LenUpdata = 0; //升級(jí)數(shù)據(jù)包的有效數(shù)據(jù)長(zhǎng)度
if(p != NULL)
{
len = p->len;
len = len;
nptr = (unsigned char*)p->payload;
/*************************add your code here***************/
/*******************************************************/
/**************************************************************************/
pbuf_free(p);
}
}
歡迎光臨 (http://www.torrancerestoration.com/bbs/)
Powered by Discuz! X3.1