ProDevelopTeam#MasterRace / Mbed 2 deprecated ArtnetDMX

Dependencies:   mbed DMX TextLCD mbed-rtos

Committer:
Ayrton_L
Date:
Mon Mar 14 12:19:50 2016 +0000
Revision:
22:b4af2cbd3148
Parent:
16:3cc108681a53
Child:
23:2ed8390eaf32
test

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Ayrton_L 15:b0efafcfbb03 1 #ifndef ARTNET_H
Ayrton_L 15:b0efafcfbb03 2 #define ARTNET_H
Ayrton_L 15:b0efafcfbb03 3
Ayrton_L 15:b0efafcfbb03 4 #include "mbed.h"
Ayrton_L 15:b0efafcfbb03 5 #include "EthernetInterface.h"
Ayrton_L 22:b4af2cbd3148 6 #include "string"
Ayrton_L 15:b0efafcfbb03 7
Ayrton_L 22:b4af2cbd3148 8 using namespace std;
Ayrton_L 22:b4af2cbd3148 9
Ayrton_L 22:b4af2cbd3148 10 #define ArtNetID "Art-Net"
Ayrton_L 22:b4af2cbd3148 11 #define ArtNetOPCode 0x5000
Ayrton_L 22:b4af2cbd3148 12 #define ArtNetPV 14
Ayrton_L 15:b0efafcfbb03 13 #define ArtNetPoort 6454
Ayrton_L 15:b0efafcfbb03 14
Ayrton_L 15:b0efafcfbb03 15 static const char* mbedIp = "2.0.0.100"; //IP
Ayrton_L 15:b0efafcfbb03 16 static const char* mbedMask = "255.0.0.0"; // Mask
Ayrton_L 15:b0efafcfbb03 17 static const char* mbedGateway = "2.0.0.1"; //Gateway
Ayrton_L 15:b0efafcfbb03 18
Ayrton_L 15:b0efafcfbb03 19 void V_ArtNet();
Ayrton_L 15:b0efafcfbb03 20
Ayrton_L 15:b0efafcfbb03 21 void V_ArtNet()
Ayrton_L 15:b0efafcfbb03 22 {
Ayrton_L 15:b0efafcfbb03 23 EthernetInterface eth;
Ayrton_L 15:b0efafcfbb03 24 eth.init(mbedIp, mbedMask, mbedGateway);
Ayrton_L 15:b0efafcfbb03 25 eth.connect();
Ayrton_L 15:b0efafcfbb03 26 UDPSocket ArtNetSocket;
Ayrton_L 15:b0efafcfbb03 27 ArtNetSocket.bind(ArtNetPoort);
Ayrton_L 15:b0efafcfbb03 28
Ayrton_L 15:b0efafcfbb03 29 Endpoint Client;
Ayrton_L 22:b4af2cbd3148 30 char buffer[600];
Ayrton_L 22:b4af2cbd3148 31 uint8_t I8_Channels[512][3];
Ayrton_L 16:3cc108681a53 32
Ayrton_L 22:b4af2cbd3148 33 while (true)
Ayrton_L 22:b4af2cbd3148 34 {
Ayrton_L 16:3cc108681a53 35 int n = ArtNetSocket.receiveFrom(Client, buffer, sizeof(buffer));
Ayrton_L 16:3cc108681a53 36 buffer[n] = '\0';
Ayrton_L 22:b4af2cbd3148 37
Ayrton_L 22:b4af2cbd3148 38 uint32_t i;
Ayrton_L 22:b4af2cbd3148 39 bool B_ArtNet = true;
Ayrton_L 22:b4af2cbd3148 40 for(i = 0; i <8; i++)
Ayrton_L 22:b4af2cbd3148 41 {
Ayrton_L 22:b4af2cbd3148 42 if(buffer [i] != ArtNetID[i])
Ayrton_L 22:b4af2cbd3148 43 {
Ayrton_L 22:b4af2cbd3148 44 B_ArtNet = false;
Ayrton_L 22:b4af2cbd3148 45 }
Ayrton_L 22:b4af2cbd3148 46 }
Ayrton_L 22:b4af2cbd3148 47 if(B_ArtNet == true)
Ayrton_L 22:b4af2cbd3148 48 {
Ayrton_L 22:b4af2cbd3148 49
Ayrton_L 22:b4af2cbd3148 50 for(i = 0; i < 512; i++)
Ayrton_L 22:b4af2cbd3148 51 {
Ayrton_L 22:b4af2cbd3148 52 buffer[i + (n-512)];
Ayrton_L 22:b4af2cbd3148 53 }
Ayrton_L 22:b4af2cbd3148 54 }
Ayrton_L 22:b4af2cbd3148 55
Ayrton_L 16:3cc108681a53 56 }
Ayrton_L 15:b0efafcfbb03 57
Ayrton_L 15:b0efafcfbb03 58 }
Ayrton_L 15:b0efafcfbb03 59
Ayrton_L 15:b0efafcfbb03 60
Ayrton_L 15:b0efafcfbb03 61 #endif
Ayrton_L 15:b0efafcfbb03 62