⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 egi_stat.c

📁 世纪民生公司的带网络功能的单片机CS6209开发http服务器的演示源代码。
💻 C
字号:
/*
 * 
 * Egi_stat.c
 * 
 * Part of the Myson Century CS620X	demo program.
 *
 * Authors: LY Lin, WM Wang, IJ Chen, WH Lee
 *
 * Egi_stat.c contains HTTP status.cgi callback routine.
 *
 * This	program	was developed using the Keil 8051 C uVision 2 system.
 * The Keil compiler MUST be used if working with Myson Century supplied
 * firmware.
 *
 * 
 *
*/


#include <stdio.h>
#include <string.h>
#include <ctype.h>

#include "ether.h"
#include "netutil.h"
#include "ip.h"
#include "tcp.h"
#include "config.h"
#include "http.h"
#include "status.h"

extern xdata unsigned char PORTB_EN;
extern xdata unsigned char PORTB;

sfr P1=0x90;
/************************************************************************
/*	Function Name : status_resp											*
/*																		*
/*	Arguments : 														*
/*			TSOCK xdata *ts: Point to TSOCK.							*
/*			char xdata *str: Point to egi comment tag string(<!--#)		*
/*							 or	NULL if this function is first time be  *
/*							 called.							 		*
/*																		*
/*	Return :															*
/*			None														*
/*  Comment :															*
/*			This function is a callback function for status.cgi. First,	*
/*			this function be called on the start of status.cgi with 	*
/*			str=NULL. Then when webpage meet egi comment tag(<!--#) ,	*
/*			this function will be called , the 'str' is point to egi 	*
/*			comment tag.												*
/*																		*
/************************************************************************/
void status_resp(TSOCK xdata *ts, char xdata *str)
{
    APPDATA *adp;
    unsigned char input, i;
    int which_bit, mask;
	RAM_WEB_PAGE *ptr_web_page;

    adp = (APPDATA *)ts->app;
    if (!str) /*The egi function is called the first time.*/
    {/*Init app for status.cgi. */
        adp->egi = status_resp;
        ptr_web_page = search_get_web_page ("status.cgi");
    	adp->in = ptr_web_page->RAM_WEB_PAGE_DATA;
  	    adp->file_length = ptr_web_page->RAM_WEB_PAGE_LEN;
    }
    else/*Egi comment tag.*/
    {
        str += EGI_STARTLEN;/*Skip "<!--#" .*/

		/*Egi web page needs P1 led data.*/
        if (!strncmp(str, "$led", 4) && isdigit(*(str+4)))
        {
            which_bit = *(str+4) - '0';
            mask = 1 << which_bit;
            buff_instr(&ts->txb, (P1 & mask) ? "1" : "0");
        }

		PORTB_EN=0xc0; /*Configure PortB as input pin.*/
		input=PORTB; 

		/*Egi web page needs PB switch data.*/
        if (!strncmp(str, "$switch", 7) && isdigit(*(str+7)))
        {
	    i = *(str+7) - '0';
            buff_instr (&ts->txb, (input & (0x08 >> i)) ? "0" : "1"); 
        }

    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -