搜索
bottom↓
回复: 2

ENC28J60在51单片机上的移植(uIP0.9)的请教 其中电路图 程序是卖家送的。谢谢大家,有会

[复制链接]

出0入0汤圆

发表于 2011-6-21 21:28:48 | 显示全部楼层 |阅读模式
我现在是把卖家给的51的代码下载到STC89C516RD+中,能正常显示WEB SEVER的网页。

其中51单片机与ENC28J60的连接接口定义在SPI.H中。我发现INT引脚好像并没有用到。而且WOL网络唤醒也没有用到。

(1)但是不稳定。不知道是不是没有时基的原因。因为我看程序中好像是直接延时完成的。
(2)而且不清楚怎么更改HTTPD.C中不同的网页对应的显示内容。这个里面是uIP0.9在51上的移植。希望懂的朋友给帮个忙啊。
我主要是想把DS18B20的温度上传到网页中。谢谢……

这里是卖家给的资料,全部放在这里供大家使用。
里面有电路图,程序(51 AVR STM32)ourdev_650945MVERES.rar(文件大小:1.89M) (原文件名:网络模块 卖家资料.rar)

其中51的程序、STM32程序我都测试通过。只不过 感觉都不太稳定,特别是51的基于uIP0.9的,感觉有点复杂。

阿莫论坛20周年了!感谢大家的支持与爱护!!

曾经有一段真挚的爱情摆在我的面前,我没有珍惜,现在想起来,还好我没有珍惜……

出0入0汤圆

 楼主| 发表于 2011-6-21 21:41:21 | 显示全部楼层
好像判断网页与单片机控制的服务器通信的控制在这里面,但是不太清楚是怎么控制的。谢谢……
void
httpd_appcall(void)
{
  struct fs_file fsfile;  

  u8_t i;

  switch(uip_conn->lport) {
    /* This is the web server: */
  case HTONS(80):
    /* Pick out the application state from the uip_conn structure. */
    hs = (struct httpd_state *)(uip_conn->appstate);

    /* We use the uip_ test functions to deduce why we were
       called. If uip_connected() is non-zero, we were called
       because a remote host has connected to us. If
       uip_newdata() is non-zero, we were called because the
       remote host has sent us new data, and if uip_acked() is
       non-zero, the remote host has acknowledged the data we
       previously sent to it. */
    if(uip_connected()) {
      /* Since we have just been connected with the remote host, we
         reset the state for this connection. The ->count variable
         contains the amount of data that is yet to be sent to the
         remote host, and the ->state is set to HTTP_NOGET to signal
         that we haven't received any HTTP GET request for this
         connection yet. */
      hs->state = HTTP_NOGET;
      hs->count = 0;
      return;

    } else if(uip_poll()) {
      /* If we are polled ten times, we abort the connection. This is
         because we don't want connections lingering indefinately in
         the system. */
      if(hs->count++ >= 10) {
        uip_abort();
      }
      return;
    } else if(uip_newdata() && hs->state == HTTP_NOGET) {
      /* This is the first data we receive, and it should contain a
         GET. */
      
      /* Check for GET. */
      if(uip_appdata[0] != ISO_G ||
         uip_appdata[1] != ISO_E ||
         uip_appdata[2] != ISO_T ||
         uip_appdata[3] != ISO_space) {
        /* If it isn't a GET, we abort the connection. */
        uip_abort();
        return;
      }
               
      /* Find the file we are looking for. */
      for(i = 4; i < 40; ++i) {
        if(uip_appdata == ISO_space ||
           uip_appdata == ISO_cr ||
           uip_appdata == ISO_nl) {
          uip_appdata = 0;
          break;
        }
      }

      PRINT("request for file ");
      PRINTLN(&uip_appdata[4]);
      
      /* Check for a request for "/". */
      if(uip_appdata[4] == ISO_slash &&
         uip_appdata[5] == 0) {
        fs_open(file_index_html->name, &fsfile);   
      } else {
        if(!fs_open((const char *)&uip_appdata[4], &fsfile)) {
          PRINTLN("couldn't open file");
          fs_open(file_404_html->name, &fsfile);
        }
      }


      if(uip_appdata[4] == ISO_slash &&
         uip_appdata[5] == ISO_c &&
         uip_appdata[6] == ISO_g &&
         uip_appdata[7] == ISO_i &&
         uip_appdata[8] == ISO_slash) {
        /* If the request is for a file that starts with "/cgi/", we
           prepare for invoking a script. */       
        hs->script = fsfile.dat;
        next_scriptstate();
      } else {
        hs->script = NULL;
        /* The web server is now no longer in the HTTP_NOGET state, but
           in the HTTP_FILE state since is has now got the GET from
           the client and will start transmitting the file. */
        hs->state = HTTP_FILE;

        /* Point the file pointers in the connection state to point to
           the first byte of the file. */
        hs->dataptr = fsfile.dat;
        hs->count = fsfile.len;       
      }     
    }

   
    if(hs->state != HTTP_FUNC) {
      /* Check if the client (remote end) has acknowledged any data that
         we've previously sent. If so, we move the file pointer further
         into the file and send back more data. If we are out of data to
         send, we close the connection. */
      if(uip_acked()) {
        if(hs->count >= uip_conn->len) {
          hs->count -= uip_conn->len;
          hs->dataptr += uip_conn->len;
        } else {
          hs->count = 0;
        }
       
        if(hs->count == 0) {
          if(hs->script != NULL) {
            next_scriptline();
            next_scriptstate();
          } else {
            uip_close();
          }
        }
      }         
    } else {
      /* Call the CGI function. */
      if(cgitab[hs->script[2] - ISO_a](uip_acked())) {
        /* If the function returns non-zero, we jump to the next line
           in the script. */
        next_scriptline();
        next_scriptstate();
      }
    }

    if(hs->state != HTTP_FUNC && !uip_poll()) {
      /* Send a piece of data, but not more than the MSS of the
         connection. */
      uip_send(hs->dataptr, hs->count);
    }

    /* Finally, return to uIP. Our outgoing packet will soon be on its
       way... */
    return;

  default:
    /* Should never happen. */
    uip_abort();
    break;
  }  
}

出0入0汤圆

发表于 2014-7-7 21:11:34 | 显示全部楼层
楼主,请问在连网时ping的是哪个ip是ping uipopt.h的UIP_IPADDR宏定义的那个ip吗?那个ip是自己设定还是必须是当前电脑的ip?我一直不知道到底ping哪个ip

回帖提示: 反政府言论将被立即封锁ID 在按“提交”前,请自问一下:我这样表达会给举报吗,会给自己惹麻烦吗? 另外:尽量不要使用Mark、顶等没有意义的回复。不得大量使用大字体和彩色字。【本论坛不允许直接上传手机拍摄图片,浪费大家下载带宽和论坛服务器空间,请压缩后(图片小于1兆)才上传。压缩方法可以在微信里面发给自己(不要勾选“原图),然后下载,就能得到压缩后的图片。注意:要连续压缩2次才能满足要求!!】。另外,手机版只能上传图片,要上传附件需要切换到电脑版(不需要使用电脑,手机上切换到电脑版就行,页面底部)。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

手机版|Archiver|amobbs.com 阿莫电子技术论坛 ( 粤ICP备2022115958号, 版权所有:东莞阿莫电子贸易商行 创办于2004年 (公安交互式论坛备案:44190002001997 ) )

GMT+8, 2024-8-26 03:54

© Since 2004 www.amobbs.com, 原www.ourdev.cn, 原www.ouravr.com

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