📄 task3_websever.c.svn-base
字号:
/****************************************************************************
函数名称:Task3()
说明: 任务3,
调用函数:提供测试的Http页面
输入参数:*Id 任务ID
输出参数:无
****************************************************************************/
#include "includes.h"
#include "os_tasks.h"
#include "globe.h"
#include "netif.h"
#include "ne2kif.h"
#include "tcpip.h"
#include "memp.h"
#include "webpage.c"
OS_STK Task3Stack[TASK3_STACKSIZE];
///////////////////////////////////////////////
void Task3(void *pdata)
{
#if OS_CRITICAL_METHOD == 3 /* Allocate storage for CPU status register */
OS_CPU_SR cpu_sr;
#endif
////////////////////////
struct netconn *conn, *newconn;
//err_t err;
pdata = pdata; //just aviod warning
/* Create a new connection identifier. */
conn = netconn_new(NETCONN_TCP);
/* Bind connection to well known port number 7. */
netconn_bind(conn, NULL, 80);
/* Tell connection to go into listening mode. */
netconn_listen(conn);
while(1) {
/* Grab new connection. */
newconn = netconn_accept(conn);
/*printf("accepted new connection %p\n", newconn);*/
/* Process the new connection. */
if(newconn != NULL) {
struct netbuf *buf;
char *rq; //nothingbn 06_03_20
u16_t len;
while((buf = netconn_recv(newconn)) != NULL) {
/*printf("Recved\n");*/
do {
netbuf_data(buf, (void**)&rq, &len);
//nothingbn 06_03_20
if(rq[0] == 'G' && rq[1] == 'E' &&
rq[2] == 'T' && rq[3] == ' ' &&
rq[4] == '/' && rq[5] == ' ')
{
/* Send the header. */
//netconn_write(newconn, (void*)http_html_hdr, sizeof(http_html_hdr),NETCONN_COPY);//sdy060614
/* Send the actual web page. */
netconn_write(newconn, (void*)indexdata, sizeof(indexdata),NETCONN_COPY);
/* Close the connection. */
netconn_close(newconn);
}
//err = netconn_write(newconn, data, len, NETCONN_COPY);
//if(err != ERR_OK) {
/* printf("tcpecho: netconn_write: error \"%s\"\n", lwip_strerr(err));*/
//}
} while(netbuf_next(buf) >= 0);
netbuf_delete(buf);
}
/*printf("Got EOF, looping\n");*/
/* Close connection and discard connection identifier. */
netconn_delete(newconn);
}
}
////////////////////////
OSTaskSuspend(OS_PRIO_SELF);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -