Open Lighting Architecture  Latest Git
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 Art-Net
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 // ARTNET_PORT_COUNT
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_SYNC = 0x5200,
59  ARTNET_TODREQUEST = 0x8000,
60  ARTNET_TODDATA = 0x8100,
61  ARTNET_TODCONTROL = 0x8200,
62  ARTNET_RDM = 0x8300,
63  ARTNET_RDM_SUB = 0x8400,
64  ARTNET_TIME_CODE = 0x9700,
65  ARTNET_IP_PROGRAM = 0xf800,
66  ARTNET_IP_PROGRAM_REPLY = 0xf900,
67 } artnet_packet_type;
68 
69 PACK(
70 struct artnet_poll_s {
71  uint16_t version;
72  uint8_t talk_to_me;
73  uint8_t priority;
74 });
75 
76 typedef struct artnet_poll_s artnet_poll_t;
77 
78 PACK(
79 struct artnet_reply_s {
80  uint8_t ip[ola::network::IPV4Address::LENGTH];
81  uint16_t port;
82  uint16_t version;
83  uint8_t net_address;
84  uint8_t subnet_address;
85  uint16_t oem;
86  uint8_t ubea;
87  uint8_t status1;
88  uint16_t esta_id;
89  char short_name[ARTNET_SHORT_NAME_LENGTH];
90  char long_name[ARTNET_LONG_NAME_LENGTH];
91  char node_report[ARTNET_REPORT_LENGTH];
92  uint8_t number_ports[2];
93  uint8_t port_types[ARTNET_MAX_PORTS];
94  uint8_t good_input[ARTNET_MAX_PORTS];
95  uint8_t good_output[ARTNET_MAX_PORTS];
96  uint8_t sw_in[ARTNET_MAX_PORTS];
97  uint8_t sw_out[ARTNET_MAX_PORTS];
98  uint8_t sw_video;
99  uint8_t sw_macro;
100  uint8_t sw_remote;
101  uint8_t spare1;
102  uint8_t spare2;
103  uint8_t spare3;
104  uint8_t style;
105  uint8_t mac[ola::network::MACAddress::LENGTH];
106  uint8_t bind_ip[ola::network::IPV4Address::LENGTH];
107  uint8_t bind_index;
108  uint8_t status2;
109  uint8_t filler[26];
110 });
111 
112 typedef struct artnet_reply_s artnet_reply_t;
113 
114 PACK(
115 struct artnet_timecode_s {
116  uint16_t version;
117  uint8_t filler;
118  uint8_t filler2;
119  uint8_t frames;
120  uint8_t seconds;
121  uint8_t minutes;
122  uint8_t hours;
123  uint8_t type;
124 });
125 
126 typedef struct artnet_timecode_s artnet_timecode_t;
127 
128 PACK(
129 struct artnet_dmx_s {
130  uint16_t version;
131  uint8_t sequence;
132  uint8_t physical;
133  uint8_t universe;
134  uint8_t net;
135  uint8_t length[2];
136  uint8_t data[DMX_UNIVERSE_SIZE];
137 });
138 
139 typedef struct artnet_dmx_s artnet_dmx_t;
140 
141 PACK(
142 struct artnet_todrequest_s {
143  uint16_t version;
144  uint8_t filler1;
145  uint8_t filler2;
146  uint8_t spare1;
147  uint8_t spare2;
148  uint8_t spare3;
149  uint8_t spare4;
150  uint8_t spare5;
151  uint8_t spare6;
152  uint8_t spare7;
153  uint8_t net;
154  uint8_t command;
155  uint8_t address_count;
156  uint8_t addresses[ARTNET_MAX_RDM_ADDRESS_COUNT];
157 });
158 
159 typedef struct artnet_todrequest_s artnet_todrequest_t;
160 
161 PACK(
162 struct artnet_toddata_s {
163  uint16_t version;
164  uint8_t rdm_version;
165  uint8_t port;
166  uint8_t spare1;
167  uint8_t spare2;
168  uint8_t spare3;
169  uint8_t spare4;
170  uint8_t spare5;
171  uint8_t spare6;
172  uint8_t spare7;
173  uint8_t net;
174  uint8_t command_response;
175  uint8_t address;
176  uint16_t uid_total;
177  uint8_t block_count;
178  uint8_t uid_count;
179  uint8_t tod[ARTNET_MAX_UID_COUNT][ola::rdm::UID::UID_SIZE];
180 });
181 
182 typedef struct artnet_toddata_s artnet_toddata_t;
183 
184 PACK(
185 struct artnet_todcontrol_s {
186  uint16_t version;
187  uint8_t filler1;
188  uint8_t filler2;
189  uint8_t spare1;
190  uint8_t spare2;
191  uint8_t spare3;
192  uint8_t spare4;
193  uint8_t spare5;
194  uint8_t spare6;
195  uint8_t spare7;
196  uint8_t net;
197  uint8_t command;
198  uint8_t address;
199 });
200 
201 typedef struct artnet_todcontrol_s artnet_todcontrol_t;
202 
203 PACK(
204 struct artnet_rdm_s {
205  uint16_t version;
206  uint8_t rdm_version;
207  uint8_t filler2;
208  uint8_t spare1;
209  uint8_t spare2;
210  uint8_t spare3;
211  uint8_t spare4;
212  uint8_t spare5;
213  uint8_t spare6;
214  uint8_t spare7;
215  uint8_t net;
216  uint8_t command;
217  uint8_t address;
218  uint8_t data[ARTNET_MAX_RDM_DATA];
219 });
220 
221 typedef struct artnet_rdm_s artnet_rdm_t;
222 
223 PACK(
224 struct artnet_ip_prog_s {
225  uint16_t version;
226  uint16_t filler;
227  uint8_t command;
228  uint8_t filler1;
229  uint8_t ip[ola::network::IPV4Address::LENGTH];
230  uint8_t subnet[ola::network::IPV4Address::LENGTH];
231  uint16_t port;
232  uint8_t spare[8];
233 });
234 
235 typedef struct artnet_ip_prog_s artnet_ip_prog_t;
236 
237 PACK(
238 struct artnet_ip_reply_s {
239  uint16_t version;
240  uint16_t filler;
241  uint8_t command;
242  uint8_t filler1;
243  uint8_t ip[ola::network::IPV4Address::LENGTH];
244  uint8_t subnet[ola::network::IPV4Address::LENGTH];
245  uint16_t port;
246  uint8_t spare[8];
247 });
248 
249 typedef struct artnet_ip_reply_s artnet_ip_reply_t;
250 
251 // union of all Art-Net packets
252 typedef struct {
253  uint8_t id[8];
254  uint16_t op_code;
255  union {
256  artnet_poll_t poll;
257  artnet_reply_t reply;
258  artnet_timecode_t timecode;
259  artnet_dmx_t dmx;
260  artnet_todrequest_t tod_request;
261  artnet_toddata_t tod_data;
262  artnet_todcontrol_t tod_control;
263  artnet_rdm_t rdm;
264  artnet_ip_prog_t ip_program;
265  artnet_ip_reply_t ip_reply;
266  } data;
267 } artnet_packet;
268 } // namespace artnet
269 } // namespace plugin
270 } // namespace ola
271 #endif // PLUGINS_ARTNET_ARTNETPACKETS_H_
#define PACK(__Declaration__)
Pack structures.
Definition: Macro.h:170
A RDM unique identifier (UID).
Constants used throughout OLA.
Definition: ArtNetPackets.h:252
Definition: UID.h:293
Definition: Constants.h:36
Represents an IPv4 Address.
The namespace containing all OLA symbols.
Definition: Credentials.cpp:44
Represents a MAC Address.