Open Lighting Architecture
 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"
26 #include "ola/network/IPV4Address.h"
27 #include "ola/network/Interface.h"
28 
29 
30 #ifndef ARTNET_PORT_COUNT
31 #define ARTNET_PORT_COUNT 4
32 #endif
33 
34 namespace ola {
35 namespace plugin {
36 namespace artnet {
37 
38 // various length enums
39 enum { ARTNET_LONG_NAME_LENGTH = 64 };
40 enum { ARTNET_MAX_PORTS = ARTNET_PORT_COUNT };
41 enum { ARTNET_MAX_RDM_ADDRESS_COUNT = 32 };
42 // According to the rdm spec, this should be 256 bytes
43 // We'll set to 512 here just to be safe
44 enum { ARTNET_MAX_RDM_DATA = 512 };
45 enum { ARTNET_MAX_UID_COUNT = 200 };
46 enum { ARTNET_REPORT_LENGTH = 64 };
47 enum { ARTNET_SHORT_NAME_LENGTH = 18 };
48 
49 
50 /*
51  * The subset of packets we're interested in
52  */
53 typedef enum artnet_packet_type_e {
54  ARTNET_POLL = 0x2000,
55  ARTNET_REPLY = 0x2100,
56  ARTNET_DMX = 0x5000,
57  ARTNET_TODREQUEST = 0x8000,
58  ARTNET_TODDATA = 0x8100,
59  ARTNET_TODCONTROL = 0x8200,
60  ARTNET_RDM = 0x8300,
61  ARTNET_RDM_SUB = 0x8400,
62  ARTNET_TIME_CODE = 0x9700,
63  ARTNET_IP_PROGRAM = 0xf800,
64  ARTNET_IP_PROGRAM_REPLY = 0xf900,
65 } artnet_packet_type;
66 
67 
68 struct artnet_poll_s {
69  uint16_t version;
70  uint8_t talk_to_me;
71  uint8_t priority;
72 } __attribute__((packed));
73 
74 typedef struct artnet_poll_s artnet_poll_t;
75 
77  uint8_t ip[ola::network::IPV4Address::LENGTH];
78  uint16_t port;
79  uint16_t version;
80  uint8_t net_address;
81  uint8_t subnet_address;
82  uint16_t oem;
83  uint8_t ubea;
84  uint8_t status1;
85  uint16_t esta_id;
86  char short_name[ARTNET_SHORT_NAME_LENGTH];
87  char long_name[ARTNET_LONG_NAME_LENGTH];
88  char node_report[ARTNET_REPORT_LENGTH];
89  uint8_t number_ports[2];
90  uint8_t port_types[ARTNET_MAX_PORTS];
91  uint8_t good_input[ARTNET_MAX_PORTS];
92  uint8_t good_output[ARTNET_MAX_PORTS];
93  uint8_t sw_in[ARTNET_MAX_PORTS];
94  uint8_t sw_out[ARTNET_MAX_PORTS];
95  uint8_t sw_video;
96  uint8_t sw_macro;
97  uint8_t sw_remote;
98  uint8_t spare1;
99  uint8_t spare2;
100  uint8_t spare3;
101  uint8_t style;
102  uint8_t mac[ola::network::MAC_LENGTH];
103  uint8_t bind_ip[ola::network::IPV4Address::LENGTH];
104  uint8_t bind_index;
105  uint8_t status2;
106  uint8_t filler[26];
107 } __attribute__((packed));
108 
109 typedef struct artnet_reply_s artnet_reply_t;
110 
111 
113  uint16_t version;
114  uint8_t filler;
115  uint8_t filler2;
116  uint8_t frames;
117  uint8_t seconds;
118  uint8_t minutes;
119  uint8_t hours;
120  uint8_t type;
121 } __attribute__((packed));
122 
123 typedef struct artnet_timecode_s artnet_timecode_t;
124 
125 struct artnet_dmx_s {
126  uint16_t version;
127  uint8_t sequence;
128  uint8_t physical;
129  uint8_t universe;
130  uint8_t net;
131  uint8_t length[2];
132  uint8_t data[DMX_UNIVERSE_SIZE];
133 } __attribute__((packed));
134 
135 typedef struct artnet_dmx_s artnet_dmx_t;
136 
137 
139  uint16_t version;
140  uint8_t filler1;
141  uint8_t filler2;
142  uint8_t spare1;
143  uint8_t spare2;
144  uint8_t spare3;
145  uint8_t spare4;
146  uint8_t spare5;
147  uint8_t spare6;
148  uint8_t spare7;
149  uint8_t net;
150  uint8_t command;
151  uint8_t address_count;
152  uint8_t addresses[ARTNET_MAX_RDM_ADDRESS_COUNT];
153 } __attribute__((packed));
154 
156 
157 
159  uint16_t version;
160  uint8_t rdm_version;
161  uint8_t port;
162  uint8_t spare1;
163  uint8_t spare2;
164  uint8_t spare3;
165  uint8_t spare4;
166  uint8_t spare5;
167  uint8_t spare6;
168  uint8_t spare7;
169  uint8_t net;
170  uint8_t command_response;
171  uint8_t address;
172  uint16_t uid_total;
173  uint8_t block_count;
174  uint8_t uid_count;
175  uint8_t tod[ARTNET_MAX_UID_COUNT][ola::rdm::UID::UID_SIZE];
176 } __attribute__((packed));
177 
178 typedef struct artnet_toddata_s artnet_toddata_t;
179 
181  uint16_t version;
182  uint8_t filler1;
183  uint8_t filler2;
184  uint8_t spare1;
185  uint8_t spare2;
186  uint8_t spare3;
187  uint8_t spare4;
188  uint8_t spare5;
189  uint8_t spare6;
190  uint8_t spare7;
191  uint8_t net;
192  uint8_t command;
193  uint8_t address;
194 } __attribute__((packed));
195 
197 
198 struct artnet_rdm_s {
199  uint16_t version;
200  uint8_t rdm_version;
201  uint8_t filler2;
202  uint8_t spare1;
203  uint8_t spare2;
204  uint8_t spare3;
205  uint8_t spare4;
206  uint8_t spare5;
207  uint8_t spare6;
208  uint8_t spare7;
209  uint8_t net;
210  uint8_t command;
211  uint8_t address;
212  uint8_t data[ARTNET_MAX_RDM_DATA];
213 } __attribute__((packed));
214 
215 typedef struct artnet_rdm_s artnet_rdm_t;
216 
218  uint16_t version;
219  uint16_t filler;
220  uint8_t command;
221  uint8_t filler1;
222  uint8_t ip[ola::network::IPV4Address::LENGTH];
223  uint8_t subnet[ola::network::IPV4Address::LENGTH];
224  uint16_t port;
225  uint8_t spare[8];
226 } __attribute__((packed));
227 
228 typedef struct artnet_ip_prog_s artnet_ip_prog_t;
229 
231  uint16_t version;
232  uint16_t filler;
233  uint8_t command;
234  uint8_t filler1;
235  uint8_t ip[ola::network::IPV4Address::LENGTH];
236  uint8_t subnet[ola::network::IPV4Address::LENGTH];
237  uint16_t port;
238  uint8_t spare[8];
239 } __attribute__((packed));
240 
241 typedef struct artnet_ip_reply_s artnet_ip_reply_t;
242 
243 // union of all artnet packets
244 typedef struct {
245  uint8_t id[8];
246  uint16_t op_code;
247  union {
248  artnet_poll_t poll;
249  artnet_reply_t reply;
250  artnet_timecode_t timecode;
251  artnet_dmx_t dmx;
252  artnet_todrequest_t tod_request;
253  artnet_toddata_t tod_data;
254  artnet_todcontrol_t tod_control;
255  artnet_rdm_t rdm;
256  artnet_ip_prog_t ip_program;
257  artnet_ip_reply_t ip_reply;
258  } data;
259 } artnet_packet;
260 } // namespace artnet
261 } // namespace plugin
262 } // namespace ola
263 #endif // PLUGINS_ARTNET_ARTNETPACKETS_H_