Go Down

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

3en

I am using the Arduino Ethernet shield and using the example web client code (where it connects to google).

Code: [Select]
   
   Serial.println("connected");
   client.println("GET /search?q=arduino HTTP/1.0");
   client.println();


How do I see on the web server or keep a log of what the Arduino client sends to the webserver (via telnet?), in order to use it for debugging.

Fubushi

Too much work to do it on the Arduino side.

Get Wireshark from www.wireshark.org and install it on the client.

Much more comfy :)

3en

#2
Sep 28, 2009, 03:16 pm Last Edit: Sep 28, 2009, 05:25 pm by 3en Reason: 1
<Edit: this problem still exists please read the next post>

Thanks Fubushi. That makes sense, why didn't I think of that before. Doh.

Though I wish on the Arduino site it would make that suggestion, so that I didn't need to scratch my head and wonder.

Once I figure out doing the basic stuff with the ethernet shield I plan on making a blog post to help others out on all of the basic stuff.

3en

Actually my problem still exists.

Using the example web client code and Wireshark I am not able to see

Code: [Select]
   Serial.println("This is test debug code");

Also if I try to connect to the USB serial monitor with Arduino. It doesn't connect.

Code: [Select]
connecting...
connection failed

disconnecting.


I have also tried trying to pass messages via ethernet.

Code: [Select]
client.println("This is other debug code");


The only thing I'm picking up from Wireshark is a TCP SYN packet to the google server.

blackjack > http [SYN] Seq=0 Win=2048 Len=0 MSS=1460

Fubushi

Sorry - only reading here now and then :)

Is the Arduino connected to the Internet directy, via PPPoE or proxy/router/firewall?

(Just in case, the SYN is supposed to be answered by ACK, SYN which in turn the Arduino should answer with ACK, then start talking...)

GOOD news: Your packet is being sent out. Check destination IP address.

BAD news: There is no answer. Some details about network structure and the packet capture might be helpful.


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