Go Down

Topic: Debugging Web Client with Ethernet shield (Read 3 times) previous topic - next topic

3en

Thank you so much Fubushi for helping me out. I can't express how much gratitude I have towards you.

You can find the packet dump here: http://dl.getdropbox.com/u/263645/Arduino/ArduinoWireSharkDump1.pcap

I'm using an ethernet cable connected to my Macbook. Using Apple OSX's internet sharing options. I have made sure I manually select the IP of the Macbook machine and have cross checked the subnet.

And I've included the code that I'm using just to make sure below:

Code: [Select]

#include <Ethernet.h>

byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
byte ip[] = { 169, 254, 196, 50 };
byte server[] = { 74, 125, 67, 100 }; // Google
byte subnet[] = { 255, 255, 0, 0 };    //subnet mask of the network
byte gateway[] = { 169, 254, 196, 45 };   //your router's IP address

Client client(server, 80);

void setup()
{
 Ethernet.begin(mac, ip, gateway, subnet);
 Serial.begin(9600);
 
 delay(1000);
 
 Serial.println("connecting...");
     client.println("Connecting");
 
 if (client.connect()) {
   Serial.println("connected");
   client.println("GET /search?q=arduino HTTP/1.0");
   client.println();
 } else {
   Serial.println("connection failed");
 }
}

void loop()
{
 if (client.available()) {
   char c = client.read();
   Serial.print(c);
         client.println("Working");

 }
 
 if (!client.connected()) {
   Serial.println();
   Serial.println("disconnecting.");
   client.stop();
   for(;;)
     ;
 }
}



Any ideas?

Fubushi

Loads of ideas.

I will have to check out the OSX Internet Sharing and come back to you.

Can you ping the Arduino from the Mac?

Fubushi

Now...
With a little bit more time :)

Soo... The MacBook has 169.254.196.45 (most likely given by autoconfiguration).
The Arduino has 168.254.196.50.

The Mac answers the Arduino's ARP request, which is fine!

For some reason, the MacBook also seems to have 192.168.2.1.

So far, so good.

Try the following:

Set the Arduino IP address to 192.168.2.2, the Gateway to 192.168.2.1 and the netmask to 255.255.255.0.







3en

It works! :-)

Thank you so much. So what was going on there? And if I write about how to figure this out, how should I go about explaining that?

I'm assuming that the macbook takes two IPs and one of them is accessible to the internet and the other is local?

Fubushi

Yep, that is more or less it. :)

You can then use addresses in 192.168.2.x to share your connection.

Call it bad documentation on Apple's side.

Go Up