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