PJRC Ethernet Library + wiz850io

Status
Not open for further replies.

dimitre

Well-known member
Hello, I'm working on a project and everything is running smoothly.
I've made an array of EthernetUDP and noticed the project always freeze when a certain number of EthernetUDP objects are created.

I'm using Teensy 3.2 and wiz850io, but I feel it can be reproduced in other systems.

here is the minimal code to reproduce. in my setup if you use up to 4 objects the sistem runs, if you use 5 it freeze

Code:
#include <SPI.h>
#include <Ethernet.h>
#include <EthernetUdp.h>

#define NUMBEROFPACKETS 5

byte mac[] = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x00 };
IPAddress ip(192, 168, 1, 201);
EthernetUDP Udps[NUMBEROFPACKETS];

void setup() {
  Ethernet.begin(mac, ip);
  Serial.begin(9600);
  for (int a = 0; a < NUMBEROFPACKETS; a++) {
    Udps[a].begin(4001 + a);
  }
}

void loop() {
  delay(500);
  Serial.println("alive");
  for (int a = 0; a < NUMBEROFPACKETS; a++) {
    if (Udps[a].parsePacket()) { //int n =
      byte packetBuffer[100]; //buffer to hold incoming & outgoing packets
      Udps[a].read(packetBuffer, 100);
    }
  }
}
 
Yup, only 4 sockets are supported.

Improving the ability to more easily configure 8 sockets, or fewer than 4 with larger buffers, is on my (very long) todo list.

Long-term, the default is probably going to remain 4 sockets with 4k buffers. Larger buffers help when you have network latency.

The hardware limit is 8 sockets.
 
Thanks! in fact in my application I dont' mind losing packets, I'll use a tiny TTL setting because I'm pushing pixels to LEDs.
I'll soon try this version of Ethernet library just to see if it works for my application.
https://github.com/sstaub/Ethernet3

Nice thing is actually I'm reading the Udp buffer directly inside the FastLED LEDS buffer, so I'm not even using memcpy anymore.
Each UDP port writes to a specific part of the buffer (one port for each 1464 bytes, or 488 leds) so this is why I'm looking for more ports.
I can loop through all UDP ports before updating leds.

This way I can handle 3904 pixels at a time.
My actual tests are running very fast, handling great 180 fps using 3 UDP ports.

If it doesn't work I'll try to use the first byte as a packet index, making teensy knowing in which position of the LED buffer it should write the UDP packet.

Ideas are welcome. Videos soon.
 
Status
Not open for further replies.
Back
Top