Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions NEWS.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,8 @@ https://github.com/networkupstools/nut/milestone/12
ignore any useful reports, and that we successfully use reasonably many
of the existing mappings. Suggest how user can help improve the driver
if too few data points were seen. [#3082, #3095]
* Default to `usb_hid_rep_index=1` for Liebert PSI5 and PowerSure PST
devices with ID `10af:0002`. [#3345, #1028, #1252 etc.]
* `cps-hid` updated with Replace Battery information. [PR #3268]
* `openups-hid` had `nobattery` definition inverted, causing alarms -- now
fixed to use the same mapping helper as other subdrivers. [issue #3246]
Expand Down
24 changes: 18 additions & 6 deletions drivers/arduino-hid.c
Original file line number Diff line number Diff line change
Expand Up @@ -155,24 +155,36 @@ static int arduino_claim(HIDDevice_t *hd)
case POSSIBLY_SUPPORTED:
/* by default, reject, unless the productid option is given */
if (getval("productid")) {
if (!getval("usb_hid_ep_in"))
if (!getval("usb_hid_ep_in")) {
upsdebugx(1, "%s: defaulting usb_hid_ep_in=4 for this model", __func__);
usb->hid_ep_in=4;
if (!getval("usb_hid_ep_out"))
}
if (!getval("usb_hid_ep_out")) {
upsdebugx(1, "%s: defaulting usb_hid_ep_out=5 for this model", __func__);
usb->hid_ep_out=5;
if (!getval("usb_hid_rep_index"))
}
if (!getval("usb_hid_rep_index")) {
upsdebugx(1, "%s: defaulting usb_hid_rep_index=2 for this model", __func__);
usb->hid_rep_index = 2;
}
return 1;
}
possibly_supported("Arduino", hd);
return 0;

case SUPPORTED:
if (!getval("usb_hid_ep_in"))
if (!getval("usb_hid_ep_in")) {
upsdebugx(1, "%s: defaulting usb_hid_ep_in=4 for this model", __func__);
usb->hid_ep_in=4;
if (!getval("usb_hid_ep_out"))
}
if (!getval("usb_hid_ep_out")) {
upsdebugx(1, "%s: defaulting usb_hid_ep_out=5 for this model", __func__);
usb->hid_ep_out=5;
if (!getval("usb_hid_rep_index"))
}
if (!getval("usb_hid_rep_index")) {
upsdebugx(1, "%s: defaulting usb_hid_rep_index=2 for this model", __func__);
usb->hid_rep_index = 2;
}
return 1;

case NOT_SUPPORTED:
Expand Down
28 changes: 26 additions & 2 deletions drivers/belkin-hid.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* 2005 Peter Selinger <selinger@users.sourceforge.net>
* 2011, 2014 Charles Lepple <clepple+nut@gmail.com>
* 2024 James R. Parks <jrjparks@zathera.com>
* 2024 Jim Klimov <jimklimov+nut@gmail.com>
* 2024 - 2026 Jim Klimov <jimklimov+nut@gmail.com>
*
* Sponsored by MGE UPS SYSTEMS <http://www.mgeups.com>
*
Expand All @@ -32,7 +32,7 @@
#include "usb-common.h"
#include "nut_float.h" /* For fabs() */

#define BELKIN_HID_VERSION "Belkin/Liebert HID 0.22"
#define BELKIN_HID_VERSION "Belkin/Liebert HID 0.23"

/* Belkin */
#define BELKIN_VENDORID 0x050d
Expand Down Expand Up @@ -83,6 +83,8 @@ static usb_device_id_t belkin_usb_device_table[] = {
{ 0, 0, NULL }
};

static usb_communication_subdriver_t *usb = &usb_subdriver;

static const char *liebert_online_fun(double value);
static const char *liebert_discharging_fun(double value);
static const char *liebert_charging_fun(double value);
Expand Down Expand Up @@ -661,6 +663,19 @@ static int belkin_claim(HIDDevice_t *hd)
case LIEBERT_VENDORID:
/* by default, reject, unless the productid option is given */
if (getval("productid")) {
/* Liebert PSI5 / PowerSure PST (10af:0002): the HID Power Device
* Class descriptor is on interface 1. Interface 0 exposes only a
* 27-byte vendor-specific report that contains no usable UPS data,
* which caused NUT to incorrectly report the UPS as on battery
* (OB) even when AC power was present, and serve no useful data.
* See GitHub issues #1252 and #3340, PR #3345. */
if (hd->ProductID == 0x0002
&& !getval("usb_hid_rep_index")
) {
upsdebugx(1, "%s: defaulting usb_hid_rep_index=1 for this model", __func__);
usb->hid_rep_index = 1;
}

return 1;
}
possibly_supported("Liebert", hd);
Expand All @@ -672,6 +687,15 @@ static int belkin_claim(HIDDevice_t *hd)
return 0;

case SUPPORTED:
/* See comment above */
if (hd->VendorID == LIEBERT_VENDORID
&& hd->ProductID == 0x0002
&& !getval("usb_hid_rep_index")
) {
upsdebugx(1, "%s: defaulting usb_hid_rep_index=1 for this model", __func__);
usb->hid_rep_index = 1;
}

return 1;

case NOT_SUPPORTED:
Expand Down
10 changes: 7 additions & 3 deletions drivers/powervar-hid.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
#include "main.h" /* for getval() */
#include "usb-common.h"

#define POWERVAR_HID_VERSION "Powervar HID 0.20"
#define POWERVAR_HID_VERSION "Powervar HID 0.21"
/* FIXME: experimental flag to be put in upsdrv_info */

/* Powervar */
Expand Down Expand Up @@ -119,16 +119,20 @@ static int powervar_claim(HIDDevice_t *hd)
case POSSIBLY_SUPPORTED:
/* by default, reject, unless the productid option is given */
if (getval("productid")) {
if (!getval("usb_hid_rep_index"))
if (!getval("usb_hid_rep_index")) {
upsdebugx(1, "%s: defaulting usb_hid_rep_index=1 for this model", __func__);
usb->hid_rep_index = 1;
}
return 1;
}
possibly_supported("Powervar", hd);
return 0;

case SUPPORTED:
if (!getval("usb_hid_rep_index"))
if (!getval("usb_hid_rep_index")) {
upsdebugx(1, "%s: defaulting usb_hid_rep_index=1 for this model", __func__);
usb->hid_rep_index = 1;
}
return 1;

case NOT_SUPPORTED:
Expand Down
18 changes: 17 additions & 1 deletion tests/getexponenttest-belkin-hid.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* https://github.com/networkupstools/nut/issues/2370
*
* Copyright (C)
* 2024 Jim Klimov <jimklimov+nut@gmail.com>
* 2024-2026 Jim Klimov <jimklimov+nut@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand All @@ -34,6 +34,22 @@
#include <string.h>
#include "common.h"

/* Dummy here */
#include "nut_libusb.h"
#if (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_PUSH_POP_BESIDEFUNC) && ( (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_MISSING_FIELD_INITIALIZERS_BESIDEFUNC) || (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_MISSING_BRACES_BESIDEFUNC) )
#pragma GCC diagnostic push
#endif
#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_MISSING_FIELD_INITIALIZERS_BESIDEFUNC
#pragma GCC diagnostic ignored "-Wmissing-field-initializers"
#endif
#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_MISSING_BRACES_BESIDEFUNC
#pragma GCC diagnostic ignored "-Wmissing-braces"
#endif
usb_communication_subdriver_t usb_subdriver = {0};
#if (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_PUSH_POP_BESIDEFUNC) && ( (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_MISSING_FIELD_INITIALIZERS_BESIDEFUNC) || (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_MISSING_BRACES_BESIDEFUNC) )
#pragma GCC diagnostic pop
#endif

#include "belkin-hid.c"
/* from drivers/belkin-hid.c we test:
extern double liebert_config_voltage_mult, liebert_line_voltage_mult;
Expand Down
Loading