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

📄 slipdev.c

📁 keil c编写的单片机实现web服务 包含原程序和可执行文件
💻 C
字号:
/* * Copyright (c) 2001, Adam Dunkels. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright *    notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright *    notice, this list of conditions and the following disclaimer in the *    documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software *    must display the following acknowledgement: *      This product includes software developed by Adam Dunkels. * 4. The name of the author may not be used to endorse or promote *    products derived from this software without specific prior *    written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * This file is part of the uIP TCP/IP stack. * * $Id: slipdev.c,v 1.1 2001/11/20 20:49:45 adam Exp $ * */#include "uip.h"#include <8051io.h>#define SLIP_END     0xc0#define SLIP_ESC     0xdb#define SLIP_ESC_END 0xdc#define SLIP_ESC_ESC 0xdd#define SIO_RECV(c)  while((c = chkchr()) == -1)#define SIO_SEND(c)  putchr(c)#define MAX_SIZE UIP_BUFSIZEstatic const unsigned char slip_end = SLIP_END,                           slip_esc = SLIP_ESC,                           slip_esc_end = SLIP_ESC_END,                           slip_esc_esc = SLIP_ESC_ESC;/*-----------------------------------------------------------------------------------*/voidslipdev_send(void){#if MAX_SIZE >= 256  u16_t i;#else  u8_t i;#endif /* MAX_SIZE >= 256 */  u8_t *ptr;  u8_t c;  SIO_SEND(slip_end);  ptr = uip_buf;  for(i = 0; i < uip_len; ++i) {	if (i == 40) {      ptr = uip_appdata;    }    c = *ptr++;    switch(c) {    case SLIP_END:      SIO_SEND(slip_esc);      SIO_SEND(slip_esc_end);      break;    case SLIP_ESC:      SIO_SEND(slip_esc);      SIO_SEND(slip_esc_esc);      break;    default:      SIO_SEND(c);      break;    }  }  SIO_SEND(slip_end);}/*-----------------------------------------------------------------------------------*/u16_tslipdev_read(void){  u8_t c; start: uip_len = 0;  while(1) {    if(uip_len >= MAX_SIZE) {      goto start;    }    SIO_RECV(c);    switch(c) {    case SLIP_END:      if(uip_len > 0) {        return uip_len;      } else {	goto start;      }      break;    case SLIP_ESC:      SIO_RECV(c);      switch(c) {      case SLIP_ESC_END:        c = SLIP_END;        break;      case SLIP_ESC_ESC:        c = SLIP_ESC;        break;      }      /* FALLTHROUGH */    default:      if(uip_len < MAX_SIZE) {	    uip_buf[uip_len] = c;        uip_len++;      }      break;    }  }  return 0;}/*-----------------------------------------------------------------------------------*/voidslipdev_init(void){}/*-----------------------------------------------------------------------------------*/void modem_request(void){  u8_t c;  do {    SIO_RECV(c);    if (c != 'C')      continue;    SIO_RECV(c);    if (c != 'L')      continue;    SIO_RECV(c);    if (c != 'I')      continue;    SIO_RECV(c);    if (c != 'E')      continue;    SIO_RECV(c);    if (c != 'N')      continue;    SIO_RECV(c);  } while (c != 'T');}void modem_reply(void){  putstr("CLIENTSERVER");}

⌨️ 快捷键说明

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