赞
踩
/*
*******************************************************************************
* SmallBoxLwIP
*Description: LwIP函数入口
*Arguments : 无
*Returns : 无
*Note : V1.0 by Small.Box at 2008.05.20
*******************************************************************************
*/
void SmallBoxLwIP(void *arg)
{
struct netconn *conn;
int i,length;
unsigned char LD_Send_BUF[500];
unsigned char *pbData;
pUDPCONN udpconn;
struct LocalIPconfig Localipconfig;
for(i=0;i<500;i++) {
LD_Send_BUF[i]=0x55;
}
//设置本地IP地址
Localipconfig.ipaddr[0] = 192;
Localipconfig.ipaddr[1] = 168;
Localipconfig.ipaddr[2] = 2;
Localipconfig.ipaddr[3] = 2;
//设置本地网关
Localipconfig.gateway[0] = 192;
Localipconfig.gateway[1] = 168;
Localipconfig.gateway[2] = 2;
Localipconfig.gateway[3] = 1;
//设置本地的子网掩码
Localipconfig.mask[0] = 255;
Localipconfig.mask[1] = 255;
Localipconfig.mask[2] = 255;
Localipconfig.mask[3] = 0;
//设置服务端的IP地址
udpconn->ipaddr[0] = 192;
udpconn->ipaddr[1] = 168;
udpconn->ipaddr[2] = 2;
udpconn->ipaddr[3] = 1;
udpconn->port = 5000; //设置端口号
//初始化Lwip
LwIPInit();
//初始化以太网
SetupLwIP_Ethernet(Localipconfig);
while(1) {
conn = ReadUDPDev(udpconn);
while(1) {
length = ReadUDPDev(conn,&pbData); //读取数据
if(length > 0) {
WriteUDPDev(conn,LD_Send_BUF,200); //发送数据
CloseUDPDev(conn);
OSTimeDlyHMSM(0,0,2,0);
break;
}
OSTimeDlyHMSM(0,0,2,0);
}
}
}
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。