Open Lighting Architecture  0.9.5
 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
15  *
16  * ArtNetPackets.h
17  * Datagram definitions for ArtNet
18  * Copyright (C) 2004 Simon Newton
19  */
20 
21 #ifndef PLUGINS_ARTNET_ARTNETPACKETS_H_
22 #define PLUGINS_ARTNET_ARTNETPACKETS_H_
23 
24 #include "ola/Constants.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 PACK(
69 struct artnet_poll_s {
70  uint16_t version;
71  uint8_t talk_to_me;
72  uint8_t priority;
73 });
74 
75 typedef struct artnet_poll_s artnet_poll_t;
76 
77 PACK(
78 struct artnet_reply_s {
79  uint8_t ip[ola::network::IPV4Address::LENGTH];
80  uint16_t port;
81  uint16_t version;
82  uint8_t net_address;
83  uint8_t subnet_address;
84  uint16_t oem;
85  uint8_t ubea;
86  uint8_t status1;
87  uint16_t esta_id;
88  char short_name[ARTNET_SHORT_NAME_LENGTH];
89  char long_name[ARTNET_LONG_NAME_LENGTH];
90  char node_report[ARTNET_REPORT_LENGTH];
91  uint8_t number_ports[2];
92  uint8_t port_types[ARTNET_MAX_PORTS];
93  uint8_t good_input[ARTNET_MAX_PORTS];
94  uint8_t good_output[ARTNET_MAX_PORTS];
95  uint8_t sw_in[ARTNET_MAX_PORTS];
96  uint8_t sw_out[ARTNET_MAX_PORTS];
97  uint8_t sw_video;
98  uint8_t sw_macro;
99  uint8_t sw_remote;
100  uint8_t spare1;
101  uint8_t spare2;
102  uint8_t spare3;
103  uint8_t style;
104  uint8_t mac[ola::network::MACAddress::LENGTH];
105  uint8_t bind_ip[ola::network::IPV4Address::LENGTH];
106  uint8_t bind_index;
107  uint8_t status2;
108  uint8_t filler[26];
109 });
110 
111 typedef struct artnet_reply_s artnet_reply_t;
112 
113 PACK(
114 struct artnet_timecode_s {
115  uint16_t version;
116  uint8_t filler;
117  uint8_t filler2;
118  uint8_t frames;
119  uint8_t seconds;
120  uint8_t minutes;
121  uint8_t hours;
122  uint8_t type;
123 });
124 
125 typedef struct artnet_timecode_s artnet_timecode_t;
126 
127 PACK(
128 struct artnet_dmx_s {
129  uint16_t version;
130  uint8_t sequence;
131  uint8_t physical;
132  uint8_t universe;
133  uint8_t net;
134  uint8_t length[2];
135  uint8_t data[DMX_UNIVERSE_SIZE];
136 });
137 
138 typedef struct artnet_dmx_s artnet_dmx_t;
139 
140 PACK(
141 struct artnet_todrequest_s {
142  uint16_t version;
143  uint8_t filler1;
144  uint8_t filler2;
145  uint8_t spare1;
146  uint8_t spare2;
147  uint8_t spare3;
148  uint8_t spare4;
149  uint8_t spare5;
150  uint8_t spare6;
151  uint8_t spare7;
152  uint8_t net;
153  uint8_t command;
154  uint8_t address_count;
155  uint8_t addresses[ARTNET_MAX_RDM_ADDRESS_COUNT];
156 });
157 
158 typedef struct artnet_todrequest_s artnet_todrequest_t;
159 
160 PACK(
161 struct artnet_toddata_s {
162  uint16_t version;
163  uint8_t rdm_version;
164  uint8_t port;
165  uint8_t spare1;
166  uint8_t spare2;
167  uint8_t spare3;
168  uint8_t spare4;
169  uint8_t spare5;
170  uint8_t spare6;
171  uint8_t spare7;
172  uint8_t net;
173  uint8_t command_response;
174  uint8_t address;
175  uint16_t uid_total;
176  uint8_t block_count;
177  uint8_t uid_count;
178  uint8_t tod[ARTNET_MAX_UID_COUNT][ola::rdm::UID::UID_SIZE];
179 });
180 
181 typedef struct artnet_toddata_s artnet_toddata_t;
182 
183 PACK(
184 struct artnet_todcontrol_s {
185  uint16_t version;
186  uint8_t filler1;
187  uint8_t filler2;
188  uint8_t spare1;
189  uint8_t spare2;
190  uint8_t spare3;
191  uint8_t spare4;
192  uint8_t spare5;
193  uint8_t spare6;
194  uint8_t spare7;
195  uint8_t net;
196  uint8_t command;
197  uint8_t address;
198 });
199 
200 typedef struct artnet_todcontrol_s artnet_todcontrol_t;
201 
202 PACK(
203 struct artnet_rdm_s {
204  uint16_t version;
205  uint8_t rdm_version;
206  uint8_t filler2;
207  uint8_t spare1;
208  uint8_t spare2;
209  uint8_t spare3;
210  uint8_t spare4;
211  uint8_t spare5;
212  uint8_t spare6;
213  uint8_t spare7;
214  uint8_t net;
215  uint8_t command;
216  uint8_t address;
217  uint8_t data[ARTNET_MAX_RDM_DATA];
218 });
219 
220 typedef struct artnet_rdm_s artnet_rdm_t;
221 
222 PACK(
223 struct artnet_ip_prog_s {
224  uint16_t version;
225  uint16_t filler;
226  uint8_t command;
227  uint8_t filler1;
228  uint8_t ip[ola::network::IPV4Address::LENGTH];
229  uint8_t subnet[ola::network::IPV4Address::LENGTH];
230  uint16_t port;
231  uint8_t spare[8];
232 });
233 
234 typedef struct artnet_ip_prog_s artnet_ip_prog_t;
235 
236 PACK(
237 struct artnet_ip_reply_s {
238  uint16_t version;
239  uint16_t filler;
240  uint8_t command;
241  uint8_t filler1;
242  uint8_t ip[ola::network::IPV4Address::LENGTH];
243  uint8_t subnet[ola::network::IPV4Address::LENGTH];
244  uint16_t port;
245  uint8_t spare[8];
246 });
247 
248 typedef struct artnet_ip_reply_s artnet_ip_reply_t;
249 
250 // union of all artnet packets
251 typedef struct {
252  uint8_t id[8];
253  uint16_t op_code;
254  union {
255  artnet_poll_t poll;
256  artnet_reply_t reply;
257  artnet_timecode_t timecode;
258  artnet_dmx_t dmx;
259  artnet_todrequest_t tod_request;
260  artnet_toddata_t tod_data;
261  artnet_todcontrol_t tod_control;
262  artnet_rdm_t rdm;
263  artnet_ip_prog_t ip_program;
264  artnet_ip_reply_t ip_reply;
265  } data;
266 } artnet_packet;
267 } // namespace artnet
268 } // namespace plugin
269 } // namespace ola
270 #endif // PLUGINS_ARTNET_ARTNETPACKETS_H_