Closed red4dj closed 11 months ago
That is, or a receiver able to monitor multiple universes. Thanks!
The short answer is no. There are many problems for doing it, language problems (different cpp standards), memory fails .... I understand that it will useful for receiving unicast. But every receiver/sender has it's own limited socket memory space.
Just found this library, and this is super useful! Plan to use it in a project moving forward but I have also run into the issue of wanting to be able to receive multiple universes. I'm using a Wiznet W5100 EVB Pico. Any thoughts about ways to receive multiple universes?
@DrewJSquared here a short example for two receivers this for a Raspberry Pico, maybe there a small issues, this code is extracted from a larger test code.
#include <Arduino.h>
#include <Ethernet.h>
#include "sACN3.h"
#define ETH_RST 20 // reset pin of W5500
#define ETH_CS 17 // CS pin, depends on microcontroller
uint8_t mac[] = {0x90, 0xA2, 0xDA, 0x10, 0x14, 0x48}; // MAC Adress of your device
IPAddress ip(10, 101, 1, 201); // IP Adress of your device
IPAddress dns(10, 101, 1, 100); // IP Adress of your device
IPAddress gateway(10, 101, 1, 100); // IP Adress of your device
IPAddress subnet(255, 255, 0, 0); // Subnet of your device
// UDP instances
EthernetUDP sacn1;
EthernetUDP sacn2;
// Receiver instances
Receiver recv1(sacn1, 1);
Receiver recv2(sacn2, 2);
//callbacks
void framerate1() {
Serial.print("Universe 1 DMX framerate ");
Serial.println(recv1.framerate());
}
void framerate2() {
Serial.print("Universe 2 DMX framerate ");
Serial.println(recv2.framerate());
}
void dmxReceived1() {
Serial.println("Universe 1 new DMX received ");
Serial.print("DMX 1: ");
Serial.print(recv1.dmx(1));
Serial.print(" DMX 2: ");
Serial.println(recv1.dmx(2));
}
void dmxReceived2() {
Serial.println("Universe 2 new DMX received ");
Serial.print("DMX 1: ");
Serial.print(recv2.dmx(1));
Serial.print(" DMX 2: ");
Serial.println(recv2.dmx(2));
}
void newSource1() {
Serial.print("Universe 1 new soure name: ");
Serial.println(recv1.name());
}
void newSource2() {
Serial.print("Universe 2 new soure name: ");
Serial.println(recv2.name());
}
void timeOut1() {
Serial.println("Universe 1 Timeout!");
}
void timeOut2() {
Serial.println("Universe 2 Timeout!");
}
// hard reset needed when no common reset with microcontroller
void hardreset(uint8_t pinRST) {
pinMode(pinRST, OUTPUT);
digitalWrite(pinRST, HIGH);
digitalWrite(pinRST, LOW);
delay(1);
digitalWrite(pinRST, HIGH);
delay(150);
}
void setup() {
Serial.begin(9600);
Ethernet.init(ETH_CS);
hardreset(ETH_RST);
Ethernet.begin(mac, ip, dns, gateway, subnet);
recv1.callbackDMX(dmxReceived1);
recv1.callbackSource(newSource1);
recv1.callbackTimeout(timeOut1);
recv1.callbackFramerate(framerate1);
recv1.begin();
recv2.callbackDMX(dmxReceived2);
recv2.callbackSource(newSource2);
recv2.callbackTimeout(timeOut2);
recv2.callbackFramerate(framerate2);
recv2.begin();
Serial.println("sACN start");
}
void loop() {
recv1.receive();
recv2.receive();
}
Be able to define multiple receivers in array for referencing.
Ex. (along these lines barring exact syntax)