初级会员
- 积分
- 57
- 金钱
- 57
- 注册时间
- 2014-12-4
- 在线时间
- 2 小时
|
5金钱
原子哥:
LWIP+ENC60J+STM32(MINI)V3.0
发送回调函数中,发送变量多了不行,常量再多也可以,在论坛中都没发现过讨论这个问题的,
注释掉的发15个就有接收不到的,常量发90个可以,
我的项目是把TCP/IP,网关,掩码发给上位机显示,而后,手工配置TCP/IP,网关,掩码等
代码如下:
err_t tcp_client_poll(void *arg, struct tcp_pcb *tpcb)
{
u8 i=0;
err_t ret_err;
struct tcp_client_struct *es;
es=(struct tcp_client_struct*)arg;
if(es!=NULL) //????????????????·???????
{
if(tcp_client_sta&(1<<7)) //??????·?????????·???
{
memset(tcp_udp_demo_sendbuf,0,TCP_UDP_DEMO_TX_BUFSIZE); //????·???????????0
if(key_flag) //·?????????????????????
{
tcp_udp_demo_sendbuf[0]=0x0a;
tcp_udp_demo_sendbuf[1]=0x0b;
tcp_udp_demo_sendbuf[2]=0x0c;
tcp_udp_demo_sendbuf[3]=0x0d;
tcp_udp_demo_sendbuf[4]=0x0e;
key_flag=0;
}
if( read_ip_ok) //±à??×???·???IP????????±à???í??
{
// tcp_udp_demo_sendbuf[0]=NET_ID_FLG;
// tcp_udp_demo_sendbuf[1]=eeprom_net_num[0]; //??????
// tcp_udp_demo_sendbuf[2]=eeprom_net_num[1];
// tcp_udp_demo_sendbuf[3]=eeprom_net_num[2];
// tcp_udp_demo_sendbuf[1]=USER_ID_FLG;
// tcp_udp_demo_sendbuf[5]=eeprom_user_id[0]; //???§????
// tcp_udp_demo_sendbuf[6]=eeprom_user_id[1];
// tcp_udp_demo_sendbuf[7]=eeprom_user_id[2];
// tcp_udp_demo_sendbuf[8]=eeprom_user_id[3];
// tcp_udp_demo_sendbuf[2]=REMOTEIP_FLG;
// tcp_udp_demo_sendbuf[3]=lwipdev.remoteip[0]; //????IP
// tcp_udp_demo_sendbuf[4]=lwipdev.remoteip[1];
// tcp_udp_demo_sendbuf[5]=lwipdev.remoteip[2];
// tcp_udp_demo_sendbuf[6]=lwipdev.remoteip[3];
// tcp_udp_demo_sendbuf[3]=HEREIP_FLG;
// tcp_udp_demo_sendbuf[4]=lwipdev.ip[0]; //±???IP
// tcp_udp_demo_sendbuf[5]=lwipdev.ip[1];
// tcp_udp_demo_sendbuf[6]=lwipdev.ip[2];
// tcp_udp_demo_sendbuf[7]=lwipdev.ip[3];
// tcp_udp_demo_sendbuf[8]=NETMASK_FLG;
// tcp_udp_demo_sendbuf[9]=lwipdev.netmask[0]; //×???????
// tcp_udp_demo_sendbuf[10]=lwipdev.netmask[1];
// tcp_udp_demo_sendbuf[11]=lwipdev.netmask[2];
// tcp_udp_demo_sendbuf[12]=lwipdev.netmask[3];
// tcp_udp_demo_sendbuf[13]=GATWAY_FLG;
// tcp_udp_demo_sendbuf[14]=lwipdev.gateway[0]; //????????
// tcp_udp_demo_sendbuf[15]=lwipdev.gateway[1];
// tcp_udp_demo_sendbuf[16]=lwipdev.gateway[2];
// tcp_udp_demo_sendbuf[17]=lwipdev.gateway[3];
// tcp_udp_demo_sendbuf[22]=TCP_UDP_PORT_FLG;
tcp_udp_demo_sendbuf[0]=0x0a;
tcp_udp_demo_sendbuf[1]=0x0b;
tcp_udp_demo_sendbuf[2]=0x0b;
tcp_udp_demo_sendbuf[3]=0x0c;
tcp_udp_demo_sendbuf[4]=0x0d;
tcp_udp_demo_sendbuf[5]=0x0e;
tcp_udp_demo_sendbuf[6]=0x0a;
tcp_udp_demo_sendbuf[7]=0x0b;
tcp_udp_demo_sendbuf[8]=0x0c;
tcp_udp_demo_sendbuf[9]=0x0d;
tcp_udp_demo_sendbuf[10]=0x0e;
tcp_udp_demo_sendbuf[11]=0x0a;
tcp_udp_demo_sendbuf[12]=0x0b;
tcp_udp_demo_sendbuf[13]=0x0c;
tcp_udp_demo_sendbuf[14]=0x0d;
tcp_udp_demo_sendbuf[15]=0x0e;
tcp_udp_demo_sendbuf[16]=0x0a;
tcp_udp_demo_sendbuf[17]=0x0b;
tcp_udp_demo_sendbuf[18]=0x0c;
tcp_udp_demo_sendbuf[19]=0x0d;
tcp_udp_demo_sendbuf[20]=0x0e;
tcp_udp_demo_sendbuf[21]=0x0a;
tcp_udp_demo_sendbuf[22]=0x0b;
tcp_udp_demo_sendbuf[23]=0x0c;
tcp_udp_demo_sendbuf[24]=0x0d;
tcp_udp_demo_sendbuf[25]=0x0e;
tcp_udp_demo_sendbuf[26]=0x0c;
tcp_udp_demo_sendbuf[27]=0x0d;
tcp_udp_demo_sendbuf[28]=0x0e;
tcp_udp_demo_sendbuf[29]=0x0a;
tcp_udp_demo_sendbuf[30]=0x0b;
tcp_udp_demo_sendbuf[31]=0x0c;
tcp_udp_demo_sendbuf[32]=0x0d;
tcp_udp_demo_sendbuf[33]=0x0e;
tcp_udp_demo_sendbuf[34]=0x0c;
tcp_udp_demo_sendbuf[35]=0x0d;
tcp_udp_demo_sendbuf[36]=0x0e;
tcp_udp_demo_sendbuf[37]=0x0c;
tcp_udp_demo_sendbuf[38]=0x0d;
tcp_udp_demo_sendbuf[39]=0x0e;
tcp_udp_demo_sendbuf[40]=0x0a;
tcp_udp_demo_sendbuf[41]=0x0b;
tcp_udp_demo_sendbuf[42]=0x0c;
tcp_udp_demo_sendbuf[43]=0x0d;
tcp_udp_demo_sendbuf[44]=0x0e;
tcp_udp_demo_sendbuf[45]=0x0a;
tcp_udp_demo_sendbuf[46]=0x0b;
tcp_udp_demo_sendbuf[47]=0x0b;
tcp_udp_demo_sendbuf[48]=0x0c;
tcp_udp_demo_sendbuf[49]=0x0d;
tcp_udp_demo_sendbuf[50]=0x0e;
tcp_udp_demo_sendbuf[51]=0x0a;
tcp_udp_demo_sendbuf[52]=0x0b;
tcp_udp_demo_sendbuf[53]=0x0c;
tcp_udp_demo_sendbuf[54]=0x0d;
tcp_udp_demo_sendbuf[55]=0x0e;
tcp_udp_demo_sendbuf[56]=0x0a;
tcp_udp_demo_sendbuf[57]=0x0b;
tcp_udp_demo_sendbuf[58]=0x0c;
tcp_udp_demo_sendbuf[59]=0x0d;
tcp_udp_demo_sendbuf[60]=0x0e;
tcp_udp_demo_sendbuf[61]=0x0a;
tcp_udp_demo_sendbuf[62]=0x0b;
tcp_udp_demo_sendbuf[63]=0x0c;
tcp_udp_demo_sendbuf[64]=0x0d;
tcp_udp_demo_sendbuf[65]=0x0e;
tcp_udp_demo_sendbuf[66]=0x0a;
tcp_udp_demo_sendbuf[67]=0x0b;
tcp_udp_demo_sendbuf[68]=0x0c;
tcp_udp_demo_sendbuf[69]=0x0d;
tcp_udp_demo_sendbuf[70]=0x0e;
tcp_udp_demo_sendbuf[71]=0x0c;
tcp_udp_demo_sendbuf[72]=0x0d;
tcp_udp_demo_sendbuf[73]=0x0e;
tcp_udp_demo_sendbuf[74]=0x0a;
tcp_udp_demo_sendbuf[75]=0x0b;
tcp_udp_demo_sendbuf[76]=0x0c;
tcp_udp_demo_sendbuf[77]=0x0d;
tcp_udp_demo_sendbuf[78]=0x0e;
tcp_udp_demo_sendbuf[79]=0x0c;
tcp_udp_demo_sendbuf[80]=0x0d;
tcp_udp_demo_sendbuf[81]=0x0e;
tcp_udp_demo_sendbuf[82]=0x0c;
tcp_udp_demo_sendbuf[83]=0x0d;
tcp_udp_demo_sendbuf[84]=0x0e;
tcp_udp_demo_sendbuf[85]=0x0a;
tcp_udp_demo_sendbuf[86]=tcp_client_porth; //这个能接收到,
tcp_udp_demo_sendbuf[87]=tcp_client_portl; //这个能接收到,
tcp_udp_demo_sendbuf[88]=udp_porth; //这里就收不到了
tcp_udp_demo_sendbuf[89]=udp_portl; //这里也收不到了
LCD_ShowString(30,270,200,16,16,"send ok");
readip_send_ok=1;
read_ip_ok=0;
}
es->p=pbuf_alloc(PBUF_TRANSPORT, strlen((char*)tcp_udp_demo_sendbuf),PBUF_POOL); //?ê??????
pbuf_take(es->p,(char*)tcp_udp_demo_sendbuf,strlen((char*)tcp_udp_demo_sendbuf)); //??tcp_udp_demo_sentbuf[]
//??????????±???es->p_tx??
tcp_client_senddata(tpcb,es);//??tcp_udp_demo_sentbuf[]??????????pbuf??????·???????
tcp_client_sta&=~(1<<7); //????????·???±ê??
if(es->p)pbuf_free(es->p); //??·?????
}else if(es->state==ES_TCPCLIENT_CLOSING)
{
tcp_client_connection_close(tpcb,es);//??±?TCP????
}
ret_err=ERR_OK;
}else
{
tcp_abort(tpcb);//????????,????pcb?????é
ret_err=ERR_ABRT;
}
return ret_err;
}
|
最佳答案
查看完整内容[请看2#楼]
回复【2楼】zuozhongkai:
---------------------------------
找到了问题,是因为strlen()函数遇到0就把后面的数据给丢弃了,我发的是16进制数,数据中有0,看来还是用字符串或字符与PC机交互。
谢了。
|