Pages: [1]   Go Down
Author Topic: Debugging Web Client with Ethernet shield  (Read 2278 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 19
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Code:
   
    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.
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 19
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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 smiley
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 19
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

<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.
« Last Edit: September 28, 2009, 10:25:02 am by 3en » Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 19
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Actually my problem still exists.

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

Code:
   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:
connecting...
connection failed

disconnecting.

I have also tried trying to pass messages via ethernet.

Code:
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
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 19
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Sorry - only reading here now and then smiley

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.

Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 19
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
#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?
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 19
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 19
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Now...
With a little bit more time smiley

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.






Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 19
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 19
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Yep, that is more or less it. smiley

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

Call it bad documentation on Apple's side.
Logged

Pages: [1]   Go Up
Jump to: