Open Lighting Architecture  0.9.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ArtNetPackets.h
1 /*
2  * This program is free software; you can redistribute it and/or modify
3  * it under the terms of the GNU General Public License as published by
4  * the Free Software Foundation; either version 2 of the License, or
5  * (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU Library General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software
14  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
15  *
16  * ArtNetPackets.h
17  * Datagram definitions for ArtNet
18  * Copyright (C) 2004-2010 Simon Newton
19  */
20 
21 #ifndef PLUGINS_ARTNET_ARTNETPACKETS_H_
22 #define PLUGINS_ARTNET_ARTNETPACKETS_H_
23 
24 #include "ola/BaseTypes.h"
25 #include "ola/rdm/UID.h"
27 #include "ola/network/MACAddress.h"
28 #include "ola/network/Interface.h"
29 
30 
31 #ifndef ARTNET_PORT_COUNT
32 #define ARTNET_PORT_COUNT 4
33 #endif
34 
35 namespace ola {
36 namespace plugin {
37 namespace artnet {
38 
39 // various length enums
40 enum { ARTNET_LONG_NAME_LENGTH = 64 };
41 enum { ARTNET_MAX_PORTS = ARTNET_PORT_COUNT };
42 enum { ARTNET_MAX_RDM_ADDRESS_COUNT = 32 };
43 // According to the rdm spec, this should be 256 bytes
44 // We'll set to 512 here just to be safe
45 enum { ARTNET_MAX_RDM_DATA = 512 };
46 enum { ARTNET_MAX_UID_COUNT = 200 };
47 enum { ARTNET_REPORT_LENGTH = 64 };
48 enum { ARTNET_SHORT_NAME_LENGTH = 18 };
49 
50 
51 /*
52  * The subset of packets we're interested in
53  */
54 typedef enum artnet_packet_type_e {
55  ARTNET_POLL = 0x2000,
56  ARTNET_REPLY = 0x2100,
57  ARTNET_DMX = 0x5000,
58  ARTNET_TODREQUEST = 0x8000,
59  ARTNET_TODDATA = 0x8100,
60  ARTNET_TODCONTROL = 0x8200,
61  ARTNET_RDM = 0x8300,
62  ARTNET_RDM_SUB = 0x8400,
63  ARTNET_TIME_CODE = 0x9700,
64  ARTNET_IP_PROGRAM = 0xf800,
65  ARTNET_IP_PROGRAM_REPLY = 0xf900,
66 } artnet_packet_type;
67 
68 
69 struct artnet_poll_s {
70  uint16_t version;
71  uint8_t talk_to_me;
72  uint8_t priority;
73 } __attribute__((packed));
74 
75 typedef struct artnet_poll_s artnet_poll_t;
76 
78  uint8_t ip[ola::network::IPV4Address::LENGTH];
79  uint16_t port;
80  uint16_t version;
81  uint8_t net_address;
82  uint8_t subnet_address;
83  uint16_t oem;
84  uint8_t ubea;
85  uint8_t status1;
86  uint16_t esta_id;
87  char short_name[ARTNET_SHORT_NAME_LENGTH];
88  char long_name[ARTNET_LONG_NAME_LENGTH];
89  char node_report[ARTNET_REPORT_LENGTH];
90  uint8_t number_ports[2];
91  uint8_t port_types[ARTNET_MAX_PORTS];
92  uint8_t good_input[ARTNET_MAX_PORTS];
93  uint8_t good_output[ARTNET_MAX_PORTS];
94  uint8_t sw_in[ARTNET_MAX_PORTS];
95  uint8_t sw_out[ARTNET_MAX_PORTS];
96  uint8_t sw_video;
97  uint8_t sw_macro;
98  uint8_t sw_remote;
99  uint8_t spare1;
100  uint8_t spare2;
101  uint8_t spare3;
102  uint8_t style;
103  uint8_t mac[ola::network::MACAddress::LENGTH];
104  uint8_t bind_ip[ola::network::IPV4Address::LENGTH];
105  uint8_t bind_index;
106  uint8_t status2;
107  uint8_t filler[26];
108 } __attribute__((packed));
109 
110 typedef struct artnet_reply_s artnet_reply_t;
111 
112 
114  uint16_t version;
115  uint8_t filler;
116  uint8_t filler2;
117  uint8_t frames;
118  uint8_t seconds;
119  uint8_t minutes;
120  uint8_t hours;
121  uint8_t type;
122 } __attribute__((packed));
123 
124 typedef struct artnet_timecode_s artnet_timecode_t;
125 
126 struct artnet_dmx_s {
127  uint16_t version;
128  uint8_t sequence;
129  uint8_t physical;
130  uint8_t universe;
131  uint8_t net;
132  uint8_t length[2];
133  uint8_t data[DMX_UNIVERSE_SIZE];
134 } __attribute__((packed));
135 
136 typedef struct artnet_dmx_s artnet_dmx_t;
137 
138 
140  uint16_t version;
141  uint8_t filler1;
142  uint8_t filler2;
143  uint8_t spare1;
144  uint8_t spare2;
145  uint8_t spare3;
146  uint8_t spare4;
147  uint8_t spare5;
148  uint8_t spare6;
149  uint8_t spare7;
150  uint8_t net;
151  uint8_t command;
152  uint8_t address_count;
153  uint8_t addresses[ARTNET_MAX_RDM_ADDRESS_COUNT];
154 } __attribute__((packed));
155 
157 
158 
160  uint16_t version;
161  uint8_t rdm_version;
162  uint8_t port;
163  uint8_t spare1;
164  uint8_t spare2;
165  uint8_t spare3;
166  uint8_t spare4;
167  uint8_t spare5;
168  uint8_t spare6;
169  uint8_t spare7;
170  uint8_t net;
171  uint8_t command_response;
172  uint8_t address;
173  uint16_t uid_total;
174  uint8_t block_count;
175  uint8_t uid_count;
176  uint8_t tod[ARTNET_MAX_UID_COUNT][ola::rdm::UID::UID_SIZE];
177 } __attribute__((packed));
178 
179 typedef struct artnet_toddata_s artnet_toddata_t;
180 
182  uint16_t version;
183  uint8_t filler1;
184  uint8_t filler2;
185  uint8_t spare1;
186  uint8_t spare2;
187  uint8_t spare3;
188  uint8_t spare4;
189  uint8_t spare5;
190  uint8_t spare6;
191  uint8_t spare7;
192  uint8_t net;
193  uint8_t command;
194  uint8_t address;
195 } __attribute__((packed));
196 
198 
199 struct artnet_rdm_s {
200  uint16_t version;
201  uint8_t rdm_version;
202  uint8_t filler2;
203  uint8_t spare1;
204  uint8_t spare2;
205  uint8_t spare3;
206  uint8_t spare4;
207  uint8_t spare5;
208  uint8_t spare6;
209  uint8_t spare7;
210  uint8_t net;
211  uint8_t command;
212  uint8_t address;
213  uint8_t data[ARTNET_MAX_RDM_DATA];
214 } __attribute__((packed));
215 
216 typedef struct artnet_rdm_s artnet_rdm_t;
217 
219  uint16_t version;
220  uint16_t filler;
221  uint8_t command;
222  uint8_t filler1;
223  uint8_t ip[ola::network::IPV4Address::LENGTH];
224  uint8_t subnet[ola::network::IPV4Address::LENGTH];
225  uint16_t port;
226  uint8_t spare[8];
227 } __attribute__((packed));
228 
229 typedef struct artnet_ip_prog_s artnet_ip_prog_t;
230 
232  uint16_t version;
233  uint16_t filler;
234  uint8_t command;
235  uint8_t filler1;
236  uint8_t ip[ola::network::IPV4Address::LENGTH];
237  uint8_t subnet[ola::network::IPV4Address::LENGTH];
238  uint16_t port;
239  uint8_t spare[8];
240 } __attribute__((packed));
241 
242 typedef struct artnet_ip_reply_s artnet_ip_reply_t;
243 
244 // union of all artnet packets
245 typedef struct {
246  uint8_t id[8];
247  uint16_t op_code;
248  union {
249  artnet_poll_t poll;
250  artnet_reply_t reply;
251  artnet_timecode_t timecode;
252  artnet_dmx_t dmx;
253  artnet_todrequest_t tod_request;
254  artnet_toddata_t tod_data;
255  artnet_todcontrol_t tod_control;
256  artnet_rdm_t rdm;
257  artnet_ip_prog_t ip_program;
258  artnet_ip_reply_t ip_reply;
259  } data;
260 } artnet_packet;
261 } // namespace artnet
262 } // namespace plugin
263 } // namespace ola
264 #endif // PLUGINS_ARTNET_ARTNETPACKETS_H_