Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Address spurious LB+RB log flood on APC BXnnnnMI devices #2565

Merged
merged 18 commits into from
Aug 12, 2024
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
5a52815
drivers/usbhid-ups.c: avoid "\n" starting an upsdebugx() message
jimklimov Jul 29, 2024
67a3bc1
drivers/dstate.{c,h}, docs/new-drivers.txt, NEWS.adoc: introduce stat…
jimklimov Jul 29, 2024
1f5b686
drivers/usbhid-ups.c: track start and end timestamps of calibration […
jimklimov Jul 29, 2024
d15ab31
drivers/usbhid-ups.c, docs/man/usbhid-ups.txt: introduce lbrb_log_del…
jimklimov Jul 29, 2024
82abc3d
Merge branch 'master' into issue-2347
jimklimov Jul 29, 2024
5f7630c
Merge branch 'master' into issue-2347
jimklimov Aug 1, 2024
fd39200
Merge branch 'master' into issue-2347
jimklimov Aug 5, 2024
6401b70
Merge branch 'master' into issue-2347
jimklimov Aug 5, 2024
a27d0ab
Merge remote-tracking branch 'upstream/master' into issue-2347
jimklimov Aug 6, 2024
21917d7
drivers/usbhid-ups.c: when defaulting lbrb_log_delay_sec, suggest als…
jimklimov Aug 6, 2024
420ce04
Merge remote-tracking branch 'upstream/master' into issue-2347
jimklimov Aug 11, 2024
af181be
NEWS.adoc, UPGRADING.adoc, docs/nut.dict: summarize the mitigation fo…
jimklimov Aug 11, 2024
2986cc2
drivers/usbhid-ups.c: clarify suggested settings for LB+RB log flood …
jimklimov Aug 11, 2024
61574c2
data/driver.list.in: update about "Back-UPS BX****MI Series (may need…
jimklimov Aug 11, 2024
120cd2a
drivers/usbhid-ups.c: upsdrv_initups(): cache testvar() outcome as ex…
jimklimov Aug 12, 2024
1476ad7
ci_build.sh: fix shell syntax that could confuse CANBUILD_LIBGD_CGI d…
jimklimov Aug 12, 2024
015e238
ci_build.sh: actually honour CANBUILD_LIBGD_CGI=no
jimklimov Aug 12, 2024
b2df27e
m4/nut_check_libgd.m4: AX_RUN_OR_LINK_IFELSE() to check that we can a…
jimklimov Aug 12, 2024
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
6 changes: 6 additions & 0 deletions NEWS.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,9 @@ https://github.com/networkupstools/nut/milestone/11
- usbhid-ups updates:
* Support of the `onlinedischarge_log_throttle_hovercharge` in the NUT
v2.8.2 release was found to be incomplete. [#2423, follow-up to #2215]
* Added support for `lbrb_log_delay_sec` setting to delay propagation of
`LB` or `LB+RB` state (buggy with APC BXnnnnMI devices circa 2023-2024).
[#2347]
* General suggestion from `possibly_supported()` message method for devices
with VendorID=`0x06da` (Phoenixtec), seen in some models supported by
MGE HID or Liebert HID, updated to suggest trying `nutdrv_qx`. [#334]
Expand Down Expand Up @@ -217,6 +220,9 @@ during a NUT build.
and values (or macros) in the NUT codebase. [issue #1176, issue #31]
* custom `distcheck-something` targets did not inherit `DISTCHECK_FLAGS`
properly. [#2541]
* added `status_get()` in NUT driver state API, to check if a status
token string had been set recently, and to avoid duplicate settings.
[PR #2565]
* local socket/pipe protocol introduced a `LOGOUT` command for cleaner
disconnection handling. [#2572]

Expand Down
14 changes: 14 additions & 0 deletions docs/man/usbhid-ups.txt
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,20 @@ not forcing it to be fully charged all the time. As long as the current value
of `battery.charge` remains at or above this threshold percentage (default 100),
the `OL+DISCHRG` message logging is not triggered by variations of the charge.

*lbrb_log_delay_sec*='num'::
Set to delay status-setting (and log messages) about device entering `LB` or
`LB+RB` state.
+
Some APC BXnnnnMI device models or firmware versions (reportedly 2023-2024)
frequently report low battery, replace battery, and all ok within a couple
of seconds, sometimes but not always preceded by OL+DISCHRG (presumably
calibration). This setting lets the driver ignore short-lived states and
only pay attention if they persist longer than this setting (and the device
power state is `OL`).

*lbrb_log_delay_without_calibrating*::
Set to apply `lbrb_log_delay_sec` even if device is not calibrating.

*disable_fix_report_desc*::
Set to disable fix-ups for broken USB encoding, etc. which we apply by default
on certain models (vendors/products) which were reported as not following the
Expand Down
6 changes: 5 additions & 1 deletion docs/new-drivers.txt
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,11 @@ UPS status flags like on line (OL) and on battery (OB) live in
ups.status. Don't manipulate this by hand. There are functions which
will do this for you.

status_init() -- before doing anything else
status_init() -- before doing anything else (clear internal buffers,
etc.)

status_get(val) -- optionally check if a status word had been set
since the most-recent status_init()

status_set(val) -- add a status word (OB, OL, etc)

Expand Down
4 changes: 3 additions & 1 deletion docs/nut.dict
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
personal_ws-1.1 en 3203 utf-8
personal_ws-1.1 en 3205 utf-8
AAC
AAS
ABI
Expand Down Expand Up @@ -100,6 +100,7 @@ BTS
BTV
BUFRD
BUZ
BXnnnnMI
BYP
BZ
BZOFF
Expand Down Expand Up @@ -2148,6 +2149,7 @@ labcd
lan
langid
lasaine
lbrb
ld
ldd
le
Expand Down
35 changes: 35 additions & 0 deletions drivers/dstate.c
Original file line number Diff line number Diff line change
Expand Up @@ -1617,6 +1617,36 @@ void status_init(void)
memset(status_buf, 0, sizeof(status_buf));
}

/* check if a status element has been set, return 0 if not, 1 if yes
* (considering a whole-word token in temporary status_buf) */
int status_get(const char *buf)
{
char *s = NULL;
size_t offset = 0, buflen = 0;

if (!buf || !*buf || !*status_buf)
return 0;

s = strstr(status_buf, buf);
buflen = strlen(buf);

/* not found */
if (!s)
return 0;

offset = status_buf - s;
if (offset == 0 || status_buf[offset - 1] == ' ') {
/* We have hit the start of token */
if (s[buflen] == '\0' || s[buflen] == ' ') {
/* And we have hit the end of token */
return 1;
}
}

/* buf was a substring of some other token */
return 0;
}

/* add a status element */
void status_set(const char *buf)
{
Expand All @@ -1625,6 +1655,11 @@ void status_set(const char *buf)
return;
}

if (status_get(buf)) {
upsdebugx(2, "%s: status was already set: %s", __func__, buf);
return;
}

/* separate with a space if multiple elements are present */
if (strlen(status_buf) > 0) {
snprintfcat(status_buf, sizeof(status_buf), " %s", buf);
Expand Down
4 changes: 4 additions & 0 deletions drivers/dstate.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,10 @@ int dstate_is_stale(void);
/* clean out the temp space for a new pass */
void status_init(void);

/* check if a status element has been set, return 0 if not, 1 if yes
* (considering a whole-word token in temporary status_buf) */
int status_get(const char *buf);

/* add a status element */
void status_set(const char *buf);

Expand Down
Loading
Loading