Skip to content

Commit

Permalink
Add a Eurolite serial number check
Browse files Browse the repository at this point in the history
This MR adds an option 'eurolite_serials' to the usb dmx plugin. This option accepts
a comma separated list of serial numbers that are assumed to be Eurolite mk2 devices
(as long as their product and vendor ids also match).

This allows finding the Eurolite MK2 without enabling the 'enable_eurolite_mk2' option.
The advantage is that is avoids the conflicts that 'enable_eurolite_mk2' produces
with other plugins. These
conflicts make it impossible to connect the mk2 simultaneously together with most other
interfaces to have multiple universes and/or input universes.

I have tested this by connecting an Enttec pro together with the Eurolite Mk2, and this
works.
  • Loading branch information
aroffringa committed Aug 3, 2023
1 parent 5fa67e5 commit cae45f7
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 9 deletions.
30 changes: 21 additions & 9 deletions plugins/usbdmx/EuroliteProFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
#include "ola/Logging.h"
#include "ola/base/Flags.h"

#include <algorithm>

Check failure on line 27 in plugins/usbdmx/EuroliteProFactory.cpp

View workflow job for this annotation

GitHub Actions / cpplint

Found C++ system header after other header. Should be: EuroliteProFactory.h, c system, c++ system, other. [build/include_order] [4]

DECLARE_bool(use_async_libusb);

namespace ola {
Expand All @@ -46,12 +48,15 @@ const uint16_t EuroliteProFactory::VENDOR_ID_MK2 = 0x0403;

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

EuroliteProFactory::EuroliteProFactory(ola::usb::LibUsbAdaptor *adaptor,
Preferences *preferences)
: BaseWidgetFactory<class EurolitePro>("EuroliteProFactory"),
m_adaptor(adaptor),
m_enable_eurolite_mk2(IsEuroliteMk2Enabled(preferences)) {
StringSplit(preferences->GetValue(EUROLITE_SERIALS_KEY), m_expected_eurolite_serials, ",");

Check failure on line 59 in plugins/usbdmx/EuroliteProFactory.cpp

View workflow job for this annotation

GitHub Actions / cpplint

Lines should be <= 80 characters long [whitespace/line_length] [2]
}

bool EuroliteProFactory::IsEuroliteMk2Enabled(Preferences *preferences) {
Expand Down Expand Up @@ -88,12 +93,16 @@ bool EuroliteProFactory::DeviceAdded(
// Eurolite USB-DMX512-PRO MK2?
} else if (descriptor.idVendor == VENDOR_ID_MK2 &&
descriptor.idProduct == PRODUCT_ID_MK2) {
if (m_enable_eurolite_mk2) {
OLA_INFO << "Found a possible new Eurolite USB-DMX512-PRO MK2 device";
LibUsbAdaptor::DeviceInformation info;
if (!m_adaptor->GetDeviceInfo(usb_device, descriptor, &info)) {
return false;
}

Check failure on line 96 in plugins/usbdmx/EuroliteProFactory.cpp

View workflow job for this annotation

GitHub Actions / cpplint

Line ends in whitespace. Consider deleting these extra spaces. [whitespace/end_of_line] [4]

Check failure on line 96 in plugins/usbdmx/EuroliteProFactory.cpp

View workflow job for this annotation

GitHub Actions / cpplint

Redundant blank line at the start of a code block should be deleted. [whitespace/blank_line] [2]
LibUsbAdaptor::DeviceInformation info;
if (!m_adaptor->GetDeviceInfo(usb_device, descriptor, &info)) {
return false;
}

Check failure on line 101 in plugins/usbdmx/EuroliteProFactory.cpp

View workflow job for this annotation

GitHub Actions / cpplint

Line ends in whitespace. Consider deleting these extra spaces. [whitespace/end_of_line] [4]
const bool serial_matches = std::find(m_expected_eurolite_serials.begin(), m_expected_eurolite_serials.end(), info.serial) != m_expected_eurolite_serials.end();

Check failure on line 102 in plugins/usbdmx/EuroliteProFactory.cpp

View workflow job for this annotation

GitHub Actions / cpplint

Lines should be <= 80 characters long [whitespace/line_length] [2]

Check failure on line 103 in plugins/usbdmx/EuroliteProFactory.cpp

View workflow job for this annotation

GitHub Actions / cpplint

Line ends in whitespace. Consider deleting these extra spaces. [whitespace/end_of_line] [4]
if (m_enable_eurolite_mk2 || serial_matches) {
OLA_INFO << "Found a possible new Eurolite USB-DMX512-PRO MK2 device with serial " << info.serial;

Check failure on line 105 in plugins/usbdmx/EuroliteProFactory.cpp

View workflow job for this annotation

GitHub Actions / cpplint

Lines should be <= 80 characters long [whitespace/line_length] [2]

if (!m_adaptor->CheckManufacturer(EXPECTED_MANUFACTURER_MK2, info)) {
return false;
Expand All @@ -104,9 +113,12 @@ bool EuroliteProFactory::DeviceAdded(
}
is_mk2 = true;
} else {
OLA_INFO << "Connected FTDI device could be a Eurolite "
<< "USB-DMX512-PRO MK2 but was ignored, because "
<< ENABLE_EUROLITE_MK2_KEY << " was false.";
OLA_INFO << "Connected FTDI device with serial " << info.serial
<< " could be a Eurolite USB-DMX512-PRO MK2 but was "
<< "ignored, because "
<< ENABLE_EUROLITE_MK2_KEY << " was false and "
<< "its serial number was not in the "
<< "configuration.";
return false;
}
} else {
Expand Down
2 changes: 2 additions & 0 deletions plugins/usbdmx/EuroliteProFactory.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,12 @@ class EuroliteProFactory : public BaseWidgetFactory<class EurolitePro> {
static bool IsEuroliteMk2Enabled(Preferences *preferences);

static const char ENABLE_EUROLITE_MK2_KEY[];
static const char EUROLITE_SERIALS_KEY[];

private:
ola::usb::LibUsbAdaptor *m_adaptor;
bool m_enable_eurolite_mk2;
std::vector<std::string> m_expected_eurolite_serials;

Check failure on line 54 in plugins/usbdmx/EuroliteProFactory.h

View workflow job for this annotation

GitHub Actions / cpplint

Add #include <string> for string [build/include_what_you_use] [4]

Check failure on line 54 in plugins/usbdmx/EuroliteProFactory.h

View workflow job for this annotation

GitHub Actions / cpplint

Add #include <vector> for vector<> [build/include_what_you_use] [4]

static const uint16_t PRODUCT_ID;
static const uint16_t VENDOR_ID;
Expand Down

0 comments on commit cae45f7

Please sign in to comment.