极客工坊

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 15120|回复: 11

UNO+5100扩展板 做WWW服务器 总不稳定

[复制链接]
发表于 2014-8-4 16:17:53 | 显示全部楼层 |阅读模式
用的IDE中的webserver例子简单修改,现象:

1)网页刷新总是出乱码;
2)时间长了webserver会停止服务,但IP地址可以ping通。

请教下:不稳定是UNO固有的现象也就是硬件本身就不是很稳定,还是代码问题,和编译环境有多大关系?
回复

使用道具 举报

发表于 2014-8-4 16:50:39 | 显示全部楼层
uno的ram比较少。。。。
回复 支持 反对

使用道具 举报

发表于 2014-8-4 17:03:22 | 显示全部楼层
弘毅 发表于 2014-8-4 16:50
uno的ram比较少。。。。

请教一下,如果和 ram 有关系,那么理论上非常有可能被堵死耗光?

即便是高版本的话,如果我发起很多 session登录的话,也有可能搞死?
回复 支持 反对

使用道具 举报

发表于 2014-8-4 17:46:07 | 显示全部楼层
楼主上图上代码看看
回复 支持 反对

使用道具 举报

 楼主| 发表于 2014-8-7 16:05:37 | 显示全部楼层
代码就是案例里的,就改了下IP地址,WEB总是不稳定刷几分钟就停止了,但IP可以ping通
/*
  Web Server

A simple web server that shows the value of the analog input pins.
using an Arduino Wiznet Ethernet shield.

Circuit:
* Ethernet shield attached to pins 10, 11, 12, 13
* Analog inputs attached to pins A0 through A5 (optional)

created 18 Dec 2009
by David A. Mellis
modified 9 Apr 2012
by Tom Igoe

*/

#include <SPI.h>
#include <Ethernet.h>

// Enter a MAC address and IP address for your controller below.
// The IP address will be dependent on your local network:
byte mac[] = {
  0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress ip(192,168,0,177);

// Initialize the Ethernet server library
// with the IP address and port you want to use
// (port 80 is default for HTTP):
EthernetServer server(80);

void setup() {
// Open serial communications and wait for port to open:
  Serial.begin(9600);
   while (!Serial) {
    ; // wait for serial port to connect. Needed for Leonardo only
  }


  // start the Ethernet connection and the server:
  Ethernet.begin(mac, ip);
  server.begin();
  Serial.print("server is at ");
  Serial.println(Ethernet.localIP());
}


void loop() {
  // listen for incoming clients
  EthernetClient client = server.available();
  if (client) {
    Serial.println("new client");
    // an http request ends with a blank line
    boolean currentLineIsBlank = true;
    while (client.connected()) {
      if (client.available()) {
        char c = client.read();
        Serial.write(c);
        // if you've gotten to the end of the line (received a newline
        // character) and the line is blank, the http request has ended,
        // so you can send a reply
        if (c == '\n' && currentLineIsBlank) {
          // send a standard http response header
          client.println("HTTP/1.1 200 OK");
          client.println("Content-Type: text/html");
          client.println("Connection: close");  // the connection will be closed after completion of the response
          client.println("Refresh: 5");  // refresh the page automatically every 5 sec
          client.println();
          client.println("<!DOCTYPE HTML>");
          client.println("<html>");
          // output the value of each analog input pin
          for (int analogChannel = 0; analogChannel < 6; analogChannel++) {
            int sensorReading = analogRead(analogChannel);
            client.print("analog input ");
            client.print(analogChannel);
            client.print(" is ");
            client.print(sensorReading);
            client.println("<br />");      
          }
          client.println("</html>");
          break;
        }
        if (c == '\n') {
          // you're starting a new line
          currentLineIsBlank = true;
        }
        else if (c != '\r') {
          // you've gotten a character on the current line
          currentLineIsBlank = false;
        }
      }
    }
    // give the web browser time to receive the data
    delay(1);
    // close the connection:
    client.stop();
    Serial.println("client disonnected");
  }
}
回复 支持 反对

使用道具 举报

 楼主| 发表于 2014-8-7 16:13:09 | 显示全部楼层
后来我试验了telnet的案例,比用80端口的WEB稳定很多,
有什么区别么?HTML1.1和浏览器支持有问题么?
回复 支持 反对

使用道具 举报

发表于 2014-8-7 18:10:28 | 显示全部楼层
官网的这个程序我用过,测试跑过24小时,没有啥问题。基本排除程序问题。硬件上照片看看。
回复 支持 反对

使用道具 举报

 楼主| 发表于 2014-8-11 12:12:55 | 显示全部楼层
以下是串口监测显示,刷新几次后串口就不关闭了,应该是程序运行中间死掉了.
GET / HTTP/1.1
Accept: */*
Accept-Language: zh-cn
User-Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; GTB7.4; InfoPath.2; .NET4.0C; .NET CLR 2.0.50727)
Accept-Encoding: gzip, deflate
Host: 192.168.1.177
Connection: Keep-Alive

client disonnected
new client
GET / HTTP/1.1
Accept: image/gif, image/jpeg, image/pjpeg, image/pjpeg, application/x-shockwave-flash, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, application/xaml+xml, application/x-ms-xbap, application/x-ms-application, */*
Accept-Language: zh-cn
User-Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; GTB7.4; InfoPath.2; .NET4.0C; .NET CLR 2.0.50727)
Accept-Encoding: gzip, deflate
Host: 192.168.1.177
Connection: Keep-Alive

client disonnected
new client
GET / HTTP/1.1
Accept: image/gif, image/jpeg, image/pjpeg, image/pjpeg, application/x-shockwave-flash, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, application/xaml+xml, application/x-ms-xbap, application/x-ms-application, */*
Accept-Language: zh-cn
User-Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; GTB7.4; InfoPath.2; .NET4.0C; .NET CLR 2.0.50727)
Accept-Encoding: gzip, deflate
Host: 192.168.1.177
Connection: Keep-Alive

回复 支持 反对

使用道具 举报

 楼主| 发表于 2014-8-20 12:07:31 | 显示全部楼层
还是不稳定,这东西看来不是主流啊,怎么就没办法用呢?
回复 支持 反对

使用道具 举报

 楼主| 发表于 2014-8-23 00:12:55 | 显示全部楼层
还是不行,只好归结硬件的问题了。主板45元,W5100 42元,可能是赶上个质量不好的板子了。
回复 支持 反对

使用道具 举报

发表于 2014-8-27 16:01:12 | 显示全部楼层
LOOP 中,加个 Blink without Delay  例子中的闪灯看是否死掉,最好再测一下内存
回复 支持 反对

使用道具 举报

 楼主| 发表于 2014-8-29 12:59:37 | 显示全部楼层
wxws 发表于 2014-8-27 16:01
LOOP 中,加个 Blink without Delay  例子中的闪灯看是否死掉,最好再测一下内存

谢谢 我试验下
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|联系我们|极客工坊

GMT+8, 2026-6-16 00:20 , Processed in 0.068443 second(s), 22 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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