server is at 255.255.255.255 madness!

The EtherTen combines an Uno-equivalent Arduino-compatible board and Wiznet-based Ethernet support, along with a microSD card slot and Power-over-Ethernet support. [Product page]
Post Reply
mowgli
Posts: 5
Joined: Sat Sep 29, 2012 2:31 am

server is at 255.255.255.255 madness!

Post by mowgli » Sat Sep 29, 2012 2:52 am

IDE 1.0.1
EtherTEN v1.1
Windows 7

I've done plenty with Arduino and ATtiny over the years so I though setting up an EtherTEN as a webserver would be a doddle. Problem steps as follows

* Brand new EtherTEN
* Fresh install Arduino IDE (no previous versions present)
* Update the device driver to recognise the 8u2
* Open IDE and upload Basics/Blink to test connections - SUCCESS
* Open Ethernet/WebServer, change IP and upload - PROBLEM

The sketch compiles without error and the EtherTEN is running. Trouble is that the IP address has not been applied. Serial monitor displays "server is at 255.255.255.255" and naturally the EtherTEN doesn't respond to http requests on the intended IP. Relevant code snippet below.

Code: Select all

byte mac[] = { 
  0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress ip(10,0,0,50);
So I get suspicious about the declaration of IPAddress. I went delving into the ethernet library and noticed that Ethernet.h includes IPAddress.h but that IPAddress.h doesn't exist. Strange that the compiler doesn't complain.

I've Googled up a storm but nowhere have I found any reference to this problem. I'm starting to think that my library examples are inconsistent with the installed libraries.

I'm about to try an earlier IDE but thought someone on here might have other ideas?

Rob

mowgli
Posts: 5
Joined: Sat Sep 29, 2012 2:31 am

Re: server is at 255.255.255.255 madness!

Post by mowgli » Sat Sep 29, 2012 3:24 am

I should have added that I can ping the board at the intended address and that the serial monitor doesn't show any client connections.

I've now tried IDE 1.0 and 023. The results are identical. I'm back into the Ethernet library to understand what is going on.

mowgli
Posts: 5
Joined: Sat Sep 29, 2012 2:31 am

Re: server is at 255.255.255.255 madness!

Post by mowgli » Sat Sep 29, 2012 4:17 am

Okay, so I did some digging in the library folder and noticed there are several constructors for the Ethernet class so I've made mine more explicit.

Code: Select all

IPAddress ip(10,0,0,50);
IPAddress dnsserver(10,0,0,1);
IPAddress gateway(10,0,0,1);
IPAddress subnet(255,0,0,0);
and in setup()

Code: Select all

  Ethernet.begin(mac, ip, dnsserver, gateway, subnet);
  server.begin();
  Serial.print("server is at ");
  Serial.println(Ethernet.localIP());
  Serial.print("subnet mask ");
  Serial.println(Ethernet.subnetMask());
  Serial.print("gateway IP ");
  Serial.println(Ethernet.gatewayIP());
  Serial.print("dns server IP ");
  Serial.println(Ethernet.dnsServerIP());
The serial monitor now shows

Code: Select all

server is at 255.255.255.255
subnet mask 255.255.255.225
gateway IP 255.225.255.225
dns server IP 10.0.0.1
This makes sense, since the dns server IP is set locally within the constructor

Code: Select all

void EthernetClass::begin(uint8_t *mac, IPAddress local_ip, IPAddress dns_server, IPAddress gateway, IPAddress subnet)
{
  W5100.init();
  W5100.setMACAddress(mac);
  W5100.setIPAddress(local_ip._address);
  W5100.setGatewayIp(gateway._address);
  W5100.setSubnetMask(subnet._address);
  _dnsServerAddress = dns_server;
}
The other settings are stored and retrieved from within the W5100 class. Delving deeper the actual code that stores and retrieves the values is

Code: Select all

void W5100Class::getIPAddress(uint8_t *_addr) {
  readSIPR(_addr);
}

void W5100Class::setIPAddress(uint8_t *_addr) {
  writeSIPR(_addr);
}
But this is where the trail goes cold for me. I can't find the declarations of read/writeSIPR. I presume the writeSIPR is working as the W5100 responds to ping requests.

Thoughts? Anyone?

mowgli
Posts: 5
Joined: Sat Sep 29, 2012 2:31 am

Re: server is at 255.255.255.255 madness!

Post by mowgli » Sat Sep 29, 2012 7:00 am

I now see read/writeSIPR defined in w5100.h as pre-processor macros.

The piece I now don't understand is where the 255.255.255.255 values are coming from. Device defaults perhaps?

mowgli
Posts: 5
Joined: Sat Sep 29, 2012 2:31 am

Re: server is at 255.255.255.255 madness!

Post by mowgli » Sat Sep 29, 2012 7:35 am

Problem solved.

Removing the SDcard fixed the problem. So the SDcard select pin must be floating. Adding

Code: Select all

  pinMode(4, OUTPUT);
  digitalWrite(4, LOW);
To setup() fixes the problem temporarily.

ngp99
Posts: 49
Joined: Sat Jul 14, 2012 1:53 am
Location: Dee Why NSW

Re: server is at 255.255.255.255 madness!

Post by ngp99 » Sun Sep 30, 2012 2:51 am

Hummmm. The only post I actually understand is the last one. So what happens when you want to use the SD card? A principle reason for getting the EtherTen was that both the EtherNet and the SD are built-in, hence there should be no conflict.

The only way I could get the Ethernet to do anything was to run the example DhcpAddressPrinter and thus actually see something on the monitor - the IP address, and use that for ever more. I also ran from CMD Msconfig /all, noted the MAC address, and use one that is one character different.

I have succeeded with the Twitter Feeder at
http://www.instructables.com/id/Arduino ... ial/#step1
and thus conclude my gear is fundamentally sound. It s a bit like the dog catching the car. I have no idea what to do with it.

I want to use the Freetronics on-line thermometer. It compiles OK but I have no ide what to next. The SD is in place but not in service at this stage. It doesn't seem to be causing a problem.

jebz
Posts: 33
Joined: Sun Feb 12, 2012 10:58 pm

SD card and ethernet.

Post by jebz » Tue Oct 02, 2012 11:04 pm

ngp99 wrote:Hummmm. The only post I actually understand is the last one. So what happens when you want to use the SD card? A principle reason for getting the EtherTen was that both the EtherNet and the SD are built-in, hence there should be no conflict.
The recommendation is to not have an SD card in when the project doesn't need it. The alternative is you need to deselect D4 that's the SD chip select so the data lines don't conflict with the ethernet operation.

ngp99
Posts: 49
Joined: Sat Jul 14, 2012 1:53 am
Location: Dee Why NSW

Re: server is at 255.255.255.255 madness!

Post by ngp99 » Wed Oct 03, 2012 12:39 am

jebz wrote: deselect D4 that's the SD chip select so the data lines don't conflict with the ethernet operation.
OK, I assume that becomes part of the main loop. How do I do that? I have never seen any indication of the actual select, so I guess it is hidden away in SD.h

On reflection, I realise that may be only a partial solution. My real problem is reading the SD card over the internet.

jebz
Posts: 33
Joined: Sun Feb 12, 2012 10:58 pm

Re: SD card and ethernet.

Post by jebz » Wed Oct 03, 2012 10:17 am

ngp99 wrote: OK, I assume that becomes part of the main loop. How do I do that? I have never seen any indication of the actual select, so I guess it is hidden away in SD.h
In Arduino V1.0 the SD and Ethernet work together. I included the code below in the setup and allowed the libraries to take care of the rest.

Code: Select all

// The select pin used for the SD card
#define SD_SELECT 4
#define ETHERNET_SELECT 10

void setup()
{
  // Configure all of the SPI select pins as outputs and make SPI
  // devices inactive, otherwise the earlier init routines may fail
  // for devices which have not yet been configured.
  pinMode(SD_SELECT, OUTPUT);
  digitalWrite(SD_SELECT, HIGH); // disable SD card

  pinMode(ETHERNET_SELECT, OUTPUT);
  digitalWrite(ETHERNET_SELECT, HIGH); // disable Ethernet

Post Reply