Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 5 of 5

Thread: PJRC Ethernet Library + wiz850io

  1. #1
    Member dimitre's Avatar
    Join Date
    Aug 2016
    Location
    São Paulo
    Posts
    75

    PJRC Ethernet Library + wiz850io

    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);
        }
      }
    }

  2. #2
    Senior Member+ manitou's Avatar
    Join Date
    Jan 2013
    Posts
    2,300
    Ethernet.h in the Ethernet lib is configured for a max of 4 sockets. With some work, you can change that to 8, though it affects buffer sizes on the wiznet chip. I think 8 may be the max as defined by the wiznet API.

    Here is repository with a modified Ethernet lib (to use just 1 socket)
    https://github.com/alex-Arc/Ethernet/tree/1-socket
    discussed at https://forum.pjrc.com/threads/28975...l=1#post109591

  3. #3
    Member dimitre's Avatar
    Join Date
    Aug 2016
    Location
    São Paulo
    Posts
    75
    Thanks for the prompt answer @manitou. I'll definetly take a look in this option.

  4. #4
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    21,128
    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.

  5. #5
    Member dimitre's Avatar
    Join Date
    Aug 2016
    Location
    São Paulo
    Posts
    75
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •