Open Lighting Architecture  0.9.2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ShowNetPackets.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  * ShowNetPackets.h
17  * Datagram definitions for the ShowNet protocol.
18  * Copyright (C) 2005 Simon Newton
19  */
20 
21 #ifndef PLUGINS_SHOWNET_SHOWNETPACKETS_H_
22 #define PLUGINS_SHOWNET_SHOWNETPACKETS_H_
23 
29 #include "ola/BaseTypes.h"
30 
31 namespace ola {
32 namespace plugin {
33 namespace shownet {
34 
35 enum { SHOWNET_MAC_LENGTH = 6 };
36 enum { SHOWNET_NAME_LENGTH = 9 };
37 enum { SHOWNET_SPARE_LENGTH = 22 };
38 
39 // Assume this is 512.
40 enum { SHOWNET_DMX_DATA_LENGTH = 512 };
41 
42 enum { SHOWNET_COMPRESSED_DATA_LENGTH = 1269 };
43 
44 enum ShowNetPacketType {
45  DMX_PACKET = 0x202f,
46  COMPRESSED_DMX_PACKET = 0x808f,
47 };
48 
49 // The old style Shownet DMX packet. Type 0x202f . Apparently this isn't used
50 // much.
51 PACK(
52 struct shownet_dmx_s {
53  uint16_t port;
54  uint16_t slot_length;
55  uint16_t pool_size;
56  uint16_t h_slot;
57  uint32_t sequence;
58  uint8_t priority; // 0 = not used
59  uint8_t universe; // 0 = not used
60  uint16_t spare[SHOWNET_SPARE_LENGTH];
61  uint8_t dmx_data[SHOWNET_DMX_DATA_LENGTH];
62 });
63 
64 typedef struct shownet_dmx_s shownet_dmx;
65 
66 // The 'new' style, compressed shownet packet. Type 0x808f
67 // Each packet can contain up to 4 'blocks' of DMX data.
68 PACK(
69 struct shownet_compressed_dmx_s {
70  uint16_t netSlot[4]; // start channel of each slot (hSlot)
71  uint16_t slotSize[4]; // size of each slot
72  uint16_t indexBlock[5]; // index into data of each slot
73  uint16_t sequence; // not used in n21+ code.
74  uint8_t priority; // not used in n21+ code, 0 = not used
75  uint8_t universe; // not used in n21+ code, 0 = not used
76  uint8_t pass[2]; // something to do with the channels that have
77  // passwords. PasswordNumChans ?
78  char name[SHOWNET_NAME_LENGTH]; // name of console
79  uint8_t data[SHOWNET_COMPRESSED_DATA_LENGTH]; // RLE data.
80 });
81 
82 typedef struct shownet_compressed_dmx_s shownet_compressed_dmx;
83 
84 // The union of all packets.
85 typedef struct {
86  uint16_t type; // packet type
87  uint8_t ip[4]; // ip of sender
88  union {
89  shownet_dmx dmx;
90  shownet_compressed_dmx compressed_dmx;
91  } data;
93 
94 } // namespace shownet
95 } // namespace plugin
96 } // namespace ola
97 #endif // PLUGINS_SHOWNET_SHOWNETPACKETS_H_