• 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

78.79
/plugins/usbdmx/UsbDmxPlugin.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
 * UsbDmxPlugin.cpp
17
 * A plugin that uses libusb to communicate with USB devices.
18
 * Copyright (C) 2006 Simon Newton
19
 */
20

21
#include "plugins/usbdmx/UsbDmxPlugin.h"
22

23
#include <string>
24

25
#include "ola/Logging.h"
26
#include "ola/base/Flags.h"
27
#include "olad/Preferences.h"
28
#include "plugins/usbdmx/AsyncPluginImpl.h"
29
#include "plugins/usbdmx/PluginImplInterface.h"
30
#include "plugins/usbdmx/SyncPluginImpl.h"
31

32
DECLARE_bool(use_async_libusb);
33

34
namespace ola {
35
namespace plugin {
36
namespace usbdmx {
37

38
using std::string;
39

40
const char UsbDmxPlugin::PLUGIN_NAME[] = "USB";
41
const char UsbDmxPlugin::PLUGIN_PREFIX[] = "usbdmx";
42
const char UsbDmxPlugin::LIBUSB_DEBUG_LEVEL_KEY[] = "libusb_debug_level";
43
int UsbDmxPlugin::LIBUSB_DEFAULT_DEBUG_LEVEL = 0;
44
int UsbDmxPlugin::LIBUSB_MAX_DEBUG_LEVEL = 4;
45

46

47
UsbDmxPlugin::UsbDmxPlugin(PluginAdaptor *plugin_adaptor)
1✔
48
    : Plugin(plugin_adaptor) {
1✔
49
}
1✔
50

51
UsbDmxPlugin::~UsbDmxPlugin() {}
2✔
52

53
bool UsbDmxPlugin::StartHook() {
1✔
54
  if (m_impl.get()) {
1✔
55
    return true;
56
  }
57

58
  unsigned int debug_level;
1✔
59
  if (!StringToInt(m_preferences->GetValue(LIBUSB_DEBUG_LEVEL_KEY) ,
1✔
60
                   &debug_level)) {
61
    debug_level = LIBUSB_DEFAULT_DEBUG_LEVEL;
×
62
  }
63

64
  std::auto_ptr<PluginImplInterface> impl;
1✔
65
  if (FLAGS_use_async_libusb) {
1✔
66
    impl.reset(
1✔
67
        new AsyncPluginImpl(m_plugin_adaptor, this, debug_level,
68
                            m_preferences));
1✔
69
  } else {
70
    impl.reset(
×
71
        new SyncPluginImpl(m_plugin_adaptor, this, debug_level, m_preferences));
×
72
  }
73

74
  if (impl->Start()) {
1✔
75
    m_impl.reset(impl.release());
1✔
76
    return true;
1✔
77
  } else {
78
    return false;
79
  }
80
}
1✔
81

82
bool UsbDmxPlugin::StopHook() {
1✔
83
  if (m_impl.get()) {
1✔
84
    m_impl->Stop();
1✔
85
  }
86
  return true;
1✔
87
}
88

89
string UsbDmxPlugin::Description() const {
×
90
    return
×
91
"USB DMX Plugin\n"
×
92
"----------------------------\n"
93
"\n"
94
"This plugin supports various USB DMX devices including the \n"
95
"Anyma uDMX, DMXControl Projects e.V. Nodle U1, Eurolite, Fadecandy, "
96
"Sunlite USBDMX2 and Velleman K8062.\n"
97
"\n"
98
"--- Config file : ola-usbdmx.conf ---\n"
99
"\n"
100
"libusb_debug_level = {0,1,2,3,4}\n"
101
"The debug level for libusb, see http://libusb.sourceforge.net/api-1.0/ .\n"
102
"0 = No logging, 4 = Verbose debug.\n"
103
"\n"
104
"nodle-<serial>-mode = {0,1,2,3,4,5,6,7}\n"
105
"The mode for the Nodle U1 interface with serial number <serial> "
106
"to operate in. Default = 6\n"
107
"0 - Standby\n"
108
"1 - DMX In -> DMX Out\n"
109
"2 - PC Out -> DMX Out\n"
110
"3 - DMX In + PC Out -> DMX Out\n"
111
"4 - DMX In -> PC In\n"
112
"5 - DMX In -> DMX Out & DMX In -> PC In\n"
113
"6 - PC Out -> DMX Out & DMX In -> PC In\n"
114
"7 - DMX In + PC Out -> DMX Out & DMX In -> PC In\n"
115
"\n";
×
116
}
117

118
bool UsbDmxPlugin::SetDefaultPreferences() {
1✔
119
  if (!m_preferences) {
1✔
120
    return false;
121
  }
122

123
  bool save = m_preferences->SetDefaultValue(
1✔
124
      LIBUSB_DEBUG_LEVEL_KEY,
125
      UIntValidator(LIBUSB_DEFAULT_DEBUG_LEVEL, LIBUSB_MAX_DEBUG_LEVEL),
1✔
126
      LIBUSB_DEFAULT_DEBUG_LEVEL);
127

128
  if (save) {
1✔
129
    m_preferences->Save();
1✔
130
  }
131

132
  return true;
133
}
134
}  // namespace usbdmx
135
}  // namespace plugin
136
}  // 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