Skip to content
Permalink
Browse files

Add enable_eurolite_mk2 preference to usbdmx plugin

When this key is enabled, the plugin conflicts with ftdi usb dmx and
serialusb. It is disabled by default. This is an effort to finish #1292.
I've tested the commit with the Eurolite MK2 device.
  • Loading branch information...
aroffringa committed Apr 21, 2019
1 parent dc873eb commit c508e963edaf04f36e0ab25972ea41aad10c37c4
@@ -126,7 +126,7 @@ bool AsyncPluginImpl::Start() {
m_preferences));
m_widget_factories.push_back(new DMXCreator512BasicFactory(m_usb_adaptor));
m_widget_factories.push_back(
new EuroliteProFactory(m_usb_adaptor));
new EuroliteProFactory(m_usb_adaptor, m_preferences));
m_widget_factories.push_back(
new JaRuleFactory(m_plugin_adaptor, m_usb_adaptor));
m_widget_factories.push_back(
@@ -44,6 +44,26 @@ const char EuroliteProFactory::EXPECTED_PRODUCT_MK2[] = "FT232R USB UART";
const uint16_t EuroliteProFactory::PRODUCT_ID_MK2 = 0x6001;
const uint16_t EuroliteProFactory::VENDOR_ID_MK2 = 0x0403;

const char EuroliteProFactory::ENABLE_EUROLITE_MK2_KEY[] = "enable_eurolite_mk2";

EuroliteProFactory::EuroliteProFactory(ola::usb::LibUsbAdaptor *adaptor,
Preferences *preferences)
: BaseWidgetFactory<class EurolitePro>("EuroliteProFactory"),
m_adaptor(adaptor),
m_enable_eurolite_mk2(IsEuroliteMk2Enabled(preferences))
{
}

bool EuroliteProFactory::IsEuroliteMk2Enabled(Preferences *preferences)
{
bool enabled;
if (!StringToBool(preferences->GetValue(ENABLE_EUROLITE_MK2_KEY),
&enabled)) {
enabled = false;
}
return enabled;
}

bool EuroliteProFactory::DeviceAdded(
WidgetObserver *observer,
libusb_device *usb_device,
@@ -67,7 +87,8 @@ bool EuroliteProFactory::DeviceAdded(
}

// Eurolite USB-DMX512-PRO MK2?
} else if (descriptor.idVendor == VENDOR_ID_MK2 &&
} else if (m_enable_eurolite_mk2 &&
descriptor.idVendor == VENDOR_ID_MK2 &&
descriptor.idProduct == PRODUCT_ID_MK2) {
OLA_INFO << "Found a new Eurolite USB-DMX512-PRO MK2 device";
LibUsbAdaptor::DeviceInformation info;
@@ -23,6 +23,7 @@

#include "libs/usb/LibUsbAdaptor.h"
#include "ola/base/Macro.h"
#include "olad/Preferences.h"
#include "plugins/usbdmx/EurolitePro.h"
#include "plugins/usbdmx/WidgetFactory.h"

@@ -35,16 +36,18 @@ namespace usbdmx {
*/
class EuroliteProFactory : public BaseWidgetFactory<class EurolitePro> {
public:
explicit EuroliteProFactory(ola::usb::LibUsbAdaptor *adaptor)
: BaseWidgetFactory<class EurolitePro>("EuroliteProFactory"),
m_adaptor(adaptor) {}
explicit EuroliteProFactory(ola::usb::LibUsbAdaptor *adaptor,
Preferences *preferences);

bool DeviceAdded(WidgetObserver *observer,
libusb_device *usb_device,
const struct libusb_device_descriptor &descriptor);

static bool IsEuroliteMk2Enabled(Preferences *preferences);

private:
ola::usb::LibUsbAdaptor *m_adaptor;
bool m_enable_eurolite_mk2;

static const uint16_t PRODUCT_ID;
static const uint16_t VENDOR_ID;
@@ -56,6 +59,8 @@ class EuroliteProFactory : public BaseWidgetFactory<class EurolitePro> {
static const char EXPECTED_MANUFACTURER_MK2[];
static const char EXPECTED_PRODUCT_MK2[];

static const char ENABLE_EUROLITE_MK2_KEY[];

DISALLOW_COPY_AND_ASSIGN(EuroliteProFactory);
};
} // namespace usbdmx
@@ -7,7 +7,8 @@ This plugin supports various USB DMX devices including:
* AVLdiy D512
* DMXControl Projects e.V. Nodle U1
* DMXCreator 512 Basic
* Eurolite
* Eurolite USB-DMX512 PRO
* Eurolite USB-DMX512 PRO MK2
* Fadecandy
* ShowJockey SJ-DMX-U1
* Sunlite USBDMX2
@@ -20,6 +21,12 @@ This plugin supports various USB DMX devices including:
The debug level for libusb, see http://libusb.sourceforge.net/api-1.0/
0 = No logging, 4 = Verbose debug.

`enable_eurolite_mk2 = {false,true}`
Whether to enable detection of the Eurolite USB-DMX512 PRO MK2.
Default = false. This device is indistinguishable from other devices
with an FTDI chip, and is therefore disabled by default. When enabled,
this plugin will conflict with the usbserial and ftdi usb dmx plugins.

`nodle-<serial>-mode = {0,1,2,3,4,5,6,7}`
The mode for the Nodle U1 interface with serial number `<serial>` to operate
in. Default = 6
@@ -77,7 +77,8 @@ SyncPluginImpl::SyncPluginImpl(PluginAdaptor *plugin_adaptor,
m_widget_factories.push_back(new DMXCProjectsNodleU1Factory(&m_usb_adaptor,
m_plugin_adaptor, m_preferences));
m_widget_factories.push_back(new DMXCreator512BasicFactory(&m_usb_adaptor));
m_widget_factories.push_back(new EuroliteProFactory(&m_usb_adaptor));
m_widget_factories.push_back(new EuroliteProFactory(&m_usb_adaptor,
m_preferences));
m_widget_factories.push_back(new ScanlimeFadecandyFactory(&m_usb_adaptor));
m_widget_factories.push_back(new ShowJockeyDMXU1Factory(&m_usb_adaptor));
m_widget_factories.push_back(new SunliteFactory(&m_usb_adaptor));
@@ -26,6 +26,7 @@
#include "ola/base/Flags.h"
#include "olad/Preferences.h"
#include "plugins/usbdmx/AsyncPluginImpl.h"
#include "plugins/usbdmx/EuroliteProFactory.h"
#include "plugins/usbdmx/PluginImplInterface.h"
#include "plugins/usbdmx/SyncPluginImpl.h"
#include "plugins/usbdmx/UsbDmxPluginDescription.h"
@@ -107,6 +108,16 @@ bool UsbDmxPlugin::SetDefaultPreferences() {

return true;
}

void UsbDmxPlugin::ConflictsWith(std::set<ola_plugin_id>* conflicting_plugins) const
{
if(EuroliteProFactory::IsEuroliteMk2Enabled(m_preferences))
{
conflicting_plugins->insert(OLA_PLUGIN_USBPRO);
conflicting_plugins->insert(OLA_PLUGIN_FTDIDMX);
}
}

} // namespace usbdmx
} // namespace plugin
} // namespace ola
@@ -40,6 +40,7 @@ namespace usbdmx {
* - DMXControl Projects e.V. Nodle U1.
* - DMXCreator 512 Basic USB.
* - Eurolite DMX USB Pro.
* - Eurolite DMX USB Pro MK2.
* - Scanlime's Fadecandy.
* - Sunlite.
* - Velleman K8062.
@@ -59,6 +60,8 @@ class UsbDmxPlugin: public ola::Plugin {
ola_plugin_id Id() const { return OLA_PLUGIN_USBDMX; }
std::string PluginPrefix() const { return PLUGIN_PREFIX; }

virtual void ConflictsWith(std::set<ola_plugin_id>* conflicting_plugins) const override;

private:
std::auto_ptr<class PluginImplInterface> m_impl;

0 comments on commit c508e96

Please sign in to comment.
You can’t perform that action at this time.