Hi
i try to receive more than 1 art-net universe exactly i want to receive 3 universes.
but when i send more than 1 universe nothing happens.
please could anyone point me in to the right direction?
i am using this code
/*CE SCRIPT PERMET DE RECUPERER LE DMX DANS UNE TRAME ART-NET
ET DE L'APPLIQUER AUX SORTIES ARDUINO
PERMET DONC DE TRAVAILLER EN RJ45 OU EN WIFI
CE SCRIPT DECODE LA TRAME,
IL EST PLUS SUR QUE ART-NET RECEIVER RAW.PDE, QUI NE DECODE PAS
LES IDENTIFIANTS ET LES OPERATINGS CODES DU PROTOCOLE ART-NET
Fonctionne avec logiciel Arduino 22*/
////////////(c)Christoph Guillermet
////////////http://www.le-chat-noir-numerique.fr
////////////karistouf@yahoo.fr
#include <SPI.h> // needed for Arduino versions later than 0018
#include <Ethernet.h>
#include <Udp.h> // UDP library from: bjoern@cs.stanford.edu 12/30/2008
#define short_get_high_byte(x) ((HIGH_BYTE & x) >> 8)
#define short_get_low_byte(x) (LOW_BYTE & x)
#define bytes_to_short(h,l) ( ((h << 8) & 0xff00) | (l & 0x00FF) );
// ADRESSES MAC ET IP du shield ethernet
//l'adresse MAC de la carte réseau est collée dans un sticker au dos de la carte
//pour la traduire en décimale, utiliser: http://www.frankdevelopper.com/outils/convertisseur.php
byte mac[] = {
144, 162, 218, 00, 16, 96 };
byte ip[] = {
10,1,1,108 };
// the next two variables are set when a packet is received
byte remoteIp[4]; // holds received packet's originating IP
unsigned int remotePort; // holds received packet's originating port
//Paramètres art net
unsigned int localPort = 6454; // port UDP générique art-net=6454
const int nombre_de_circuits=512;
const int taille_chaine_artnet=8+17+nombre_de_circuits+1;
// buffers
const int MAX_BUFFER_UDP=1024;
char packetBuffer[MAX_BUFFER_UDP]; //buffer de stockage de la trame entrante
//Variables d'identification Art-Net
char ArtNetHead[8]="Art-Net";
char OpHbyteReceive=0;
char OpLbyteReceive=0;
short is_artnet_version_1=0;
short is_artnet_version_2=0;
short seq_artnet=0;
short artnet_physical=0;
short incoming_universe=0;
boolean is_opcode_is_dmx=0;
boolean is_opcode_is_artpoll=0;
boolean match_artnet=1;
short Opcode=0;
//buffer storage of the poll reply
char pollReply[] = {
'A', 'r', 't', '-', 'N', 'e', 't', 0x00,
0x00, 0x21,
10, 0, 0, 1,
0x36, 0x19,
0, 0,
0, 1, // subnet address
0x4, 0x31, // oem
0,
0xd2,
0x70, 0x7a, // esta
'L', 'E', 'D', '-', 'T', 'u', 'b', 'e', 's',
0,0, 0, 0, 0, 0, 0, 0, 0, // short name
'L', 'E', 'D', '-', 'T', 'u', 'b', 'e', 's', ' ',
'A', 'R','T', '-', 'N', 'e', 't', ' ', '2', ' ', 'D', 'M','1', '3', '4',
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // long name
'#', '0', '0', '0', '1', ' ', '[', '0', ']', ' ', 'O', 'L', 'A',
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, // node report
0, 3, // num ports
0xc0, 0xc0, 0xc0, 0xc0,
8, 8, 8, 8,
0x80, 0, 0, 0,
0x20, 0x20, 0x20, 0x20, // swin
0x23, 0x20, 0x20, 0x20, // swout
0, 0, 0, 0, 0, 0, 0, // video, macro, remote, spare, style
0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED, // mac address
0xa, 0x0, 0x0, 0x1,
0,
8,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0 // filler
};
int tubescount = 25;
//Pins for tubes data
int datapin = 5; // DI
int clockpin = 6; // CI
int latchpin = 7; // LI
void setup() {
// démarrage ethernet et serveur UDP
Ethernet.begin(mac,ip);
Udp.begin(localPort);
Serial.begin(115200);
pinMode(datapin, OUTPUT);
pinMode(latchpin, OUTPUT);
pinMode(clockpin, OUTPUT);
digitalWrite(latchpin, LOW);
}
void loop() {
int update = 0;
int packetSize = Udp.available();
if(packetSize==taille_chaine_artnet)//si un packet de la taille de la chaine art-net
{
Udp.readPacket(packetBuffer,MAX_BUFFER_UDP, remoteIp, remotePort);
//lecture de l'identifiant
match_artnet=1;//valeur de stockage
for (int i=0;i<7;i++)
{
if(char(packetBuffer[i])!=ArtNetHead[i])
{
match_artnet=0;
break;
}//si ce n'est pas correspondant au header Art-Net, on arrête
}
if (match_artnet==1)
{
for (int i=0;i<MAX_BUFFER_UDP;i++)
{
Serial.print(byte(packetBuffer[i]));
}
Serial.println("");
//version protocole utilisé
//is_artnet_version_1=packetBuffer[10];
//is_artnet_version_2=packetBuffer[11];
//séquence d'envoi des données
//seq_artnet=packetBuffer[12];//0
//émission de la trame venant du port physique dmx N°
//artnet_physical=packetBuffer[13];//
//operator code qui permet de savoir de quel type de message Art-Net il s'agit
Opcode=bytes_to_short(packetBuffer[9],packetBuffer[8]);
is_opcode_is_artpoll=0;
is_opcode_is_dmx=0;
if(Opcode==0x5000)//il s'agit d'une trame dmx
{
Serial.println("DMX-DATA");
is_opcode_is_dmx=1;
is_opcode_is_artpoll=0;
}
else if(Opcode==0x2000)//il s'agit d'un artpoll: un node art-net demande sur le réseau qui est présent
{
Serial.println("POLL");
is_opcode_is_artpoll=1;
is_opcode_is_dmx=0;
//ici il faudrait renvoyer une trame artpoll reply au node qui a lancé le art-poll
}
if (is_opcode_is_artpoll==1)
{
Serial.println("GOT POLL");
//Udp.sendPacket(pollReply, remoteIp, remotePort);
}
if (is_opcode_is_dmx==1)
{
//Extraction de l'univers DMX, si vous avez besoin de filtre
incoming_universe= bytes_to_short(packetBuffer[15],packetBuffer[14]);//extraction de l'univers
//report dans un buffer dmx de la trame reçue
if (incoming_universe==0) {
for(int i=0;i<510;i++)
{
if (byte(packetBuffer[i+17]) > 128) {
sendbit(1);
}
else {
sendbit(0);
}
}
Serial.println("OK (0)");
}
if (incoming_universe==1) {
for(int i=0;i<510;i++)
{
if (byte(packetBuffer[i+17]) > 128) {
sendbit(1);
}
else {
sendbit(0);
}
}
Serial.println("OK (1)");
}
if (incoming_universe==2) {
for(int i=0;i<180;i++)
{
if (byte(packetBuffer[i+17]) > 128) {
sendbit(1);
}
else {
sendbit(0);
}
}
sendlatch();
Serial.println("OK (2)");
}
}
}
}
}
// Functions for sending to tubes
void sendbit(int dataout) {
if (dataout == 1) {
digitalWrite(datapin, HIGH);
digitalWrite(clockpin,HIGH);
digitalWrite(datapin, LOW);
digitalWrite(clockpin,LOW);
}
else {
digitalWrite(datapin, LOW);
digitalWrite(clockpin,HIGH);
digitalWrite(clockpin,LOW);
}
}
void sendlatch() {
digitalWrite(latchpin,HIGH);
digitalWrite(latchpin,LOW);
}