有没有哪位大佬试过GD32F450上的LWIP,官方的开发板没问题吧?怎么一个简单的数据传输都会卡死呢?
有没有哪位大佬帮忙看看,GD32F450做TCP服务器,电脑做客户端,每次发1K给服务器,服务器收到后返回1个字节,客户端收到回复的1个字节再发1K,这样循环。
然后发现GD32的服务器10分钟内就收不到数据了,电脑这边客户端直接断开连接!
程序就是开发板上的程序简单修改,然后用来测试的
关键收数据代码如下:
static err_t hello_gigadevice_recv(void *arg, struct tcp_pcb *pcb, struct pbuf *p, err_t err)
{
u8_t *pRecv = arg;
struct pbuf *q;
char *c;
int i;
int nRecvLen = 0;
if( p != NULL )
{
nRecvLen = 0;
tcp_recved(pcb, p->tot_len);
for(q = p; q != NULL; q = q->next)
{
c = q->payload;
for(i = 0; i < q->len; i++)
{
pRecv[nRecvLen++] = c[i];
if ( nRecvLen>MAX_BUF_SIZE )
{
printf("Out of memory!\r\n");
return ERR_MEM;
}
}
}
printf("nRecvLen=%d\r\n",nRecvLen);
bitSend[0]=0;
tcp_write(pcb, bitSend, 1, TCP_WRITE_FLAG_COPY);
pbuf_free(p);
}
else if(err == ERR_OK)
{
/* when the pbuf is NULL and the err is ERR_OK, the remote end is closing the connection. */
/* we free the allocated memory and we close the connection */
printf("ThorX9.NET Client Closed @IP:%d.%d.%d.%d\r\n",pcb->remote_ip.addr&0xFF,pcb->remote_ip.addr>>8&0xFF,pcb->remote_ip.addr>>16&0xFF,pcb->remote_ip.addr>>24);
mem_free(pRecv);
return tcp_close(pcb);
}
return ERR_OK;
}
|