ethernet set_link()

16 Feb 2011

i am using the UDPSocketExample and i need to switch to 10mhz operation but i cant seem to get syntax right for

set_link(FullDuplex10);

when i try to compile i get class ethernetnetif has no member set_link

i have tried some of the examples in various posts but to no avail any assistance appreciated

many thanks

Chris

17 Feb 2011

Hi Chris,

Try Ethernet::FullDuplex10. Just a namespace issue i suspect, as FullDuplex10 is an enum that is part of the class.

Simon

17 Feb 2011

Hi Simon thanks for reply have tried suggestion but it still rejects it i think its due to the stack i'm using

with Ethernet eth;

eth.set_link(Ethernet::FullDuplex10); throws up no errors but if i use

EthernetNetIf eth;

eth.set_link(Ethernet::FullDuplex10); throws up error "Class "EthernetNetIf" has no member "set_link" (E135)

so it looks like the stack used in UDPSocketExample cant support that statement any suggestions or

am i being dim

many thanks

Chris

18 Feb 2011

I don't think that the EthernetNetIf class supports the set_link() method. There is an eth_interface() function exposed in the eth_drv.h header which returns a pointer to the mbed's Ethernet class used by the EthernetNetIf object.

I was able to modify the UDPSocketSample to get it build but I don't have an Ethernet port hooked up to my mbed yet to actually try it. The following code shows the highlights of what I changed in that example.

#include "mbed.h"
#include "EthernetNetIf.h"
#include "UDPSocket.h"
// NOTE: Added this header to get access to the eth_interface() function
#include "eth_drv.h"

EthernetNetIf eth;
UDPSocket     cfgSocket;

// NOTE: Snipped out onUDPSocketEvent() method code

int main() {
//   pc.baud(115200);
    printf ("HEllo World - 7 *\n");

    EthernetErr ethErr = eth.setup();
    if ( ethErr == ETH_OK ) {
        IpAddr ip = eth.getIp();
        printf("mbed IP Address is %d.%d.%d.%d\r\n", ip[0], ip[1], ip[2], ip[3]);

        // NOTE: Extract the mbed Ethernet object being used by the eth object and call the set_link() method on it
        Ethernet* pEthernet = eth_interface();
        pEthernet->set_link(Ethernet::FullDuplex10);
    } else printf ("ETHERNETSETUP FAILED\n");
    // NOTE: Snipped out the rest of the code from the example

Hopefully this will give you a non-NULL pEthernet object and the set_link() call gives you the expected behaviour.

18 Feb 2011

Hi Adam

thanks for the reply i will try this tonight and let you know how it goes

many thanks

Chris

18 Feb 2011

The one thing that I realize that is wrong with my solution above is that it will only set the link speed after the eth.setup() call which means that DHCP and probably even ARP packets have already been attempted at the higher speed by then.