Ethernet between two mbeds

31 Oct 2011

Hello everyone,

I am trying to connect two mbeds through ethernet. Connections are:

  • RD- to TD-
  • RD+ to TD+
  • TD- to RD-
  • TD+ to RD+

The first mbed code is:

#include "mbed.h"

Serial pc(USBTX, USBRX); // tx, rx

Ethernet eth;

int main()
{
    pc.baud(115200);
    wait(1);

    pc.printf("Press any key to start...\r\n");
    pc.getc(); // wait for keyboard
   
    while(1) 
    {    
        char buf = 0x20;
        pc.printf("Value to send = %d\n", buf);
        eth.write(&buf, 1);        
        wait(5);
    }
}

The second mbed code is

#include "mbed.h"

Serial pc(USBTX, USBRX); // tx, rx

Ethernet eth;

int main()
{
    pc.baud(115200);
    wait(1);
 
    char buf;
    
    while(1)
    {
        int size = eth.receive();
        if(size > 0) 
        {            
            eth.read(&buf, 1);
            printf("Destination:  %02X\n", buf);
        }

        wait(1);
    }
}

Is there something wrong with these connections or the code? I cannot get a reply from the second mbed.

31 Oct 2011

Now I'm not an ethernet guru, but I believe any attempt to use it like a serial point-to-point interface is doomed to fail (please correct if I'm missing something here). But have a look here: http://mbed.org/forum/mbed/topic/1307/?page=1#comment-6423

Keywords to search for are "sockets", and "UDP", for example.