|
| 1 | +// SPDX-FileCopyrightText: 2013 W.A. van der Meeren <danny@illogic.nl> |
| 2 | +// |
| 3 | +// SPDX-License-Identifier: LGPL-3.0-or-later |
| 4 | +/* |
| 5 | + Rdm_Defines.h - DMX library for Arduino with RDM (Remote Device Management) support |
| 6 | + Copyright (c) 2013 W.A. van der Meeren <danny@illogic.nl>. All right reserved. |
| 7 | +
|
| 8 | + This library is free software; you can redistribute it and/or |
| 9 | + modify it under the terms of the GNU Lesser General Public |
| 10 | + License as published by the Free Software Foundation; either |
| 11 | + version 3 of the License, or (at your option) any later version. |
| 12 | +
|
| 13 | + This library is distributed in the hope that it will be useful, |
| 14 | + but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 16 | + Lesser General Public License for more details. |
| 17 | +
|
| 18 | + You should have received a copy of the GNU Lesser General Public |
| 19 | + License along with this library; if not, write to the Free Software |
| 20 | + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
| 21 | +*/ |
| 22 | + |
| 23 | + |
| 24 | +#ifndef RDM_DEFINES_H_ |
| 25 | +#define RDM_DEFINES_H_ |
| 26 | + |
| 27 | +#include "Rdm_Uid.h" |
| 28 | + |
| 29 | +#define RDM_MAX_DEVICELABEL_LENGTH 32 |
| 30 | + |
| 31 | +namespace rdm |
| 32 | +{ |
| 33 | + enum RdmCommandClass |
| 34 | + { |
| 35 | + DiscoveryCommand = 0x10, |
| 36 | + DiscoveryCommandResponse, |
| 37 | + GetCommand = 0x20, |
| 38 | + GetCommandResponse, |
| 39 | + SetCommand = 0x30, |
| 40 | + SetCommandResponse, |
| 41 | + }; |
| 42 | + |
| 43 | + enum RdmResponseTypes |
| 44 | + { |
| 45 | + ResponseTypeAck = 0x00, |
| 46 | + ResponseTypeAckTimer, |
| 47 | + ResponseTypeNackReason, |
| 48 | + ResponseTypeAckOverflow, // Additional response data available (see spec) |
| 49 | + }; |
| 50 | + |
| 51 | + enum RdmParameters |
| 52 | + { |
| 53 | + // Category - Network Management |
| 54 | + DiscUniqueBranch = 0x0001, // Required |
| 55 | + DiscMute = 0x0002, // Required |
| 56 | + DiscUnMute = 0x0003, // Required |
| 57 | + |
| 58 | + CommsStatus = 0x0015, // Get,Set |
| 59 | + |
| 60 | + // Category - Status Collection |
| 61 | + QueuedMessage = 0x0020, // Get [enum RdmStatusTypes] |
| 62 | + StatusMessages = 0x0030, // Get [enum RdmStatusTypes] |
| 63 | + StatusIdDescription = 0x0031, // Get |
| 64 | + ClearStatusId = 0x0032, // Set |
| 65 | + SubDeviceStatusReportThreshold = 0x0033, // Get, Set [enum RdmStatusTypes] |
| 66 | + |
| 67 | + // Category - RDM Information |
| 68 | + // ** Only required if supporting parameters |
| 69 | + // beyond the minimum required set |
| 70 | + SupportedParameters = 0x0005, // Get, **Required |
| 71 | + ParameterDescription = 0x0051, // Get, **Required |
| 72 | + |
| 73 | + // Category = Product Information |
| 74 | + DeviceInfo = 0x0060, // Get, Required |
| 75 | + ProductDetailIdList = 0x0070, // Get |
| 76 | + DeviceModelDescription = 0x0080, // Get |
| 77 | + ManufacturerLabel = 0x0081, // Get |
| 78 | + DeviceLabel = 0x0082, // Get, Set |
| 79 | + FactoryDefaults = 0x0009, // Get, Set ** |
| 80 | + SoftwareVersionLabel = 0x000c, // Get |
| 81 | + |
| 82 | + // Category - DMX512 Setup |
| 83 | + DmxPersonality = 0x00e0, // Get, Set |
| 84 | + DmxPersonalityDescription = 0x00e1, // Get |
| 85 | + DmxStartAddress = 0x00f0, // Get, Set ** Required if DMX device |
| 86 | + SlotInfo = 0x0120, // Get |
| 87 | + SlotDescription = 0x0121, // Get |
| 88 | + DefaultSlotValue = 0x0122, // Get |
| 89 | + |
| 90 | + // Category - Sensors |
| 91 | + // Category - Dimmer Settings |
| 92 | + // Category - Power/Lamp Settings |
| 93 | + // Category - Display Settings |
| 94 | + // Category - Configuration |
| 95 | + |
| 96 | + // Category - Control |
| 97 | + IdentifyDevice = 0x1000, // Get, Set, Required |
| 98 | + ResetDevice = 0x1001, // Set |
| 99 | + PowerState = 0x1010, // Get, Set |
| 100 | + PerformSelftest = 0x1020, // Get, Set |
| 101 | + SelfTestDescription = 0x1021, // Get |
| 102 | + }; |
| 103 | + |
| 104 | + |
| 105 | + enum RdmStatusTypes |
| 106 | + { |
| 107 | + StatusNone = 0x00, |
| 108 | + StatusGetLastMessage, |
| 109 | + StatusAdvisory, |
| 110 | + StatusWarning, |
| 111 | + StatusError, |
| 112 | + StatusAdvisoryCleared = 0x12, |
| 113 | + StatusWarningCleared, |
| 114 | + StatusErrorCleared, |
| 115 | + }; |
| 116 | + |
| 117 | + enum RdmProductCategory |
| 118 | + { |
| 119 | + CategoryNotDeclared = 0x0000, |
| 120 | + |
| 121 | + // Fixtures - intended as source for illumination |
| 122 | + CategoryFixture = 0x0100, |
| 123 | + CategoryFixtureFixed = 0x0101, |
| 124 | + CategoryFixtureMovingYoke = 0x0102, |
| 125 | + CategoryFixtureMovingMirror = 0x0103, |
| 126 | + CategoryFixtureOther = 0x01ff, |
| 127 | + |
| 128 | + // Fixture Accessories - add-ons to fixtures or projectors |
| 129 | + CategoryFixtureAccessory = 0x0200, |
| 130 | + CategoryFixtureAccessoryColor = 0x0201, |
| 131 | + CategoryFixtureAccessoryYoke = 0x0202, |
| 132 | + CategoryFixtureAccessoryMirror = 0x0203, |
| 133 | + CategoryFixtureAccessoryEffect = 0x0204, |
| 134 | + CategoryFixtureAccessoryBeam = 0x0205, |
| 135 | + CategoryFixtureAccessoryOther = 0x02ff, |
| 136 | + |
| 137 | + // Projectors - Light source capable of producing |
| 138 | + // realistic images from another media |
| 139 | + CategoryProjector = 0x0300, |
| 140 | + CategoryProjectorFixed = 0x0301, |
| 141 | + CategoryProjectorMovingYoke = 0x0302, |
| 142 | + CategoryProjectorMovingMirror = 0x0303, |
| 143 | + CategoryProjectorOther = 0x03ff, |
| 144 | + |
| 145 | + // Atmospheric Effect - earth/wind/fire |
| 146 | + CategoryAtmospheric = 0x0400, |
| 147 | + CategoryAtmosphericEffect = 0x0401, // Fogger, Hazer, Flame |
| 148 | + CategoryAtmosphericPyro = 0x0402, |
| 149 | + CategoryAtmosphericOther = 0x04ff, |
| 150 | + |
| 151 | + // Insensity Control (Specifically dimming equipment) |
| 152 | + CategoryDimmer = 0x0500, |
| 153 | + CategoryDimmer_AC_Incandescent = 0x0501, |
| 154 | + CategoryDimmer_AC_Fluorescent = 0x0502, |
| 155 | + CategoryDimmer_AC_Coldcathode = 0x0503, |
| 156 | + CategoryDimmer_AC_Nondim = 0x0504, |
| 157 | + CategoryDimmer_AC_Elv = 0x0505, |
| 158 | + CategoryDimmer_AC_Other = 0x0506, |
| 159 | + CategoryDimmer_DC_Level = 0x0507, |
| 160 | + CategoryDimmer_DC_PWM = 0x0508, |
| 161 | + CategoryDimmer_CS_LED = 0x0509, |
| 162 | + CategoryDimmer_Other = 0x05ff, |
| 163 | + |
| 164 | + // Power control (Other than dimming equipment) |
| 165 | + CategoryPower = 0x0600, |
| 166 | + CategoryPowerControl = 0x0601, |
| 167 | + CategoryPowerSource = 0x0602, |
| 168 | + CategoryPowerOther = 0x06ff, |
| 169 | + |
| 170 | + // Scenic Drive - Including motorized effects |
| 171 | + // unrelated to light source |
| 172 | + CategoryScenic = 0x0700, |
| 173 | + CategoryScenicDrive = 0x0701, |
| 174 | + CategoryScenicOther = 0x07ff, |
| 175 | + |
| 176 | + // DMX Infrastructure, conversion and interfaces |
| 177 | + CategoryData = 0x0800, |
| 178 | + CategoryDataDistribution = 0x0801, |
| 179 | + CategoryDataConversion = 0x0802, |
| 180 | + CategoryDataOther = 0x08ff, |
| 181 | + |
| 182 | + // Audio visual equipment |
| 183 | + Category_AV = 0x0900, |
| 184 | + Category_AV_Audio = 0x0901, |
| 185 | + Category_AV_Video = 0x0902, |
| 186 | + Category_AV_Other = 0x09ff, |
| 187 | + |
| 188 | + // Parameter monitoring equipment |
| 189 | + CategoryMonitor = 0x0a00, |
| 190 | + CategoryMonitorACLinePower = 0x0a01, |
| 191 | + CategoryMonitorDCPower = 0x0a02, |
| 192 | + CategoryMonitorEnvironmental = 0x0a03, |
| 193 | + CategoryMonitorOther = 0x0aff, |
| 194 | + |
| 195 | + // Controllers, backup devices |
| 196 | + CategoryControl = 0x7000, |
| 197 | + CategoryControlController = 0x7001, |
| 198 | + CategoryControlBackupdevice = 0x7002, |
| 199 | + CategoryControlOther = 0x70ff, |
| 200 | + |
| 201 | + // Test equipment |
| 202 | + CategoryTest = 0x7100, |
| 203 | + CategoryTestEquipment = 0x7101, |
| 204 | + CategoryTestEquipmentOther = 0x71ff, |
| 205 | + |
| 206 | + // Miscellaneous |
| 207 | + CategoryOther = 0x7fff, |
| 208 | + }; |
| 209 | + |
| 210 | + // |
| 211 | + // Product details not yet supported in |
| 212 | + // this library |
| 213 | + // |
| 214 | + enum RdmProductDetail |
| 215 | + { |
| 216 | + ProductDetailNotDeclared = 0x0000, |
| 217 | + }; |
| 218 | + |
| 219 | + // Only LSB |
| 220 | + enum RdmNackReasons |
| 221 | + { |
| 222 | + UnknownPid = 0x00, |
| 223 | + FormatError, |
| 224 | + HardwareFault, |
| 225 | + ProxyReject, |
| 226 | + WriteProtect, |
| 227 | + UnsupportedCmdClass, |
| 228 | + DataOutOfRange, |
| 229 | + BufferFull, |
| 230 | + PacketSizeUnsupported, |
| 231 | + SubDeviceOutOfRange, |
| 232 | + ProxyBufferFull |
| 233 | + }; |
| 234 | + |
| 235 | +}; |
| 236 | + |
| 237 | + |
| 238 | +#define RDM_HDR_LEN 24 // RDM Message header length ** fixed |
| 239 | +#define RDM_PD_MAXLEN 32 // RDM Maximum parameter data length 1 - 231 |
| 240 | + |
| 241 | + |
| 242 | +union RDM_Message |
| 243 | +{ |
| 244 | + uint8_t d[ RDM_HDR_LEN + RDM_PD_MAXLEN ]; |
| 245 | + struct |
| 246 | + { |
| 247 | + uint8_t startCode; // 0 SC_RDM |
| 248 | + uint8_t subStartCode; // 1 SC_SUB_MESSAGE |
| 249 | + uint8_t msgLength; // 2 Range 24 - 255 |
| 250 | + RDM_Uid dstUid; // 3-8 Destination UID |
| 251 | + RDM_Uid srcUid; // 9-14 Source UID (sender) |
| 252 | + uint8_t TN; // 15 Transaction number |
| 253 | + uint8_t portId; // 16 Port ID / Response type |
| 254 | + uint8_t msgCount; // 17 |
| 255 | + uint16_t subDevice; // 18,19 0=root, 0xffff=all |
| 256 | + uint8_t CC; // 20 GET_COMMAND |
| 257 | + uint16_t PID; // 21,22 Parameter ID |
| 258 | + uint8_t PDL; // 23 Parameter Data length 1-231 |
| 259 | + |
| 260 | + uint8_t PD[RDM_PD_MAXLEN]; // Parameter Data ... variable length |
| 261 | + }; |
| 262 | +}; |
| 263 | + |
| 264 | +union RDM_Checksum |
| 265 | +{ |
| 266 | + uint16_t checksum; |
| 267 | + struct |
| 268 | + { |
| 269 | + uint8_t csl; |
| 270 | + uint8_t csh; |
| 271 | + }; |
| 272 | +}; |
| 273 | + |
| 274 | +struct RDM_DiscUniqueBranchPD |
| 275 | +{ |
| 276 | + RDM_Uid lbound; |
| 277 | + RDM_Uid hbound; |
| 278 | +}; |
| 279 | + |
| 280 | +struct RDM_DiscMuteUnMutePD |
| 281 | +{ |
| 282 | + uint16_t ctrlField; |
| 283 | + |
| 284 | +// Only for multiple ports |
| 285 | +// RDM_Uid bindingUid; |
| 286 | +}; |
| 287 | + |
| 288 | +struct RDM__DeviceInfoPD |
| 289 | +{ |
| 290 | + uint8_t protocolVersionMajor; |
| 291 | + uint8_t protocolVersionMinor; |
| 292 | + uint16_t deviceModelId; |
| 293 | + uint16_t ProductCategory; // enum RdmProductCategory |
| 294 | + uint8_t SoftwareVersionId[4]; |
| 295 | + uint16_t DMX512FootPrint; |
| 296 | + uint8_t DMX512CurrentPersonality; |
| 297 | + uint8_t DMX512NumberPersonalities; |
| 298 | + uint16_t DMX512StartAddress; |
| 299 | + uint16_t SubDeviceCount; |
| 300 | + uint8_t SensorCount; |
| 301 | +}; |
| 302 | + |
| 303 | +struct RDM_DeviceGetPersonality_PD |
| 304 | +{ |
| 305 | + uint8_t DMX512CurrentPersonality; |
| 306 | + uint8_t DMX512NumberPersonalities; |
| 307 | +}; |
| 308 | + |
| 309 | +struct RDM_DeviceSetPersonality_PD |
| 310 | +{ |
| 311 | + uint8_t DMX512Personality; |
| 312 | +}; |
| 313 | + |
| 314 | + |
| 315 | +#endif /* RDM_DEFINES_H_ */ |
0 commit comments