Ethernet pls help

06 Nov 2010

Hi

I am trying to get started with Ethernet.  I followed the instruction for connecting the four wires to magnetics etc on proto boards and got nowhere.  Then assuming that I had screwed up the connections ,  I bought a coolcomponenets board with RJ45 etc and still cannot get going.  My setup is local network with internet gateway PC running XP and I have fixed IP so code i have used is as per examples ( Donatiens et al ) but with change to remove DHCP

EthernetNetIf eth(

IpAddr(192,168,0,123), //IP Address

IpAddr(255,255,255,0), //Network Mask

IpAddr(192,168,0,1), //Gateway

IpAddr(192,168,0,1)  //DNS

);

 

The output I get on serial port

 

Setting up...

[..\fwk\if\eth\EthernetNetIf.cpp:setup@86] HW Addr is : 00:02:f7:f0:24:65.

[..\fwk\if\eth\EthernetNetIf.cpp:setup@142] Connected, IP : 192.168.0.123

Setup OK

Error 3

 

Can anyone help ?   What is error 3 ?

I am struggling as this is both new hardware to me and also I am having to learn c++ ( i have  java background) so I am not sure what is going wrong.  I have got the MBED to interface to compasses and accelerometers etc but this lack of Ethernet is holding me up.

Many thanks

Regards

Steve

07 Nov 2010

Stephen,

Take a look at this and load the TEST Code.  Look at your DHCP tables in your router:

http://mbed.org/forum/mbed/topic/1239/?page=1#comment-6091

Hope this helps....

Jeff - Portland, Oregon

07 Nov 2010

If you can see MY MBED in your Router DHCP table then you know the Ethernet port and Hardware is working.

Jeff

07 Nov 2010

If you're using a static IP address (not DHCP) then your MBED won't be in your router's DHCP table.

You can verify the MBED's presence on the network by bringing up a DOS window in your XP machine and entering "arp -a" You should see a line with the MBED's hardware (MAC) and IP addresses in the XP machine's arp table.

I'm not sure what's generating the "Error 3" but I suspect it's not an error but the enumerated value of ETH_OK.

Harry

 

08 Nov 2010

Thanks Guys,

 

Harry I tried the arp -a and it does not show the MBED.  Does the MBED need to be running some specific code for this to work ?

I have downloaded wireshark but need to understand how to drive it as there loads of unrelated packets and I guess i need to appply filters ( on MAC ?)

Next I am going to setup DHCP on seperate windows network and download binanries dierct from MBED site to exclude anything that may be wrong with my source.

If that doesnt work the MBED wil be put up for sale as I cant waste any more time,  I thought this was supposed to be a rapid development solution.

Regards

Steve

 

.

 

 

 

08 Nov 2010

Steve,

I think the test program you are running registers itself on the local network, contacts the Internet for the "Hello World" message and then goes into a spin loop or ends. The "Error 3" message would then come from an lwIP based service and indicate an inability to resolve a DNS name. Is your router connected to the Internet and a DNS hierarchy?

The program should register itself by sending a gratuitous broadcast ARP announcing the MBED's MAC address and the IP address it intends to use. This is to make sure the IP address isn't already in use and allow any TCP/IP stacks that receive the message to add the MBED to its ARP cache. Once the program does its test process; it ends; it is effectively not listening and is off the network


Your router may be acting like a switch in which case the XP PC may not receive the gratuitous ARP. There are two types of broadcasts: Ethernet (OSI level 2) and IP (OSI level 3). A broadcast (MAC or IP) is sent to all members of its subnet, but the MAC and IP subnet may not be the same. This is why I use a hub instead of a switch; I sometimes interconnect hundreds of MBEDs and other embedded devices.

You are probably further along than you realize. Why not move on to some of the more advanced examples? Examples that don't end and are more representive of your needs. For example, do you even need IP? or will raw Ethernet suffice?

Maybe post more information of what your intended use is.

Harry

08 Nov 2010

I have now tried a few of the 'working' examples on the MBED website ( soem dont even compile - ho hum ) and the only one that produces any activity is the ethersniff_hex which seems to capture packets when the cable is plugged in so the inbound path may be working.  typical packet received is 0230: 00 00 00 A8 AA 2A 00 00  A8 AA 6A 55 55 01 00 40 : .....*.. ..jUU..@  not suer of that is correct

Is there a simple PING type prog out there ?

Many thanks

Steve

08 Nov 2010 . Edited: 08 Nov 2010

Hi Steve,

I'm not sure quite what you are running when you see "Error 3", but assuming it is the Working with the Networking Stack example, then that would suggest you are seeing the message generated from these lines:

HTTPResult r = http.get("http://mbed.org/media/uploads/donatien/hello.txt", &txt);
  if(r==HTTP_OK)
  {
    printf("Result :\"%s\"\n", txt.gets()); 
  }
  else
  {
    printf("Error %d\n", r);
  }

If that is the case, looking at Donatiens HTTPClient code it'll be printing out the HTTPResult:

///HTTP client results
enum HTTPResult
{
  HTTP_OK, ///<Success
  HTTP_PROCESSING, ///<Processing
  HTTP_PARSE, ///<URI Parse error
  HTTP_DNS, ///<Could not resolve name
  HTTP_PRTCL, ///<Protocol error
  HTTP_NOTFOUND, ///<HTTP 404 Error
  HTTP_REFUSED, ///<HTTP 403 Error
  HTTP_ERROR, ///<HTTP xxx error
  HTTP_TIMEOUT, ///<Connection timeout
  HTTP_CONN ///<Connection error
};
So 3 would indicate it is failing to resolve the name using DNS.

 

Simon

08 Nov 2010 . Edited: 08 Nov 2010

Hi Stephen,

I used Ilya l's HTTP web server successfully - once compiled and loaded, the mbed is constantly listening and responds to ping requests. You can easily modify it to get what you want it to do, either to return a static page, respond to rpc commands etc. It can be found here and the file to modify is main.cpp about line 149. By default it uses DHCP but I modified mine to use a static IP which is read from a local file on the mbed. It means you don't have to compile again if you want to change the static IP addrress.

When HTTPServer http(hostname) is called, if the only argument passed is the hostname then DHCP is used. Otherwise use something along the lines of:

char *hostname = "mbed";
cip = IPv4(192,168,0,123);
cdns = IPv4(192,168,0,1);
cgw = IPv4(192,168,0,1);
csm = IPv4(255,255,255,0);

HTTPServer http(hostname,cip,csm,cgw,cdns);

There used to be a bug in it whereby it hung if no ethernet connection was found when the mbed was restarted. Just make sure that a cat5e cable is plugged into your mbed from your router before restarting and testing it. 

Mike   

19 Nov 2010

Hi,  I now have working Ethernet see reference by Simon Ford to the 10/100 MB setup ( see http://mbed.org/forum/helloworld/topic/1404/?page=1#comment-6945 ) made me check my hub,  which was an old junker 10MB only. I have now connected to another hub with 100MB support and all is working - fantastic.  Many thanks to all who have helped.

Regards

Steve

29 Sep 2011

Your have problems with your IP... it shouldnt be 192.168.0.123 it should be 192.168.1.123