Go Down

Topic: Why UDP_TX_PACKET_MAX_SIZE have 24 bytes? (Read 2252 times) previous topic - next topic

Rocco83

Hi,

this is the first post for me...
so hi all :)

said that, why UDP_TX_PACKET_MAX_SIZE is only 24 bytes?
Can i raise it up somehow?

i simply does not get the point ;)

bye
d.

cjdelphi

My bet is purely to save memory.... 2k sram, you're not going to be happy to find the TCP IP library uses up 1.5k of it are you? lol

Rocco83

Hi cjdelphi,

thanks for your interest.

But if i want to use only UDP in my arduino? :)
Why can't I decide how many sram for each protocol?
I already have a working framework, rewriting it is a pain!

so my second question is still:
Can i raise it up somehow?
:D

thanks,
d.

cjdelphi

simply change the values... should be that simple (all the const variables in the ethernet files)

Rocco83

Just to be sure about it:
i have to find (after arduino installation) the library and change the value in the .cpp and .h (or whatever), correct?

If i copy the file in my library which one is used?
my local or global library?

mmiller7


Just to be sure about it:
i have to find (after arduino installation) the library and change the value in the .cpp and .h (or whatever), correct?

If i copy the file in my library which one is used?
my local or global library?


Sorry for the late answer but I found this thread needing to solve the same problem myself.

This works without having to modify the stock library:
Code: [Select]

#include <EthernetUdp.h>
#define UDP_TX_PACKET_MAX_SIZE 860 //increase UDP size


By putting the #define line immediately after the header import (in your code), it seems to override the default #define and apply the new values to all the code that gets initialized later.  This eliminates any future issues that would occur modifying the standard library and also makes your code more portable if you share it with other users, it will "just work".

This can be verified later in the program:
Code: [Select]

   Serial.print(F("UDP_TX_PACKET_MAX_SIZE="));
   Serial.println(UDP_TX_PACKET_MAX_SIZE);


and if I parse out the  data I'm expecting I can see now I get all ~800 characters of my string.

Be careful not to fill up all the  RAM though, before changing the value you might want to run your program through execution at least once and then print the approx free memory:
Code: [Select]

// free RAM check for debugging. SRAM for ATmega328p = 2048Kb.
int availableMemory() {
   // Use 1024 with ATmega168
   int size = 2048;
   byte *buf;
   while ((buf = (byte *) malloc(--size)) == NULL);
       free(buf);
   return size;
}

and again after.

Go Up