OpenEdv-开源电子网

 找回密码
 立即注册
正点原子全套STM32/Linux/FPGA开发资料,上千讲STM32视频教程免费下载...
查看: 8459|回复: 3

uIP实验handle_input()函数里一死循环

[复制链接]

1

主题

2

帖子

0

精华

新手上路

积分
28
金钱
28
注册时间
2015-4-7
在线时间
0 小时
发表于 2015-4-7 22:57:08 | 显示全部楼层 |阅读模式
5金钱
uIP实验handle_input()函数如下:
{      
char *strx;
u8 dbuf[17];
PSOCK_BEGIN(&s->sin);  
PSOCK_READTO(&s->sin, ISO_space);  
if(strncmp(s->inputbuf, http_get, 4)!=0)PSOCK_CLOSE_EXIT(&s->sin); //±??????§???????÷????????????·????ê??WEB???? ?°GET ?±   
PSOCK_READTO(&s->sin, ISO_space);     //" "
if(s->inputbuf[0] != ISO_slash)PSOCK_CLOSE_EXIT(&s->sin); //??????????(????IP???·?®?ó)????,??·???"/"
if(s->inputbuf[1] == ISO_space||s->inputbuf[1] == '?') //????????????????/????

if(s->inputbuf[1]=='?'&&s->inputbuf[6]==0x31)//LED1  
{  
LED0=!LED0;
strx=strstr((const char*)(data_index_html+13),"LED0×???");  
if(strx)//????"LED0×???"????×?·??®
{
strx=strstr((const char*)strx,"color:#");//????"color:#"×?·??®
if(LED0)//LED0??
{
strncpy(strx+7,"5B5B5B",6); //????
strncpy(strx+24,"??",2); //??
strx=strstr((const char*)strx,"http:");//????"http:"×?·??® 
strncpy(strx,(const char*)LED_OFF_PIC_ADDR,strlen((const char*)LED_OFF_PIC_ADDR));//LED0??????  
}else
{
strncpy(strx+7,"FF0000",6); //?ì??
strncpy(strx+24,"??",2); //"??"
strx=strstr((const char*)strx,"http:");//????"http:"×?·??® 
strncpy(strx,(const char*)LED0_ON_PIC_ADDR,strlen((const char*)LED0_ON_PIC_ADDR));//LED0??????  
}
}  
}else if(s->inputbuf[1]=='?'&&s->inputbuf[6]==0x32)//LED2  
{  
LED1=!LED1;
strx=strstr((const char*)(data_index_html+13),"LED1×???");  
if(strx)//????"LED1×???"????×?·??®
{
strx=strstr((const char*)strx,"color:#");//????"color:#"×?·??®
if(LED1)//LED1??
{
strncpy(strx+7,"5B5B5B",6); //????
strncpy(strx+24,"??",2); //??
strx=strstr((const char*)strx,"http:");//????"http:"×?·??® 
strncpy(strx,(const char*)LED_OFF_PIC_ADDR,strlen((const char*)LED_OFF_PIC_ADDR));//LED1??????  
}else
{
strncpy(strx+7,"00FF00",6); //????
strncpy(strx+24,"??",2); //"??"
strx=strstr((const char*)strx,"http:");//????"http:"×?·??® 
strncpy(strx,(const char*)LED1_ON_PIC_ADDR,strlen((const char*)LED1_ON_PIC_ADDR));//LED1??????  
}

}
strx=strstr((const char*)(data_index_html+13),"??");//????"??"×?·?
if(strx)
{
get_temperature(dbuf); //????????  
strncpy(strx-4,(const char*)dbuf,4); //?ü??????
}
strx=strstr((const char*)strx,"RTC?±??:");//????"RTC?±??:"×?·?
if(strx)
{
get_time(dbuf); //?????±??  
strncpy(strx+33,(const char*)dbuf,16); //?ü???±??
}
strncpy(s->filename, http_index_html, sizeof(s->filename));
}else //????????' '/'?'
{
s->inputbuf[PSOCK_DATALEN(&s->sin)-1] = 0;
strncpy(s->filename,&s->inputbuf[0],sizeof(s->filename));
}   
s->state = STATE_OUTPUT;    
while(1) 
{
PSOCK_READTO(&s->sin, ISO_nl);
if(strncmp(s->inputbuf, http_referer, 8) == 0) 
{
s->inputbuf[PSOCK_DATALEN(&s->sin) - 2] = 0;   
}
}    
PSOCK_END(&s->sin);
}
最后这个while(1) 死循环是怎么退出的?请高人指点啊!

正点原子逻辑分析仪DL16劲爆上市
回复

使用道具 举报

530

主题

11万

帖子

34

精华

管理员

Rank: 12Rank: 12Rank: 12

积分
165371
金钱
165371
注册时间
2010-12-1
在线时间
2110 小时
发表于 2015-4-7 23:52:57 | 显示全部楼层
uip进行了很多次封装,代码结构比较怪异。
有些是宏,里面带return的,你把所有的宏展开看看,就知道了
我是开源电子网www.openedv.com站长,有关站务问题请与我联系。
正点原子STM32开发板购买店铺http://openedv.taobao.com
正点原子官方微信公众平台,点击这里关注“正点原子”
回复

使用道具 举报

1

主题

2

帖子

0

精华

新手上路

积分
28
金钱
28
注册时间
2015-4-7
在线时间
0 小时
 楼主| 发表于 2015-4-8 10:18:35 | 显示全部楼层
回复【2楼】正点原子:
---------------------------------
为什么我做实验时通信老是断,是uIP协议的问题么?
回复

使用道具 举报

530

主题

11万

帖子

34

精华

管理员

Rank: 12Rank: 12Rank: 12

积分
165371
金钱
165371
注册时间
2010-12-1
在线时间
2110 小时
发表于 2015-4-8 23:15:56 | 显示全部楼层
回复【3楼】hxinstar:
---------------------------------
建议用lwip
我是开源电子网www.openedv.com站长,有关站务问题请与我联系。
正点原子STM32开发板购买店铺http://openedv.taobao.com
正点原子官方微信公众平台,点击这里关注“正点原子”
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则



关闭

原子哥极力推荐上一条 /2 下一条

正点原子公众号

QQ|手机版|OpenEdv-开源电子网 ( 粤ICP备12000418号-1 )

GMT+8, 2025-2-24 12:39

Powered by OpenEdv-开源电子网

© 2001-2030 OpenEdv-开源电子网

快速回复 返回顶部 返回列表