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

OpenLightingProject / ola / 23758994672

30 Mar 2026 05:43PM UTC coverage: 45.174% (-0.7%) from 45.909%
23758994672

push

github

web-flow
Merge pull request #2033 from peternewman/0.10-fix-sid

Fix Sid dependencies and autopkgtest

8051 of 18455 branches covered (43.63%)

20598 of 45597 relevant lines covered (45.17%)

50.22 hits per line

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

56.76
/plugins/opendmx/OpenDmxPlugin.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
 * OpenDmxPlugin.cpp
17
 * The Open DMX plugin for ola
18
 * Copyright (C) 2005 Simon Newton
19
 */
20

21
#include <errno.h>
22
#include <fcntl.h>
23
#include <stdio.h>
24
#include <stdlib.h>
25
#include <string.h>
26
#include <string>
27
#include <vector>
28

29
#include "ola/Logging.h"
30
#include "ola/io/IOUtils.h"
31
#include "olad/PluginAdaptor.h"
32
#include "olad/Preferences.h"
33
#include "plugins/opendmx/OpenDmxDevice.h"
34
#include "plugins/opendmx/OpenDmxPlugin.h"
35

36
namespace ola {
37
namespace plugin {
38
namespace opendmx {
39

40
using ola::PluginAdaptor;
41
using std::string;
42
using std::vector;
43

44
const char OpenDmxPlugin::OPENDMX_DEVICE_PATH[] = "/dev/dmx0";
45
const char OpenDmxPlugin::OPENDMX_DEVICE_NAME[] = "OpenDmx USB Device";
46
const char OpenDmxPlugin::PLUGIN_NAME[] = "Enttec Open DMX";
47
const char OpenDmxPlugin::PLUGIN_PREFIX[] = "opendmx";
48
const char OpenDmxPlugin::DEVICE_KEY[] = "device";
49

50

51
/*
52
 * Start the plugin
53
 * TODO: scan /dev for devices?
54
 */
55
bool OpenDmxPlugin::StartHook() {
1✔
56
  vector<string> devices = m_preferences->GetMultipleValue(DEVICE_KEY);
1✔
57
  vector<string>::const_iterator iter = devices.begin();
1✔
58

59
  // start counting device ids from 0
60
  unsigned int device_id = 0;
1✔
61

62
  for (; iter != devices.end(); ++iter) {
2✔
63
    // first check if it's there
64
    int fd;
1✔
65
    if (ola::io::Open(*iter, O_WRONLY, &fd)) {
1✔
66
      close(fd);
×
67
      OpenDmxDevice *device = new OpenDmxDevice(
×
68
          this,
69
          OPENDMX_DEVICE_NAME,
70
          *iter,
×
71
          device_id++);
×
72
      if (device->Start()) {
×
73
        m_devices.push_back(device);
×
74
        m_plugin_adaptor->RegisterDevice(device);
×
75
      } else {
76
        OLA_WARN << "Failed to start OpenDmxDevice for " << *iter;
×
77
        delete device;
×
78
      }
79
    } else {
80
      OLA_WARN << "Could not open " << *iter << " " << strerror(errno);
1✔
81
    }
82
  }
83
  return true;
1✔
84
}
1✔
85

86

87
/*
88
 * Stop the plugin
89
 * @return true on success, false on failure
90
 */
91
bool OpenDmxPlugin::StopHook() {
1✔
92
  bool ret = true;
1✔
93
  DeviceList::iterator iter = m_devices.begin();
1✔
94
  for (; iter != m_devices.end(); ++iter) {
1✔
95
    m_plugin_adaptor->UnregisterDevice(*iter);
×
96
    ret &= (*iter)->Stop();
×
97
    delete *iter;
×
98
  }
99
  m_devices.clear();
1✔
100
  return ret;
1✔
101
}
102

103

104
/*
105
 * Return the description for this plugin
106
 */
107
string OpenDmxPlugin::Description() const {
×
108
    return
×
109
"Enttec Open DMX Plugin\n"
×
110
"----------------------------\n"
111
"\n"
112
"The plugin creates a single device with one output port using the Enttec\n"
113
"Open DMX USB widget. It requires the Open DMX kernel module, if you don't\n"
114
"have this installed, use the FTDI DMX USB plugin instead.\n"
115
"\n"
116
"--- Config file : ola-opendmx.conf ---\n"
117
"\n"
118
"device = /dev/dmx0\n"
119
"The path to the Open DMX USB device. Multiple entries are supported.\n"
120
"\n";
×
121
}
122

123

124
/*
125
 * Set default preferences.
126
 */
127
bool OpenDmxPlugin::SetDefaultPreferences() {
1✔
128
  if (!m_preferences) {
1✔
129
    return false;
130
  }
131

132
  if (m_preferences->SetDefaultValue(DEVICE_KEY, StringValidator(),
1✔
133
                                     OPENDMX_DEVICE_PATH)) {
134
    m_preferences->Save();
1✔
135
  }
136

137
  // check if this save correctly
138
  // we don't want to use it if null
139
  if (m_preferences->GetValue(DEVICE_KEY).empty()) {
1✔
140
    return false;
141
  }
142

143
  return true;
144
}
145
}  // namespace opendmx
146
}  // namespace plugin
147
}  // 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