关于STM32F746使用LwIP_TCP_Echo_Client进行tcp/ip 客户端开发的问题
最近在使用STM32F746做网络开发,移植LwIP_TCP_Echo_Client客户端的程序,电脑端使用TCP/IP调试助手建立服务器,客户端板子上电初始化配置后,在调试助手能够看到客户端已经连上服务器,并收到字符串sending11111 tcp client message 0,但是在主函数中调用 tcp_echoclient_send函数,电脑端的调试助手收不到发送的数据,这中间出现了什么问题啊?还请搞过的朋友们指点啊,先谢谢了啊!~~~~~~~~客户端配置程序如下:void tcp_echoclient_connect(void)
{
struct ip_addr DestIPaddr;
/* create new tcp pcb */
echoclient_pcb = tcp_new();
if (echoclient_pcb != NULL)
{
IP4_ADDR( &DestIPaddr, DEST_IP_ADDR0, DEST_IP_ADDR1, DEST_IP_ADDR2, DEST_IP_ADDR3 );
/* connect to destination address/port */
tcp_connect(echoclient_pcb,&DestIPaddr,DEST_PORT,tcp_echoclient_connected);
}
else
{
/* deallocate the pcb */
memp_free(MEMP_TCP_PCB, echoclient_pcb);
#ifdef SERIAL_DEBUG
printf("\n\r can not create tcp pcb");
#endif
}
}
static err_t tcp_echoclient_connected(void *arg, struct tcp_pcb *tpcb, err_t err)
{
struct echoclient *es = NULL;
if (err == ERR_OK)
{
/* allocate structure es to maintain tcp connection informations */
es = (struct echoclient *)mem_malloc(sizeof(struct echoclient));
if (es != NULL)
{
es->state = ES_CONNECTED;
es->pcb = tpcb;
sprintf((char*)data, "sending11111 tcp client message %d", (int)message_count);
/* allocate pbuf */
es->p_tx = pbuf_alloc(PBUF_TRANSPORT, strlen((char*)data) , PBUF_POOL);
if (es->p_tx)
{
/* copy data to pbuf */
pbuf_take(es->p_tx, (char*)data, strlen((char*)data));
/* pass newly allocated es structure as argument to tpcb */
tcp_arg(tpcb, es);
/* initialize LwIP tcp_recv callback function */
tcp_recv(tpcb, tcp_echoclient_recv);
/* initialize LwIP tcp_sent callback function */
tcp_sent(tpcb, tcp_echoclient_sent);
/* initialize LwIP tcp_poll callback function */
tcp_poll(tpcb, tcp_echoclient_poll, 1);
/* send data */
tcp_echoclient_send(tpcb,es);
return ERR_OK;
}
}
else
{
/* close connection */
tcp_echoclient_connection_close(tpcb, es);
/* return memory allocation error */
return ERR_MEM;
}
}
else
{
/* close connection */
tcp_echoclient_connection_close(tpcb, es);
}
return err;
}
顶一下,大家怎么使用lWIP的TCP客户端啊? 大家有用F746作为客户端开发的吗? 可以跟踪看下当前的状态,例程估计客户端自动关闭的 搞过F107的,也仅仅是调通了,收不到,一定是哪里不对,帮顶! 帮顶!! 估计是回应的IP和MAC不对。
建议使用网络抓包工具,看看发出的数据哪错了。
页:
[1]