Hi, I found this fantastic arduino codes for receiveing e1.31
http://www.claudeheintzdesign.com/lx/lxarduino.html
Could someone guide me in right directions how to send e1.31 package from arduino? I would like to convert rs232 commands to e1.31
Many thanks
Transmit e1.31 from Arduino?
This a a fragment of code that should show you how to construct an sACN packet to send.
Code: Select all
#define DIMMERS_IN_UNIVERSE 512
#define SACN_MESSAGE_SIZE 638
void packInt16Big(unsigned char* c, int i) {
c[0] = ((i & 0xff00) >> 8);
c[1] = i & 0xff;
}
unsigned char _messageout[SACN_MESSAGE_SIZE]; //dmx buffer 512 + max Header = 638 for 1 universe
int acnPriority = 100;
int packetSequenceNumber = 0; //this should ++ 0-255 for each packet sent
int outsubnet = 0;
int outuniverse = 1;
int i;
for (i=0; i<126; i++) {
mbytes[i] = 0x00; //zero up until mbytes[125] the start code before dmx slots
}
//Root Layer
mbytes[1] = 0x10; //mbytes[0] & mbytes[1] are preamble size mbytes[0] is always 0 as set above
mbytes[4] = 'A'; //0x41;
mbytes[5] = 'S'; //0x53;
mbytes[6] = 'C'; //0x43;
mbytes[7] = '-'; //0x2d;
mbytes[8] = 'E'; //0x45;
mbytes[9] = '1'; //0x31;
mbytes[10] = '.'; //0x2e;
mbytes[11] = '1'; //0x31;
mbytes[12] = '7'; //0x37; //the pad 0's [13],[14],[15] are already set
int flagsPlusLength = 0x7000 + DIMMERS_IN_UNIVERSE + 110;
packInt16Big(&mbytes[16], flagsPlusLength);
mbytes[21] = 0x04; //vector18,19,20=0x00
mbytes[22] = 206; //16byte UUID should be guaranteed unique for each instance
mbytes[23] = 156;
mbytes[24] = 55;
mbytes[25] = 180;
mbytes[26] = 9;
mbytes[27] = 147;
mbytes[28] = 67;
mbytes[29] = 81;
mbytes[30] = 165;
mbytes[31] = 133;
mbytes[32] = 170;
mbytes[33] = 144;
mbytes[34] = 121;
mbytes[35] = 76;
mbytes[36] = 9;
mbytes[37] = 240;
//Framing Layer
flagsPlusLength = 0x7000 + DIMMERS_IN_UNIVERSE + 88;
packInt16Big(&mbytes[38], flagsPlusLength);
mbytes[43] = 0x02; //vector indicates framing wraps DMP
mbytes[44] = 'm';
mbytes[45] = 'y';
mbytes[46] = 'C';
mbytes[47] = 'o';
mbytes[48] = 'n';
mbytes[49] = 's';
mbytes[50] = 'o';
mbytes[51] = 'l';
mbytes[52] = 'e'; //null terminated, padded until [108]
mbytes[108] = acnPriority; //priority ([109],[110] reserved=0)
mbytes[111] = packetSequenceNumber;
mbytes[113] = outsubnet;
mbytes[114] = outuniverse;
//DMP Layer
flagsPlusLength = 0x7000 + DIMMERS_IN_UNIVERSE + 11;
packInt16Big(&mbytes[115], flagsPlusLength);
mbytes[117] = 0x02; //indicates a DMP Set Property message
mbytes[118] = 0xa1; //type of data
mbytes[122] = 0x01; //address increment
packInt16Big(&mbytes[123], DIMMERS_IN_UNIVERSE+1); //+1 for start code
mbytes[125] = 0x00; //start code
//DMX
mbytes[126] to mbytes[637] are the individual DMX values 1-512
UDP.write(mbytes, SACN_MESSAGE_SIZE);