• 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

16.22
/plugins/ftdidmx/FtdiDmxPlugin.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
 * FtdiDmxPlugin.cpp
17
 * The FTDI usb chipset DMX plugin for ola
18
 * Copyright (C) 2011 Rui Barreiros
19
 *
20
 * Additional modifications to enable support for multiple outputs and
21
 * additional device ids did change the original structure.
22
 *
23
 * by E.S. Rosenberg a.k.a. Keeper of the Keys 5774/2014
24
 */
25

26
#include <vector>
27
#include <string>
28

29
#include "ola/StringUtils.h"
30
#include "olad/Preferences.h"
31
#include "olad/PluginAdaptor.h"
32
#include "plugins/ftdidmx/FtdiDmxPlugin.h"
33
#include "plugins/ftdidmx/FtdiDmxDevice.h"
34
#include "plugins/ftdidmx/FtdiWidget.h"
35

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

40
using std::string;
41
using std::vector;
42

43
const char FtdiDmxPlugin::K_FREQUENCY[] = "frequency";
44
const char FtdiDmxPlugin::PLUGIN_NAME[] = "FTDI USB DMX";
45
const char FtdiDmxPlugin::PLUGIN_PREFIX[] = "ftdidmx";
46

47
/**
48
 * @brief Attempt to start a device and, if successful, register it
49
 *
50
 * Ownership of the FtdiDmxDevice is transferred to us here.
51
 */
52
void FtdiDmxPlugin::AddDevice(FtdiDmxDevice *device) {
×
53
  if (device->Start()) {
×
54
      m_devices.push_back(device);
×
55
      m_plugin_adaptor->RegisterDevice(device);
×
56
  } else {
57
    OLA_WARN << "Failed to start FTDI device " << device->Description();
×
58
    delete device;
×
59
  }
60
}
×
61

62

63
/**
64
 * @brief Fetch a list of all FTDI widgets and create a new device for each of them.
65
 */
66
bool FtdiDmxPlugin::StartHook() {
×
67
  typedef vector<FtdiWidgetInfo> FtdiWidgetInfoVector;
×
68
  FtdiWidgetInfoVector widgets;
×
69
  FtdiWidget::Widgets(&widgets);
×
70

71
  unsigned int frequency = StringToIntOrDefault(
×
72
      m_preferences->GetValue(K_FREQUENCY),
×
73
      DEFAULT_FREQUENCY);
×
74

75
  FtdiWidgetInfoVector::const_iterator iter;
×
76
  for (iter = widgets.begin(); iter != widgets.end(); ++iter) {
×
77
    AddDevice(new FtdiDmxDevice(this, *iter, frequency));
×
78
  }
79
  return true;
×
80
}
×
81

82

83
/**
84
 * @brief Stop all the devices.
85
 */
86
bool FtdiDmxPlugin::StopHook() {
×
87
  FtdiDeviceVector::iterator iter;
×
88
  for (iter = m_devices.begin(); iter != m_devices.end(); ++iter) {
×
89
    m_plugin_adaptor->UnregisterDevice(*iter);
×
90
    (*iter)->Stop();
×
91
    delete (*iter);
×
92
  }
93
  m_devices.clear();
×
94
  return true;
×
95
}
96

97

98
/**
99
 * @brief Return a description for this plugin.
100
 */
101
string FtdiDmxPlugin::Description() const {
×
102
  return
×
103
"FTDI USB Chipset DMX Plugin\n"
×
104
"----------------------------\n"
105
"\n"
106
"This plugin is compatible with Enttec Open DMX USB and other\n"
107
"FTDI chipset based USB to DMX converters where the host\n"
108
"needs to create the DMX stream itself and not the interface\n"
109
"(the interface has no microprocessor to do so).\n"
110
"\n"
111
"--- Config file : ola-ftdidmx.conf ---\n"
112
"\n"
113
"frequency = 30\n"
114
"The DMX stream frequency (30 to 44 Hz max are the usual).\n"
115
"\n";
×
116
}
117

118

119
/**
120
 * @brief Set the default preferences
121
 */
122
bool FtdiDmxPlugin::SetDefaultPreferences() {
1✔
123
  if (!m_preferences) {
1✔
124
    return false;
125
  }
126

127
  if (m_preferences->SetDefaultValue(FtdiDmxPlugin::K_FREQUENCY,
1✔
128
                                     UIntValidator(1, 44),
2✔
129
                                     DEFAULT_FREQUENCY)) {
130
    m_preferences->Save();
1✔
131
  }
132

133
  if (m_preferences->GetValue(FtdiDmxPlugin::K_FREQUENCY).empty()) {
1✔
134
    return false;
135
  }
136

137
  return true;
138
}
139
}  // namespace ftdidmx
140
}  // namespace plugin
141
}  // 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