From 09240dcb30955b017e163a3e8f4bf61ec0c9506b Mon Sep 17 00:00:00 2001 From: user01010111 Date: Thu, 13 Aug 2026 15:28:16 +1200 Subject: [PATCH] Prefer complete HID descriptor for EcoFlow devices Signed-off-by: user01010111 --- NEWS.adoc | 5 +++++ drivers/libusb0.c | 8 +++++++- drivers/libusb1.c | 8 +++++++- 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/NEWS.adoc b/NEWS.adoc index 16e339db4a..b245e3d1e9 100644 --- a/NEWS.adoc +++ b/NEWS.adoc @@ -49,6 +49,11 @@ https://github.com/networkupstools/nut/milestone/13 descriptor lengths, which could cause a segmentation fault (regression added in NUT v2.8.5 release). [PR #3550] + - USB drivers now prefer the longer of conflicting HID report descriptor + lengths for EcoFlow devices using USB ID `3746:ffff`. This makes the + complete descriptor available on affected River 3 Plus firmware while + retaining the shorter length as a fallback. + - Windows serial compatibility: fixed timeout handling to return data already received as a successful short read, while safely canceling and completing pending overlapped I/O before reusing its state. diff --git a/drivers/libusb0.c b/drivers/libusb0.c index 8471136efb..ceb6d624a0 100644 --- a/drivers/libusb0.c +++ b/drivers/libusb0.c @@ -48,7 +48,7 @@ #include "strcasestr-static.h" #define USB_DRIVER_NAME "USB communication driver (libusb 0.1)" -#define USB_DRIVER_VERSION "0.53" +#define USB_DRIVER_VERSION "0.54" /* driver description structure */ upsdrv_info_t comm_upsdrv_info = { @@ -631,6 +631,12 @@ static int nut_libusb_open(usb_dev_handle **udevp, rdlens[0] = rdlen1; rdlens[1] = rdlen2; } + else if ((curDevice->VendorID == 0x3746) && (curDevice->ProductID == 0xffff) + && (rdlen1 != rdlen2)) { + upsdebugx(1, "EcoFlow device. Trying longer report descriptor first"); + rdlens[0] = rdlen1 > rdlen2 ? rdlen1 : rdlen2; + rdlens[1] = rdlen1 > rdlen2 ? rdlen2 : rdlen1; + } else { rdlens[0] = rdlen2 >= 0 ? rdlen2 : rdlen1; rdlens[1] = rdlen2 >= 0 ? rdlen1 : rdlen2; diff --git a/drivers/libusb1.c b/drivers/libusb1.c index e9f6c855c4..d250825ea9 100644 --- a/drivers/libusb1.c +++ b/drivers/libusb1.c @@ -47,7 +47,7 @@ #endif #define USB_DRIVER_NAME "USB communication driver (libusb 1.0)" -#define USB_DRIVER_VERSION "0.54" +#define USB_DRIVER_VERSION "0.55" /* driver description structure */ upsdrv_info_t comm_upsdrv_info = { @@ -788,6 +788,12 @@ static int nut_libusb_open(libusb_device_handle **udevp, rdlens[0] = rdlen1; rdlens[1] = rdlen2; } + else if ((curDevice->VendorID == 0x3746) && (curDevice->ProductID == 0xffff) + && (rdlen1 != rdlen2)) { + upsdebugx(1, "EcoFlow device. Trying longer report descriptor first"); + rdlens[0] = rdlen1 > rdlen2 ? rdlen1 : rdlen2; + rdlens[1] = rdlen1 > rdlen2 ? rdlen2 : rdlen1; + } else { rdlens[0] = rdlen2 >= 0 ? rdlen2 : rdlen1; rdlens[1] = rdlen2 >= 0 ? rdlen1 : rdlen2;