Hi Folks
I'm using an arduino nano and an ENC28J60 with the following sketch that receives data and sends it back out to the dmx pin using the dmxsimple library, I am however struggling to get ANY data out and guess I'm doing something wrong in the conversion somewhere, the data coming in is UDP packets
#include "etherShield.h"
#include "ETHER_28J60.h"
#include <DmxSimple.h>
#define bytes_to_short(h,l) ( ((h << 8) & 0xff00) | (l & 0x00FF) );
int StartUniv = 0;
short incoming_universe=0; //leave as is (if suspect uni number issues, try changing first_uni number above first.
static uint8_t mac[6] = { 0xBE, 0xEF, 0x00, 0x00, 0x00, 0x00 }; // this just needs to be unique for your network,
static uint8_t ip[4] = {192, 168, 1, 15}; // IP address for the webserver
static uint16_t port = 6454; // ART NET udp port
byte channel[768]; // The number of channels to store data for
ETHER_28J60 e;
// The setup loop, executed only once before the main loop
void setup() {
Serial.begin(9600);
DmxSimple.usePin(2);
DmxSimple.maxChannel(512);
e.setup(mac,ip , port);
Serial.print("I'm Alive");
}
void loop() {
char* EthernetData;
if (channel = e.serviceRequest())
{
incoming_universe=bytes_to_short(EthernetData[15],EthernetData[14]);
if (incoming_universe == StartUniv)
{
for(int i=0;i< 513;i++)
{
DmxSimple.write(i, byte(EthernetData[i + 17]));
}
}
}
}