Open Lighting Architecture  0.9.1
 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 struct shownet_dmx_s {
52  uint16_t port;
53  uint16_t slot_length;
54  uint16_t pool_size;
55  uint16_t h_slot;
56  uint32_t sequence;
57  uint8_t priority; // 0 = not used
58  uint8_t universe; // 0 = not used
59  uint16_t spare[SHOWNET_SPARE_LENGTH];
60  uint8_t dmx_data[SHOWNET_DMX_DATA_LENGTH];
61 } __attribute__((packed));
62 
63 typedef struct shownet_dmx_s shownet_dmx;
64 
65 // The 'new' style, compressed shownet packet. Type 0x808f
66 // Each packet can contain up to 4 'blocks' of DMX data.
68  uint16_t netSlot[4]; // start channel of each slot (hSlot)
69  uint16_t slotSize[4]; // size of each slot
70  uint16_t indexBlock[5]; // index into data of each slot
71  uint16_t sequence; // not used in n21+ code.
72  uint8_t priority; // not used in n21+ code, 0 = not used
73  uint8_t universe; // not used in n21+ code, 0 = not used
74  uint8_t pass[2]; // something to do with the channels that have
75  // passwords. PasswordNumChans ?
76  char name[SHOWNET_NAME_LENGTH]; // name of console
77  uint8_t data[SHOWNET_COMPRESSED_DATA_LENGTH]; // RLE data.
78 } __attribute__((packed));
79 
81 
82 // The union of all packets.
83 typedef struct {
84  uint16_t type; // packet type
85  uint8_t ip[4]; // ip of sender
86  union {
87  shownet_dmx dmx;
88  shownet_compressed_dmx compressed_dmx;
89  } data;
91 
92 } // namespace shownet
93 } // namespace plugin
94 } // namespace ola
95 #endif // PLUGINS_SHOWNET_SHOWNETPACKETS_H_