Hello,
I have a question about the library UIPEthernet.h because I have a lake of flash for my programm. (This question may be usefull for the others big library).
Secondly, I looked at the library examples and I was surprise to than the example below is very big computed : 25 466 bytes ! With an arduino Uno with 32k of flash, there is not a lot of free memory !
So, I would like to know if there is a way to compute only the functions and dependencies necessary for the programm ?
#include <UIPEthernet.h>
EthernetClient client;
signed long next;
void setup() {
Serial.begin(9600);
uint8_t mac[6] = {0x00,0x01,0x02,0x03,0x04,0x05};
Ethernet.begin(mac);
Serial.print("localIP: ");
Serial.println(Ethernet.localIP());
Serial.print("subnetMask: ");
Serial.println(Ethernet.subnetMask());
Serial.print("gatewayIP: ");
Serial.println(Ethernet.gatewayIP());
Serial.print("dnsServerIP: ");
Serial.println(Ethernet.dnsServerIP());
next = 0;
}
void loop() {
if (((signed long)(millis() - next)) > 0)
{
next = millis() + 5000;
Serial.println("Client connect");
// replace hostname with name of machine running tcpserver.pl
// if (client.connect("server.local",5000))
if (client.connect(IPAddress(192,168,0,1),5000))
{
Serial.println("Client connected");
client.println("DATA from Client");
while(client.available()==0)
{
if (next - millis() < 0)
goto close;
}
int size;
while((size = client.available()) > 0)
{
uint8_t* msg = (uint8_t*)malloc(size);
size = client.read(msg,size);
Serial.write(msg,size);
free(msg);
}
close:
//disconnect client
Serial.println("Client disconnect");
client.stop();
}
else
Serial.println("Client connect failed");
}
}
OK, So, I conclude the library I choose is very big. (but I do not have the choice because of my shield is not compatible with Ethernet.h)
I compared the cumputing of a simple sample with the library UIPEthernet.h and Ethernet.h.
The result is very different : lightly more than 15k for Ethernet.h and 22k for UIPEthernet.h.
I am surprised of this difference.
tack:
Use a static IP, instead of DHCP like you have, and you can lose the UDP functions.
If you don't need DHCP nor DNS and use TCP-only, you can save aprox. 5k of flash by turning off UDP entirely. To do so set UIP_CONF_UDP to 0 in uipethernet-conf.h
You also might want to check out the version in branch static-memory which saves a few hundred bytes compared to the one in master.
If you don't need DHCP nor DNS and use TCP-only, you can save aprox. 5k of flash by turning off UDP entirely. To do so set UIP_CONF_UDP to 0 in uipethernet-conf.h
Thank you, I tried, and as you said : 5ko less !
Well it tends to help if you post the code YOU are using, and not just some example code. My crystal ball is out for repair again. LOL
LOL, I understand. My purpose was not to debug my code, but to understand why the library was so big.
As the "Simple Example" was big too, I did not wanted to complexity the problem. I think than is the problem is resolved with a simple example, it may be resolved for my programm.