Fix LED Devices (Lightpack, Atmo/Karate, Hue) (#1337)

* Fix that lighpack cores when lack of permissions

* Atmo/Karate - Fix LedCount constraint handling

* Hue updates - Have EntertainmentAPI as default, disable hardwareledcount as cacultated

* Have Gamma per default 2.2
This commit is contained in:
LordGrey
2021-09-30 18:06:23 +02:00
committed by GitHub
parent af24e6d623
commit f269268def
5 changed files with 38 additions and 27 deletions

View File

@@ -118,11 +118,11 @@ bool LedDeviceLightpack::init(const QJsonObject &deviceConfig)
QString errortext;
if (_serialNumber.isEmpty())
{
errortext = QString ("No Lightpack devices were found");
errortext = QString ("No working Lightpack devices were found");
}
else
{
errortext = QString ("No Lightpack device found with serial %1").arg( _serialNumber);
errortext = QString ("No working Lightpack device found with serial %1").arg( _serialNumber);
}
this->setInError( errortext );
}
@@ -197,9 +197,6 @@ bool LedDeviceLightpack::searchDevice(libusb_device * device, const QString & re
return false;
}
#define UNO_VENDOR_ID 0x2341
#define UNO_PRODUCT_ID 0x43
if ((deviceDescriptor.idVendor == USB_VENDOR_ID && deviceDescriptor.idProduct == USB_PRODUCT_ID) ||
(deviceDescriptor.idVendor == USB_OLD_VENDOR_ID && deviceDescriptor.idProduct == USB_OLD_PRODUCT_ID))
{
@@ -375,28 +372,30 @@ int LedDeviceLightpack::openDevice(libusb_device *device, libusb_device_handle *
Error(_log, "unable to open device(%d): %s", error, libusb_error_name(error));
rc = -1;
}
// detach kernel driver if it is active
if (libusb_kernel_driver_active(handle, LIGHTPACK_INTERFACE) == 1)
else
{
error = libusb_detach_kernel_driver(handle, LIGHTPACK_INTERFACE);
// detach kernel driver if it is active
if (libusb_kernel_driver_active(handle, LIGHTPACK_INTERFACE) == 1)
{
error = libusb_detach_kernel_driver(handle, LIGHTPACK_INTERFACE);
if (error != LIBUSB_SUCCESS)
{
Error(_log, "unable to detach kernel driver(%d): %s", error, libusb_error_name(error));
libusb_close(handle);
rc = -1;
}
}
error = libusb_claim_interface(handle, LIGHTPACK_INTERFACE);
if (error != LIBUSB_SUCCESS)
{
Error(_log, "unable to detach kernel driver(%d): %s", error, libusb_error_name(error));
Error(_log, "unable to claim interface(%d): %s", error, libusb_error_name(error));
libusb_attach_kernel_driver(handle, LIGHTPACK_INTERFACE);
libusb_close(handle);
rc = -1;
}
}
error = libusb_claim_interface(handle, LIGHTPACK_INTERFACE);
if (error != LIBUSB_SUCCESS)
{
Error(_log, "unable to claim interface(%d): %s", error, libusb_error_name(error));
libusb_attach_kernel_driver(handle, LIGHTPACK_INTERFACE);
libusb_close(handle);
rc = -1;
}
*deviceHandle = handle;
return rc;
}

View File

@@ -28,7 +28,7 @@
"useEntertainmentAPI": {
"type": "boolean",
"title": "edt_dev_spec_useEntertainmentAPI_title",
"default": false,
"default": true,
"propertyOrder": 4
},
"transitiontime": {