Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed DMX TextLCD mbed-rtos
ArtNet.h@23:2ed8390eaf32, 2016-03-14 (annotated)
- Committer:
- Ayrton_L
- Date:
- Mon Mar 14 22:25:31 2016 +0000
- Revision:
- 23:2ed8390eaf32
- Parent:
- 22:b4af2cbd3148
- Child:
- 27:1bd34c90e0a9
DMX completed; Art-Net receive uni
Who changed what in which revision?
User | Revision | Line number | New 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 | 23:2ed8390eaf32 | 28 | uint8_t I8_Values[512] = {0}; |
Ayrton_L | 15:b0efafcfbb03 | 29 | Endpoint Client; |
Ayrton_L | 22:b4af2cbd3148 | 30 | char buffer[600]; |
Ayrton_L | 23:2ed8390eaf32 | 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 | 23:2ed8390eaf32 | 38 | string S_DataString(buffer); |
Ayrton_L | 23:2ed8390eaf32 | 39 | if (S_DataString.find("Art-Net") != string::npos) |
Ayrton_L | 22:b4af2cbd3148 | 40 | { |
Ayrton_L | 23:2ed8390eaf32 | 41 | size_t pos = S_DataString.find("Art-Net")+ 8; |
Ayrton_L | 23:2ed8390eaf32 | 42 | string S_Data = S_DataString.substr(pos); |
Ayrton_L | 23:2ed8390eaf32 | 43 | uint32_t I32_Universe = S_Data[12] | S_Data[13] << 8; |
Ayrton_L | 23:2ed8390eaf32 | 44 | int i = 0; |
Ayrton_L | 23:2ed8390eaf32 | 45 | for ( i =0; i <512; i++) |
Ayrton_L | 22:b4af2cbd3148 | 46 | { |
Ayrton_L | 23:2ed8390eaf32 | 47 | I8_Values[i] = S_Data[i+17]; |
Ayrton_L | 22:b4af2cbd3148 | 48 | } |
Ayrton_L | 23:2ed8390eaf32 | 49 | } |
Ayrton_L | 16:3cc108681a53 | 50 | } |
Ayrton_L | 15:b0efafcfbb03 | 51 | |
Ayrton_L | 15:b0efafcfbb03 | 52 | } |
Ayrton_L | 15:b0efafcfbb03 | 53 | |
Ayrton_L | 15:b0efafcfbb03 | 54 | |
Ayrton_L | 15:b0efafcfbb03 | 55 | #endif |
Ayrton_L | 15:b0efafcfbb03 | 56 |