From d4414feefd95adf9c91d7eaf1e94380296c35f7a Mon Sep 17 00:00:00 2001 From: Peter Newman Date: Fri, 7 Jul 2023 15:57:35 +0100 Subject: [PATCH 1/5] Fix protoc version checking, since v20.x (cherry picked from commit 2e55aa88756718d8ab4a4c8fde97d620542c2c98) --- config/ola.m4 | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/config/ola.m4 b/config/ola.m4 index f838ab70ad..51b6c825c6 100644 --- a/config/ola.m4 +++ b/config/ola.m4 @@ -44,7 +44,14 @@ if test -z "$PROTOC" ; then AC_MSG_ERROR([cannot find 'protoc' program]); elif test -n "$1" ; then AC_MSG_CHECKING([protoc version]) - [protoc_version=`$PROTOC --version 2>&1 | grep 'libprotoc' | sed 's/.*\([0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\).*/\1/g'`] + # Since v20.x we only get effectively the minor and patch versions out of protoc. + # Treat them as major and minor and everything should keep working indefinitely. + # See https://protobuf.dev/support/version-support/ + # So we've got either of these: + # libprotoc 2.4.1 + # libprotoc 23.3 + # The first sed ensures all versions have major, minor, patch, by adding a .0 on the end of ones missing it + [protoc_version=`$PROTOC --version 2>&1 | grep 'libprotoc' | sed 's/\([^\.0-9][0-9][0-9]*\.[0-9][0-9]*\)$/\1\.0/g' | sed 's/.*\([0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\).*/\1/g'`] [required=$1] [required_major=`echo $required | sed 's/[^0-9].*//'`] [required_minor=`echo $required | sed 's/[0-9][0-9]*\.\([0-9][0-9]*\)\.[0-9][0-9]*/\1/'`] From 546d9ee8d970c4e5b33d9d28b4acf6eb34f27a5d Mon Sep 17 00:00:00 2001 From: Peter Newman Date: Fri, 7 Jul 2023 16:14:21 +0100 Subject: [PATCH 2/5] Protoc check - correctly match multi-digit major versions (cherry picked from commit 69a2946622cdfce54cb6ed7f2210df2be0ec5576) --- config/ola.m4 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/ola.m4 b/config/ola.m4 index 51b6c825c6..eacee5d94f 100644 --- a/config/ola.m4 +++ b/config/ola.m4 @@ -51,7 +51,7 @@ elif test -n "$1" ; then # libprotoc 2.4.1 # libprotoc 23.3 # The first sed ensures all versions have major, minor, patch, by adding a .0 on the end of ones missing it - [protoc_version=`$PROTOC --version 2>&1 | grep 'libprotoc' | sed 's/\([^\.0-9][0-9][0-9]*\.[0-9][0-9]*\)$/\1\.0/g' | sed 's/.*\([0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\).*/\1/g'`] + [protoc_version=`$PROTOC --version 2>&1 | grep 'libprotoc' | sed 's/\([^\.0-9][0-9][0-9]*\.[0-9][0-9]*\)$/\1\.0/g' | sed 's/[^0-9]*\([0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\).*/\1/g'`] [required=$1] [required_major=`echo $required | sed 's/[^0-9].*//'`] [required_minor=`echo $required | sed 's/[0-9][0-9]*\.\([0-9][0-9]*\)\.[0-9][0-9]*/\1/'`] From 6a6b42ef7781db47fac73c5e9ba9faeebebfca76 Mon Sep 17 00:00:00 2001 From: Peter Newman Date: Sat, 3 Feb 2024 16:07:52 +0000 Subject: [PATCH 3/5] Track Eurolite MK2 by actual serial number where available --- plugins/usbdmx/EuroliteProFactory.cpp | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/plugins/usbdmx/EuroliteProFactory.cpp b/plugins/usbdmx/EuroliteProFactory.cpp index f79c812602..be380862a3 100644 --- a/plugins/usbdmx/EuroliteProFactory.cpp +++ b/plugins/usbdmx/EuroliteProFactory.cpp @@ -150,17 +150,21 @@ bool EuroliteProFactory::DeviceAdded( return false; } - // The Eurolite doesn't have a serial number, so instead we use the device & - // bus number. + // The original Eurolite doesn't have a serial number, so instead we use the + // device & bus number. The MK2 does, so we use that where available. // TODO(simon): check if this supports the SERIAL NUMBER label and use that // instead. - // There is no Serialnumber--> work around: bus+device number - int bus_number = libusb_get_bus_number(usb_device); - int device_address = libusb_get_device_address(usb_device); - std::ostringstream serial_str; - serial_str << bus_number << "-" << device_address; + if (is_mk2 && !info.serial.empty()) { + serial_str << info.serial; + } else { + // Original, there is no Serialnumber--> work around: bus+device number + int bus_number = libusb_get_bus_number(usb_device); + int device_address = libusb_get_device_address(usb_device); + + serial_str << bus_number << "-" << device_address; + } EurolitePro *widget = NULL; if (FLAGS_use_async_libusb) { From 949ce94bbd1e42855b074e9f49f8f5ef274239fa Mon Sep 17 00:00:00 2001 From: Peter Newman Date: Sat, 3 Feb 2024 16:21:06 +0000 Subject: [PATCH 4/5] Add some potential TODO for another way to track devices without serial --- plugins/usbdmx/AVLdiyD512Factory.cpp | 3 +++ plugins/usbdmx/AnymauDMXFactory.cpp | 3 +++ plugins/usbdmx/DMXCreator512BasicFactory.cpp | 3 +++ plugins/usbdmx/ScanlimeFadecandyFactory.cpp | 3 +++ 4 files changed, 12 insertions(+) diff --git a/plugins/usbdmx/AVLdiyD512Factory.cpp b/plugins/usbdmx/AVLdiyD512Factory.cpp index 0f965ab7f7..2e0481636f 100644 --- a/plugins/usbdmx/AVLdiyD512Factory.cpp +++ b/plugins/usbdmx/AVLdiyD512Factory.cpp @@ -63,6 +63,9 @@ bool AVLdiyD512Factory::DeviceAdded( // Some AVLdiy devices don't have serial numbers. Since there isn't another // good way to uniquely identify a USB device, we only support one of these // types of devices per host. + // TODO(Peter): We could instead use the device & bus number (like the + // Eurolite plugin). You could use more than one device, but the patch + // wouldn't follow if you plugged it into a different port if (info.serial.empty()) { if (m_missing_serial_number) { OLA_WARN << "Failed to read serial number or serial number empty. " diff --git a/plugins/usbdmx/AnymauDMXFactory.cpp b/plugins/usbdmx/AnymauDMXFactory.cpp index 1995fd87b1..86df54f2d9 100644 --- a/plugins/usbdmx/AnymauDMXFactory.cpp +++ b/plugins/usbdmx/AnymauDMXFactory.cpp @@ -63,6 +63,9 @@ bool AnymauDMXFactory::DeviceAdded( // Some Anyma devices don't have serial numbers. Since there isn't another // good way to uniquely identify a USB device, we only support one of these // types of devices per host. + // TODO(Peter): We could instead use the device & bus number (like the + // Eurolite plugin). You could use more than one device, but the patch + // wouldn't follow if you plugged it into a different port if (info.serial.empty()) { if (m_missing_serial_number) { OLA_WARN << "Failed to read serial number or serial number empty. " diff --git a/plugins/usbdmx/DMXCreator512BasicFactory.cpp b/plugins/usbdmx/DMXCreator512BasicFactory.cpp index 0728e7a183..caa6a0de5d 100644 --- a/plugins/usbdmx/DMXCreator512BasicFactory.cpp +++ b/plugins/usbdmx/DMXCreator512BasicFactory.cpp @@ -55,6 +55,9 @@ bool DMXCreator512BasicFactory::DeviceAdded( // vendor and product ids. Also, since DMXCreator 512 Basic devices don't have // serial numbers and there is no other good way to uniquely identify a USB // device, we only support one of these types of devices per host. + // TODO(Peter): We could instead use the device & bus number (like the + // Eurolite plugin). You could use more than one device, but the patch + // wouldn't follow if you plugged it into a different port if (info.serial.empty()) { if (m_missing_serial_number) { OLA_WARN << "We can only support one device without a serial number."; diff --git a/plugins/usbdmx/ScanlimeFadecandyFactory.cpp b/plugins/usbdmx/ScanlimeFadecandyFactory.cpp index 4f1420a8b6..60f28d5dd9 100644 --- a/plugins/usbdmx/ScanlimeFadecandyFactory.cpp +++ b/plugins/usbdmx/ScanlimeFadecandyFactory.cpp @@ -64,6 +64,9 @@ bool ScanlimeFadecandyFactory::DeviceAdded( // Fadecandy devices may be missing serial numbers. Since there isn't another // good way to uniquely identify a USB device, we only support one of these // types of devices per host. + // TODO(Peter): We could instead use the device & bus number (like the + // Eurolite plugin). You could use more than one device, but the patch + // wouldn't follow if you plugged it into a different port if (info.serial.empty()) { if (m_missing_serial_number) { OLA_WARN << "Failed to read serial number or serial number empty. " From 0fac6e8e73e4a7fca6be10c84c788c208fc047b4 Mon Sep 17 00:00:00 2001 From: Peter Newman Date: Sat, 3 Feb 2024 16:52:22 +0000 Subject: [PATCH 5/5] Enable access to the device info outside the if statements --- plugins/usbdmx/EuroliteProFactory.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/plugins/usbdmx/EuroliteProFactory.cpp b/plugins/usbdmx/EuroliteProFactory.cpp index be380862a3..42efe7bea6 100644 --- a/plugins/usbdmx/EuroliteProFactory.cpp +++ b/plugins/usbdmx/EuroliteProFactory.cpp @@ -92,11 +92,11 @@ bool EuroliteProFactory::DeviceAdded( libusb_device *usb_device, const struct libusb_device_descriptor &descriptor) { bool is_mk2 = false; + LibUsbAdaptor::DeviceInformation info; // Eurolite USB-DMX512-PRO? if (descriptor.idVendor == VENDOR_ID && descriptor.idProduct == PRODUCT_ID) { OLA_INFO << "Found a new Eurolite USB-DMX512-PRO device"; - LibUsbAdaptor::DeviceInformation info; if (!m_adaptor->GetDeviceInfo(usb_device, descriptor, &info)) { return false; } @@ -112,7 +112,6 @@ bool EuroliteProFactory::DeviceAdded( // Eurolite USB-DMX512-PRO MK2? } else if (descriptor.idVendor == VENDOR_ID_MK2 && descriptor.idProduct == PRODUCT_ID_MK2) { - LibUsbAdaptor::DeviceInformation info; if (!m_adaptor->GetDeviceInfo(usb_device, descriptor, &info)) { return false; }