Show Posts
Pages: 1 ... 156 157 [158] 159 160 ... 408
2356  Using Arduino / Networking, Protocols, and Devices / Re: Ethernet library modification on: August 05, 2013, 05:24:10 am
My code works fine with the page request and the favicon request. It doesn't return a favicon.ico file, but the web browser finishes the download.
http://playground.arduino.cc/Code/WebServerST

The requests for each file will use separate sockets. Closing one will not close the other.
2357  Using Arduino / Networking, Protocols, and Devices / Re: email using arduino on: August 05, 2013, 05:08:25 am
It connected to the server, but the email server did not send a hello message. That would happen if it is not an email server. What server are you using?

edit: This also happens if it is an email server designed to accept email from client applications (Outlook or Thunderbird) on a secure port, like 465 or 587. Those ports normally require TLS, and the ethernet library does not support that.

You need to find the server that handles email for that domain on port 25. I use nslookup for that.
Code:
nslookup
set query=mx
mydomain.com
2358  Using Arduino / Networking, Protocols, and Devices / Re: Ethernet shield fails to connect to weather API, Telnet works, Google works on: August 04, 2013, 12:39:40 pm
If you use dhcp, don't forget to put the Ethernet.maintain() call in the loop(). You wouldn't want your ip to expire while the Arduino is using it. I use static ips.

edit: I added the Ethenet.maintain() call to the code above. Every minute or so should be plenty. The call doesn't do anything until the ip lease has reached half the expiration time.
2359  Using Arduino / Networking, Protocols, and Devices / Re: Ethernet shield fails to connect to weather API, Telnet works, Google works on: August 04, 2013, 12:21:42 pm
So far it is working ok here. I made the change to the page, and I presume you are getting the weather for Sunnyvale, Ca.

Change it to whatever time period you want. I had 30 seconds set in the playground.

The router doesn't know about the build. If you don't change the mac address, you should get the same ip for a while. I'm using dhcp.

There is one thing about dhcp. You must call Ethernet.maintain() in the loop() to renew the ip lease.
2360  Using Arduino / Networking, Protocols, and Devices / Re: Ethernet shield fails to connect to weather API, Telnet works, Google works on: August 04, 2013, 11:57:49 am
This is working right now on mine. I modified it somewhat to suit your requirements. The site says that is not a valid city. I'm on pass 9 now. It takes 30 seconds to start.
Code:
/*
   Web client sketch for IDE v1.0.1 and w5100/w5200
   Uses GET method.
   Posted October 2012 by SurferTim
   Last modified June 17, 2013
*/

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

// this must be unique
byte mac[] = {  0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };

char server[] = "weather.yahooapis.com";

int serverPort = 80;

EthernetClient client;
int totalCount = 0;
int loopCount = 0;
char pageAdd[32];

void setup() {
  Serial.begin(9600);

  // disable SD SPI
  pinMode(4,OUTPUT);
  digitalWrite(4,HIGH);

  // Start ethernet
  Serial.println(F("Starting ethernet..."));
  if(!Ethernet.begin(mac)) Serial.println(F("failed"));
  else Serial.println(F("ok"));
  digitalWrite(10,HIGH);

  Serial.println(Ethernet.localIP());

  delay(2000);
  Serial.println(F("Ready"));
}

void loop()
{
  if(loopCount < 30)
  {
    // if loopCount is less than 30, just delay a second
    delay(1000);
  }
  else
  {
    // every thirty seconds this runs

    // check ip lease renewal
    int ethStatus = Ethernet.maintain();

    if(ethStatus) {
        Serial.print(F("DHCP check..."));

        switch(ethStatus) {
            case 1: Serial.println(F("renew fail"));
                       break;
            case 2: Serial.println(F("renew ok"));
                       break;
            case 3: Serial.println(F("rebind fail"));
                       break;
            case 4: Serial.println(F("rebind ok"));
                       break;
        }
    }

    loopCount = 0;

    // Modify next line to load different page
    // or pass values to server
    sprintf(pageAdd,"/forecastrss?w=2502265&u=c");

    if(!getPage(server,serverPort,pageAdd)) Serial.print(F("Fail "));
    else Serial.print(F("Pass "));
    totalCount++;
    Serial.println(totalCount,DEC);
  }    

  loopCount++;
}

byte getPage(char *ipBuf,int thisPort, char *page)
{
  int inChar;
  char outBuf[128];

  Serial.print(F("connecting..."));

  if(client.connect(ipBuf,thisPort))
  {
    Serial.println(F("connected"));

    sprintf(outBuf,"GET %s HTTP/1.1",page);
    client.println(outBuf);
    sprintf(outBuf,"Host: %s",ipBuf);
    client.println(outBuf);
    client.println(F("Connection: close\r\n"));
  }
  else
  {
    Serial.println(F("failed"));
    return 0;
  }

  // connectLoop controls the hardware fail timeout
  int connectLoop = 0;

  while(client.connected())
  {
    while(client.available())
    {
      inChar = client.read();
      Serial.write(inChar);
      // set connectLoop to zero if a packet arrives
      connectLoop = 0;
    }

    connectLoop++;

    // if more than 10000 milliseconds since the last packet
    if(connectLoop > 10000)
    {
      // then close the connection from this end.
      Serial.println();
      Serial.println(F("Timeout"));
      client.stop();
    }
    // this is a delay for the connectLoop timing
    delay(1);
  }

  Serial.println();

  Serial.println(F("disconnecting."));
  // close client end
  client.stop();

  return 1;
}
edit: It works ok if you change the page to this. The @ doesn't work there.
/forecastrss?w=2502265&u=c
2361  Using Arduino / Networking, Protocols, and Devices / Re: Ethernet shield fails to connect to weather API, Telnet works, Google works on: August 04, 2013, 11:24:13 am
The second attempt failed.  Am I blocked again already? This is nuts.
I wouldn't think so. What URL are you trying? What page? I will try it with my client code.
2362  Using Arduino / Networking, Protocols, and Devices / Re: Ethernet shield fails to connect to weather API, Telnet works, Google works on: August 04, 2013, 09:24:56 am
You can test that theory by changing your mac address. Like this:
Code:
byte mac[] = {0x90,0xA2,0xDA,0x0D,0x40,0x73};
2363  Using Arduino / Project Guidance / Re: Ethernet with SD card Shield - Compiling larger scripts. on: August 04, 2013, 05:40:56 am
If you want more memory, get a Mega 2560. Besides, the Commodore 64 has twice the memory of an Uno. And the link you provided shows "This webpage is not available". I can certainly get an Uno to do that part!
2364  Using Arduino / Interfacing w/ Software on the Computer / Re: decoding a GET response from an HTML form on: August 03, 2013, 12:46:54 pm
Here is web server code that parses two variables, but it should be no problem to do 5.
http://playground.arduino.cc/Code/WebServerST
2365  Using Arduino / Programming Questions / Re: Arduino to web host connection failed on: August 03, 2013, 08:27:10 am
Here is the thread that had the lockup fail in it. Another user found the fail, I just fixed it.
http://forum.arduino.cc/index.php?topic=102879.0
2366  Using Arduino / Programming Questions / Re: Arduino to web host connection failed on: August 03, 2013, 07:44:53 am
Unless you live in "Perfect World", this will lock up in this while loop eventually. I've tested it. It may be a couple hours or maybe a couple days, but eventually...
Code:
  while (client.connected() || client.available()) { //connected or data available
    char c = client.read(); //gets byte from ethernet buffer
    Serial.print(c); //prints byte to serial monitor
  }
It needs a timeout to abort that loop in the event of a connection fail, like a hardware failure enroute.
2367  Using Arduino / Networking, Protocols, and Devices / Re: Xively & ethernet shield timeout on: August 02, 2013, 10:38:10 am
Quote
Nobody uses Xively and thinks response is almost useless and wrong to wait for it?
I did not say or even imply that. What I said was you should do things the other way around.

Take a look at my client code.
http://playground.arduino.cc/Code/WebClient
I would do something like this. This checks the server for clients every trip thru the while loop. This presumes you have a function doServerClient(EthernetClient srvclient); that gets the client request and returns a response.
Code:
while(client.connected())
  {
    while(client.available())
    {
      // get the packet
      inChar = client.read();
      Serial.write(inChar);
      // set connectLoop to zero if a packet arrives
      connectLoop = 0;
    }

    connectLoop++;

    // if more than 10000 milliseconds since the last packet
    if(connectLoop > 10000)
    {
      // then close the connection from this end.
      Serial.println();
      Serial.println(F("Timeout"));
      client.stop();
    }

    // check the server
    EthernetClient srvclient = server.available();

    // If server client, take care of it, else delay 1ms
    if(srvclient) doServerClient(srvclient);
    else delay(1);
  }
2368  Using Arduino / Networking, Protocols, and Devices / Re: FTP conection to arduino SD card via ethernet on: August 02, 2013, 08:48:01 am
What operating system do you have on the PC? If you want to use FTP, the PC must be the FTP server. With Windows XP Pro, you can install a http and ftp server in your control panel. Select "Add or Remove Programs" and select "Add/Remove Windows Components". Select IIS and install. FTP is one of the services under IIS.
2369  Using Arduino / Networking, Protocols, and Devices / Re: FTP conection to arduino SD card via ethernet on: August 01, 2013, 05:20:53 am
I can give you a link to my server code. You should be able to modify it to download other file types besides html docs.
http://playground.arduino.cc/Code/WebServerST

You should look up html Content-Type and Content-Length header values. Those will determine what the client thinks the file type an length is.
2370  Using Arduino / Storage / Re: SPI sensor -> SD on: August 01, 2013, 04:56:45 am
OK. Try this. Disable the SD SPI for a test. Does the sensor respond correctly?
Code:
void setup() {
    
    // initialize serial i/o
    Serial.begin(9600);
    
    // disable SD SPI
    pinMode(4, OUTPUT);
    digitalWrite(4, HIGH);

    // initialize SPI interface
    SPI.begin();
// rest of your setup
   
Pages: 1 ... 156 157 [158] 159 160 ... 408