• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

OpenLightingProject / ola / 16911433572

12 Aug 2025 02:08PM UTC coverage: 45.869% (-0.04%) from 45.909%
16911433572

Pull #1739

github

web-flow
Merge 02faeaa2d into 3566c28d9
Pull Request #1739: New web UI, store highest channel number used

7157 of 16316 branches covered (43.86%)

20915 of 45597 relevant lines covered (45.87%)

52.03 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

87.5
/plugins/artnet/ArtNetPlugin.cpp
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
 * ArtNetPlugin.cpp
17
 * The ArtNet plugin for ola
18
 * Copyright (C) 2005 Simon Newton
19
 */
20

21
#include <stdlib.h>
22
#include <stdio.h>
23
#include <string>
24

25
#include "ola/Logging.h"
26
#include "olad/PluginAdaptor.h"
27
#include "olad/Preferences.h"
28
#include "plugins/artnet/ArtNetPlugin.h"
29
#include "plugins/artnet/ArtNetDevice.h"
30

31

32
namespace ola {
33
namespace plugin {
34
namespace artnet {
35

36
using std::string;
37

38
const char ArtNetPlugin::ARTNET_LONG_NAME[] = "OLA - ArtNet node";
39
const char ArtNetPlugin::ARTNET_SHORT_NAME[] = "OLA - ArtNet node";
40
const char ArtNetPlugin::PLUGIN_NAME[] = "ArtNet";
41
const char ArtNetPlugin::PLUGIN_PREFIX[] = "artnet";
42

43
bool ArtNetPlugin::StartHook() {
1✔
44
  m_device = new ArtNetDevice(this,
2✔
45
                              m_preferences,
46
                              m_plugin_adaptor);
1✔
47

48
  if (!m_device->Start()) {
1✔
49
    delete m_device;
×
50
    return false;
×
51
  }
52
  // Register device will restore the port settings. To avoid a flurry of
53
  // ArtPoll / ArtPollReply messages, we enter config mode here.
54
  m_device->EnterConfigurationMode();
1✔
55
  m_plugin_adaptor->RegisterDevice(m_device);
1✔
56
  m_device->ExitConfigurationMode();
1✔
57
  return true;
1✔
58
}
59

60

61
bool ArtNetPlugin::StopHook() {
1✔
62
  if (m_device) {
1✔
63
    // stop the device
64
    m_plugin_adaptor->UnregisterDevice(m_device);
1✔
65
    bool ret = m_device->Stop();
1✔
66
    delete m_device;
1✔
67
    return ret;
1✔
68
  }
69
  return true;
70
}
71

72

73
string ArtNetPlugin::Description() const {
×
74
  return
×
75
      "ArtNet Plugin\n"
×
76
      "----------------------------\n"
77
      "\n"
78
      "This plugin creates a single device with four input and four output \n"
79
      "ports and supports ArtNet, ArtNet 2 and ArtNet 3.\n"
80
      "\n"
81
      "ArtNet limits a single device (identified by a unique IP) to four\n"
82
      "input and four output ports, each bound to a separate ArtNet Port\n"
83
      "Address (see the ArtNet spec for more details). The ArtNet Port\n"
84
      "Address is a 16 bits int, defined as follows: \n"
85
      "\n"
86
      " Bit 15 | Bits 14 - 8 | Bits 7 - 4 | Bits 3 - 0\n"
87
      " 0      |   Net       | Sub-Net    | Universe\n"
88
      "\n"
89
      "For OLA, the Net and Sub-Net values can be controlled by the config\n"
90
      "file. The Universe bits are the OLA Universe number modulo 16.\n"
91
      "\n"
92
      " ArtNet Net | ArtNet Subnet | OLA Universe | ArtNet Port Address\n"
93
      " 0          | 0             | 0            | 0\n"
94
      " 0          | 0             | 1            | 1\n"
95
      " 0          | 0             | 15           | 15\n"
96
      " 0          | 0             | 16           | 0\n"
97
      " 0          | 0             | 17           | 1\n"
98
      " 0          | 1             | 0            | 16\n"
99
      " 0          | 1             | 1            | 17\n"
100
      " 0          | 15            | 0            | 240\n"
101
      " 0          | 15            | 15           | 255\n"
102
      " 1          | 0             | 0            | 256\n"
103
      " 1          | 0             | 1            | 257\n"
104
      " 1          | 0             | 15           | 271\n"
105
      " 1          | 1             | 0            | 272\n"
106
      " 1          | 15            | 0            | 496\n"
107
      " 1          | 15            | 15           | 511\n"
108
      "\n"
109
      "That is Port Address = (Net << 8) + (Subnet << 4) + (Universe % 4)\n"
110
      "\n"
111
      "--- Config file : ola-artnet.conf ---\n"
112
      "\n"
113
      "always_broadcast = [true|false]\n"
114
      "Use ArtNet v1 and always broadcast the DMX data. Turn this on if\n"
115
      "you have devices that don't respond to ArtPoll messages.\n"
116
      "\n"
117
      "ip = [a.b.c.d|<interface_name>]\n"
118
      "The ip address or interface name to bind to. If not specified it will\n"
119
      "use the first non-loopback interface.\n"
120
      "\n"
121
      "long_name = ola - ArtNet node\n"
122
      "The long name of the node.\n"
123
      "\n"
124
      "net = 0\n"
125
      "The ArtNet Net to use (0-127).\n"
126
      "\n"
127
      "output_ports = 4\n"
128
      "The number of output ports (Send ArtNet) to create. Only the first 4\n"
129
      "will appear in ArtPoll messages\n"
130
      "\n"
131
      "short_name = ola - ArtNet node\n"
132
      "The short name of the node (first 17 chars will be used).\n"
133
      "\n"
134
      "subnet = 0\n"
135
      "The ArtNet subnet to use (0-15).\n"
136
      "\n"
137
      "use_limited_broadcast = [true|false]\n"
138
      "When broadcasting, use the limited broadcast address (255.255.255.255)\n"
139
      "rather than the subnet directed broadcast address. Some devices which \n"
140
      "don't follow the ArtNet spec require this. This only affects ArtDMX \n"
141
      "packets.\n"
142
      "\n"
143
      "use_loopback = [true|false]\n"
144
      "Enable use of the loopback device.\n"
145
      "\n";
×
146
}
147

148

149
bool ArtNetPlugin::SetDefaultPreferences() {
1✔
150
  bool save = false;
1✔
151

152
  if (!m_preferences) {
1✔
153
    return false;
154
  }
155

156
  save |= m_preferences->SetDefaultValue(ArtNetDevice::K_IP_KEY,
1✔
157
                                         StringValidator(true), "");
1✔
158
  save |= m_preferences->SetDefaultValue(ArtNetDevice::K_SHORT_NAME_KEY,
1✔
159
                                         StringValidator(),
1✔
160
                                         ARTNET_SHORT_NAME);
161
  save |= m_preferences->SetDefaultValue(ArtNetDevice::K_LONG_NAME_KEY,
1✔
162
                                         StringValidator(),
1✔
163
                                         ARTNET_LONG_NAME);
164
  save |= m_preferences->SetDefaultValue(ArtNetDevice::K_NET_KEY,
1✔
165
                                         UIntValidator(0, 127),
1✔
166
                                         ArtNetDevice::K_ARTNET_NET);
167
  save |= m_preferences->SetDefaultValue(ArtNetDevice::K_SUBNET_KEY,
1✔
168
                                         UIntValidator(0, 15),
1✔
169
                                         ArtNetDevice::K_ARTNET_SUBNET);
170
  save |= m_preferences->SetDefaultValue(
1✔
171
      ArtNetDevice::K_OUTPUT_PORT_KEY,
172
      UIntValidator(0, 16),
1✔
173
      ArtNetDevice::K_DEFAULT_OUTPUT_PORT_COUNT);
174
  save |= m_preferences->SetDefaultValue(ArtNetDevice::K_ALWAYS_BROADCAST_KEY,
1✔
175
                                         BoolValidator(),
1✔
176
                                         false);
177
  save |= m_preferences->SetDefaultValue(ArtNetDevice::K_LIMITED_BROADCAST_KEY,
1✔
178
                                         BoolValidator(),
1✔
179
                                         false);
180
  save |= m_preferences->SetDefaultValue(ArtNetDevice::K_LOOPBACK_KEY,
1✔
181
                                         BoolValidator(),
1✔
182
                                         false);
183

184
  if (save) {
1✔
185
    m_preferences->Save();
1✔
186
  }
187

188
  // check if this saved correctly
189
  // we don't want to use it if null
190
  if (m_preferences->GetValue(ArtNetDevice::K_SHORT_NAME_KEY).empty() ||
3✔
191
      m_preferences->GetValue(ArtNetDevice::K_LONG_NAME_KEY).empty() ||
5✔
192
      m_preferences->GetValue(ArtNetDevice::K_SUBNET_KEY).empty() ||
5✔
193
      m_preferences->GetValue(ArtNetDevice::K_OUTPUT_PORT_KEY).empty() ||
6✔
194
      m_preferences->GetValue(ArtNetDevice::K_NET_KEY).empty()) {
3✔
195
    return false;
196
  }
197

198
  return true;
199
}
200
}  // namespace artnet
201
}  // namespace plugin
202
}  // namespace ola
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc