Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
7 years, 9 months ago.
LPC4088 + ethernet interface is not working
Hi, all!
I'm working with an LPC4088 QuickStart Board and using the TCPSocket_HelloWorld - main.cpp from https://os.mbed.com/handbook/Ethernet-Interface.
The code is running Ok, except for the ethernet and socket connections - when using eth.connect(), error -1 is returned. The same applies to sock.connect("os.mbed.com", 80).
Does anyone knows if there's any change I have to code or change to make the ethernet interface work?
Thanks
Ps. Code below.
Fávero
#include "mbed.h"
#include "EthernetInterface.h"
Serial serial_debug(USBTX, USBRX);
int main() {
EthernetInterface eth;
int16_t is_connected = 9;
int16_t is_socketed = 9;
serial_debug.baud(115200);
serial_debug.printf("\033[2J");
serial_debug.printf("\r -- Aloha! \n");
eth.init(); //Use DHCP
//eth.init("192.168.201.59", "255.255.255.0", "192.168.201.253");
is_connected = eth.connect(3000);
if (is_connected == 0){
serial_debug.printf("\r -- Connection OK!! \n");
}else if (is_connected != 0){
serial_debug.printf("\r -- Connect NOK!! \n");
serial_debug.printf("\r -- Error code: %d\n", is_connected);
}
serial_debug.printf("\r -- IP Address is %s\n", eth.getIPAddress());
TCPSocketConnection sock;
is_socketed = sock.connect("os.mbed.com", 80);
serial_debug.printf("\r -- Socket error: %d\n", is_socketed);
char http_cmd[] = "GET /media/uploads/mbed_official/hello.txt HTTP/1.0\n\n";
sock.send_all(http_cmd, sizeof(http_cmd)-1);
char buffer[300];
int ret;
while (true) {
ret = sock.receive(buffer, sizeof(buffer)-1);
if (ret <= 0)
break;
buffer[ret] = '\0';
serial_debug.printf("Received %d chars from server:\n%s\n", ret, buffer);
}
sock.close();
serial_debug.printf("\r -- Socket closed!\n");
eth.disconnect();
serial_debug.printf("\r -- Ethernet disconnected!\n");
while(1) {}
}
Hi! I did more research and I found out that error -1 in eth.connect is related to the error ERR_MEM - Out of memory, available in dhcp.c.
posted by Fávero Santos 11 Jan 2018