7 years ago.

EtherInterface with K64F problems

I have been having a lot of problems using EthernetInteface library with FRDM K64F. The code simply doesn't work at all. Even if I don't use the library I get errors.

When I add the library I get an error asking for "rtos.h". So I add the "mbed-rtos" library.

My code now has 4 libraries: mbed, mbed-rtos, TextLCD and EthernetInterface. So I tried a basic code just to see if everything is in order:

EDFA Control

#include "mbed.h"
#include "TextLCD.h" //  A TextLCD interface for driving 4-bit HD44780-based LCDs

// LCD
TextLCD lcd(D2,D3,D4,D5,D6,D7); //(rs,e,d4-d7)


  int main() {
      lcd.printf("Hello World!\n");
  }

// This code doesn't even use the library but I keep getting these errors and warnings:

Warning: Enumeration value is out of "int" range in "extras/mbed_e7ca05fa8600/TARGET_K64F/TARGET_Freescale/TARGET_MCUXpresso_MCUS/TARGET_MCU_K64F/drivers/fsl_dspi.h", Line: 67, Col: 29

Warning: Enumeration value is out of "int" range in "extras/mbed_e7ca05fa8600/TARGET_K64F/TARGET_Freescale/TARGET_MCUXpresso_MCUS/TARGET_MCU_K64F/drivers/fsl_dspi.h", Line: 74, Col: 28

Warning: Enumeration value is out of "int" range in "extras/mbed_e7ca05fa8600/TARGET_K64F/TARGET_Freescale/TARGET_MCUXpresso_MCUS/TARGET_MCU_K64F/drivers/fsl_dspi.h", Line: 81, Col: 40

Warning: Enumeration value is out of "int" range in "extras/mbed_e7ca05fa8600/TARGET_K64F/TARGET_Freescale/TARGET_MCUXpresso_MCUS/TARGET_MCU_K64F/drivers/fsl_dspi.h", Line: 87, Col: 33

Warning: Enumeration value is out of "int" range in "extras/mbed_e7ca05fa8600/TARGET_K64F/TARGET_Freescale/TARGET_MCUXpresso_MCUS/TARGET_MCU_K64F/drivers/fsl_edma.h", Line: 145, Col: 24

Warning: Enumeration value is out of "int" range in "extras/mbed_e7ca05fa8600/TARGET_K64F/TARGET_Freescale/TARGET_MCUXpresso_MCUS/TARGET_MCU_K64F/drivers/fsl_uart.h", Line: 159, Col: 30

Warning: Enumeration value is out of "int" range in "extras/mbed_e7ca05fa8600/TARGET_K64F/TARGET_Freescale/TARGET_MCUXpresso_MCUS/TARGET_MCU_K64F/drivers/fsl_flash.h", Line: 497, Col: 48

Error: Struct "_enet_handle" has no field "rxBdDirty" in "EthernetInterface/lwip-eth/arch/TARGET_Freescale/k64f_emac.c", Line: 86, Col: 19

Error: Struct "_enet_handle" has no field "rxBdDirty" in "EthernetInterface/lwip-eth/arch/TARGET_Freescale/k64f_emac.c", Line: 89, Col: 19

Info: Unable to download. Fix the reported errors...

Does anyone know what these problems refer to? Anyone else has problems with these libraries? I have put them to work before but now I just get these random errors and warnings.

1 Answer

7 years ago.

Caio,

Look's like you are trying to use an mbed2 repository but wanting the functionality contained in mbed5 (the most current, RTOS version of mbed).

I would recommend creating a new project (online compiler or via Mbed CLI) and make sure the following libraries are added:

Libraries

mbed add mbed-os
mbed add http://os.mbed.com/users/simon/code/TextLCD/

This adds mbed (with RTOS features) and LCD libraries to the project. Note that we are adding mbed-os, not mbed. mbed-os has RTOS features PLUS the network stack. You do have to import the specific header file in your code though (shown below).

Then, use the following code (which can be found here:

Example of LCD + Ethernet with K64

#include "mbed.h"
#include "TextLCD.h" //  A TextLCD interface for driving 4-bit HD44780-based LCDs
#include "EthernetInterface.h"

// LCD
TextLCD lcd(D2,D3,D4,D5,D6,D7); //(rs,e,d4-d7)

// Network interface
EthernetInterface net;

// Socket demo
int main() {
    // Bring up the ethernet interface
    lcd.printf("Ethernet socket example\n");
    net.connect();

    // Show the network address
    const char *ip = net.get_ip_address();
    lcd.printf("IP address is: %s\n", ip ? ip : "No IP");

    // Open a socket on the network interface, and create a TCP connection to mbed.org
    TCPSocket socket;
    socket.open(&net);
    socket.connect("developer.mbed.org", 80);

    // Send a simple http request
    char sbuffer[] = "GET / HTTP/1.1\r\nHost: developer.mbed.org\r\n\r\n";
    int scount = socket.send(sbuffer, sizeof sbuffer);
    lcd.printf("sent %d [%.*s]\n", scount, strstr(sbuffer, "\r\n")-sbuffer, sbuffer);

    // Recieve a simple http response and print out the response line
    char rbuffer[64];
    int rcount = socket.recv(rbuffer, sizeof rbuffer);
    lcd.printf("recv %d [%.*s]\n", rcount, strstr(rbuffer, "\r\n")-rbuffer, rbuffer);

    // Close the socket to return its memory and bring down the network interface
    socket.close();

    // Bring down the ethernet interface
    net.disconnect();
    lcd.printf("Done\n");
}

Accepted Answer

I will try it soon and I'll tell you if it worked. Thank you for answering.

posted by Caio Santos 23 Nov 2017

It worked out well. Thank you very much.

posted by Caio Santos 23 Nov 2017