Pages: [1]   Go Down
Author Topic: Why UDP_TX_PACKET_MAX_SIZE have 24 bytes?  (Read 1888 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi,

this is the first post for me...
so hi all smiley

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 smiley-wink

bye
d.
Logged

Offline Offline
Edison Member
*
Karma: 29
Posts: 2449
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi cjdelphi,

thanks for your interest.

But if i want to use only UDP in my arduino? smiley
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?
smiley-grin

thanks,
d.
Logged

Offline Offline
Edison Member
*
Karma: 29
Posts: 2449
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 4
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
#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:
   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:
// 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.
Logged

Pages: [1]   Go Up
Jump to: