Open Lighting Architecture  Latest Git
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 
30 #include "ola/Constants.h"
32 #include "ola/network/MACAddress.h"
33 
34 namespace ola {
35 namespace plugin {
36 namespace shownet {
37 
38 enum { SHOWNET_MAC_LENGTH = ola::network::MACAddress::LENGTH };
39 enum { SHOWNET_NAME_LENGTH = 9 };
40 enum { SHOWNET_SPARE_LENGTH = 22 };
41 
42 // Assume this is 512.
43 enum { SHOWNET_DMX_DATA_LENGTH = DMX_UNIVERSE_SIZE };
44 
45 enum { SHOWNET_COMPRESSED_DATA_LENGTH = 1269 };
46 
47 enum ShowNetPacketType {
48  DMX_PACKET = 0x202f,
49  COMPRESSED_DMX_PACKET = 0x808f,
50 };
51 
52 // The old style Shownet DMX packet. Type 0x202f . Apparently this isn't used
53 // much.
54 PACK(
55 struct shownet_dmx_s {
56  uint16_t port;
57  uint16_t slot_length;
58  uint16_t pool_size;
59  uint16_t h_slot;
60  uint32_t sequence;
61  uint8_t priority; // 0 = not used
62  uint8_t universe; // 0 = not used
63  uint16_t spare[SHOWNET_SPARE_LENGTH];
64  uint8_t dmx_data[SHOWNET_DMX_DATA_LENGTH];
65 });
66 
67 typedef struct shownet_dmx_s shownet_dmx;
68 
69 // The 'new' style, compressed shownet packet. Type 0x808f
70 // Each packet can contain up to 4 'blocks' of DMX data.
71 PACK(
72 struct shownet_compressed_dmx_s {
73  uint16_t netSlot[4]; // start channel of each slot (hSlot)
74  uint16_t slotSize[4]; // size of each slot
75  uint16_t indexBlock[5]; // index into data of each slot
76  uint16_t sequence; // not used in n21+ code.
77  uint8_t priority; // not used in n21+ code, 0 = not used
78  uint8_t universe; // not used in n21+ code, 0 = not used
79  uint8_t pass[2]; // something to do with the channels that have
80  // passwords. PasswordNumChans ?
81  char name[SHOWNET_NAME_LENGTH]; // name of console
82  uint8_t data[SHOWNET_COMPRESSED_DATA_LENGTH]; // RLE data.
83 });
84 
85 typedef struct shownet_compressed_dmx_s shownet_compressed_dmx;
86 
87 // The union of all packets.
88 typedef struct {
89  uint16_t type; // packet type
90  uint8_t ip[ola::network::IPV4Address::LENGTH]; // ip of sender
91  union {
92  shownet_dmx dmx;
93  shownet_compressed_dmx compressed_dmx;
94  } data;
96 
97 } // namespace shownet
98 } // namespace plugin
99 } // namespace ola
100 #endif // PLUGINS_SHOWNET_SHOWNETPACKETS_H_
#define PACK(__Declaration__)
Pack structures.
Definition: Macro.h:170
Constants used throughout OLA.
Definition: Constants.h:36
Represents an IPv4 Address.
The namespace containing all OLA symbols.
Definition: Credentials.cpp:44
Represents a MAC Address.
Definition: ShowNetPackets.h:88