Skip to content

Settings

Juraj Andrassy edited this page Dec 8, 2020 · 5 revisions

The EthernetENC library has some settings to balance performance and memory usage. These settings are in utility/uipethernet-conf.h file or can be specified as -D parameters for compilation.

UIP_CONF_MAX_CONNECTIONS is a maximum number of connected EthernetClient connections. The default value s 4. You can set it to 0 if you don't use EthernetClient TCp connections. It will save a lot of dynamic memory.

UIP_SOCKET_NUMPACKETS is count of packet buffers for EthernetClient. Default is 3. It applies for transmit and receive packets. For received packets the packet over UIP_SOCKET_NUMPACKETS can't be received but TCP will try to deliver it again. For sent packets at full load one is waiting for ACK or retransmission, one is ready to be sent and one is composed by the sketch. Less than 3 packets degrades the performance. More packets only allows the sketch to dump the data faster to ENC. The UIP_SOCKET_NUMPACKETS * 2 is multiplied with UIP_CONF_MAX_CONNECTIONS for the size of the memory pool control array, which is the largest variable in the library. One item of the array has 5 bytes.

UIP_CONF_UDP can save 4 kB of flash memory if set to 0. It disables UDP support. Services relaying on UDP (DHCP, DNS) can't be used then. UDP is enabled by default.

UIP_CONF_UDP_CONNS The maximum amount of concurrent UDP connections. It is set to 2. The memory pool control array has (2+UIP_UDP_BACKLOG) items per UDP connection.

UIP_UDP_BACKLOG Size of received UDP messages backlog. It must be at least 1. Default is 2. Every additional backlog record takes 7 bytes of SRAM in backlog and some more in memory pool control array as documented above. UDP messages received for the port while the backlog is full are lost.

UIP_WRITE_TIMEOUT is the timeout in ms for attempts to get a free memory block to write before returning number of bytes sent so far. Set to 0 to block until connection is closed by timeout.

UIP_CONNECT_TIMEOUT is the timeout after which EthernetClient.connect gives up. The timeout is specified in seconds. If set to a number <= 0 connect will timeout when uIP does (which might be longer than you expect...). In EthernetENC it is set to 5 seconds.

UIP_PERIODIC_TIMER periodic timer for uip (in ms). In EthernetENC it is set to 100 milliseconds.

Arduino IDE doesn't have the possibility to set defines for a sketch (For example Sloeber has it). As some workaround to set the defines for different boards for Arduino IDE, you can create a file boards.local.txt next to boards.txt file in hardware package. Set build.extra_flags for individual boards. For example for Mega you can add to boards.local.txt this line with -D options to define the macros:

mega.build.extra_flags= -DUIP_CONF_MAX_CONNECTIONS=6 -DUIP_CONNECT_TIMEOUT=3

Clone this wiki locally