12 years, 7 months ago.

Problem excercise 4.1 (ethernet) book ARM MICROCONTROLLERS2 BERT VAN DAM

Hello, This is a book that uses the mbed microcontroller. I succeeded the other examples in this book without a problem. This is a chapter about Ethernet. The example code (whitch i copy paste from the website, so no typemistakes) gives a lot of erros anybody already succesfully made this example?? thnx in advance

#include "mbed.h"
#include "EthernetNetIf.h"
#include "HTTPServer.h"

EthernetNetIf eth;
HTTPServer svr;

DigitalOut led1(LED1, "led1");



int main() {

    EthernetErr ethErr;
    int count = 0;
    do {
        printf("Setting up %d...\n\r", ++count);
        ethErr = eth.setup();
        if (ethErr) printf("Timeout\n\r", ethErr);
    } while (ethErr != ETH_OK);

    printf("Connected OK\n\r");
    const char* hwAddr = eth.getHwAddr();

    IpAddr ethIp = eth.getIp();
    printf("IP address : %d.%d.%d.%d\n\r", ethIp[0], ethIp[1], ethIp[2], ethIp[3]);

    svr.addHandler<SimpleHandler>("/hello");

    svr.bind(80);
    printf("Server listening\n\r");

    Timer tm;
    tm.start();

    while (true) {
        Net::poll();
        if (tm.read() > 0.5) {
            led1 = !led1;
            tm.start();
        }
    }
}


"no instance of constructor "mbed::DigitalOut::DigitalOut" matches the argument list" in file "InetTest//main.cpp", Line: 8, Col: 29
"identifier "PinDirection" is undefined" in file "mbed.bld//gpio_api.h", Line: 32, Col: 41
"identifier "PIN_INPUT" is undefined" in file "mbed.bld//DigitalIn.h", Line: 55, Col: 30
"class "mbed::Base" has no member "add_rpc_class"" in file "InetTest/RPCInterface//SerialRPCInterface.cpp", Line: 42, Col: 10
"type name is not allowed" in file "InetTest/RPCInterface//SerialRPCInterface.cpp", Line: 42, Col: 24
"expected an expression" in file "InetTest/RPCInterface//SerialRPCInterface.cpp", Line: 42, Col: 34

in total 45 of this errors, but they all look like the 6 i posted

thnx again

1 Answer

12 years, 7 months ago.

Hi, Adrian, first the EthernetNetIf and HTTPServer libraries are deprecated.

Second why dont you try this HTTPServer Example for this page (is the same exercise you post, but is working and dont have errors), but remenber that this exercise use deprecated libraries

http://mbed.org/cookbook/HTTP-Server

Greetings

P.D. The new EthernetInterface doc is here: http://mbed.org/handbook/Ethernet-Interface

Accepted Answer

Hello, why is this library deprecated? On google i find that this means that you should avoid to use this?

posted by Adriaan Van Steendam 04 May 2013

Hi, Adrian, deprecated means that the library maybe in any moment can dissapear or that the support for the library will end. If you look in wikipedia http://en.wikipedia.org/wiki/Deprecation in the part of "Reasons for deprecation" you will find for what i do my recomendation

Greetings

posted by Ney Palma 04 May 2013

Hi Ney, Ok thnx i see, so i will work with the new library instead, but i got some new problems there, i posted a new question about the problem i have with the example program TCP socket Hello world which i found on the new ethernetinterface.doc. if your familiar with this could you have a look please? Thnx in advance Greetings

posted by Adriaan Van Steendam 04 May 2013