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

CyberPower UT series do not seem to pass correct 'OB' flag, try to accommodate this with new "onlinedischarge" config flag #811

Merged
merged 25 commits into from
Mar 29, 2022
Merged
Changes from 6 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
5bf8cfa
initial patch that works
kgizdov Aug 11, 2020
a56b0fd
Merge branch 'master' into cyberpower-ut-series
jimklimov Oct 9, 2020
1c3d284
Merge branch 'master' into cyberpower-ut-series
jimklimov Oct 9, 2020
7c9a0f6
fix indentation style
kgizdov Oct 9, 2020
39a0f19
lay the groundwork for CyberPower UT cputquirk
kgizdov Oct 9, 2020
189b20a
remove leftover lines
kgizdov Oct 9, 2020
1a80443
more compact logic
kgizdov Oct 9, 2020
7601fb5
address some comments
kgizdov Oct 11, 2020
4399161
Merge branch 'master' into cyberpower-ut-series
jimklimov Nov 7, 2020
1c7f9fe
Merge branch 'master' into cyberpower-ut-series
jimklimov Nov 29, 2020
e1f3ad6
Merge branch 'master' into cyberpower-ut-series
jimklimov Sep 13, 2021
6e42352
Merge branch 'master' into cyberpower-ut-series
jimklimov Sep 20, 2021
a6cebcc
Merge branch 'master' into cyberpower-ut-series
jimklimov Sep 21, 2021
4373e8f
Merge branch 'master' into cyberpower-ut-series
jimklimov Jan 22, 2022
d02716b
Merge remote-tracking branch 'upstream/master' into cyberpower-ut-series
jimklimov Mar 28, 2022
0ae8f0f
drivers/usbhid-ups.c: fix format string for "onlinedischarge" help
jimklimov Mar 28, 2022
4bdccb1
drivers/usbhid-ups.c: fix var usage for upsname
jimklimov Mar 28, 2022
1ea3a3b
docs/man/usbhid-ups.txt: document onlinedischarge
jimklimov Mar 28, 2022
daee74b
NEWS: added usbhid-ups onlinedischarge for NUT v2.7.5
jimklimov Mar 28, 2022
b6cab69
NEWS: clarify that NUT 2.8.0 is new name for old planned NUT 2.7.5
jimklimov Mar 28, 2022
5e707e4
docs/nut.dict: add onlinedischarge
jimklimov Mar 28, 2022
ba9220c
drivers/usbhid-ups.c: drop DEFAULT_ONLINEDISCHARGE to match "VAR_FLAG…
jimklimov Mar 28, 2022
50775cf
drivers/usbhid-ups.c: set the onlinedischarge variable based on flag …
jimklimov Mar 28, 2022
77b9b8e
ci_build.sh: do not make noise about non-ubiquitous options to "uname…
jimklimov Mar 28, 2022
7efa550
ci_build.sh: recognize more "*bsd" CI_OS_NAME values
jimklimov Mar 28, 2022
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
28 changes: 26 additions & 2 deletions drivers/usbhid-ups.c
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,13 @@ bool_t use_interrupt_pipe = FALSE;
#endif
static time_t lastpoll; /* Timestamp the last polling */
hid_dev_handle_t udev;
/**
* CyberPower UT series sometime need a bit of help deciding their online status.
* This quirk is to enable the special handling of OL & DISCHRG at the same time
* as being OB (on battery power/no mains power)
*/
#define DEFAULT_CPUTQUIRK 0
static int cputquirk = DEFAULT_CPUTQUIRK;

/* support functions */
static hid_info_t *find_nut_info(const char *varname);
Expand Down Expand Up @@ -705,6 +712,9 @@ void upsdrv_makevartable(void)

addvar(VAR_FLAG, "pollonly", "Don't use interrupt pipe, only use polling");

snprintf(temp, sizeof(temp), "Enable CyberPower UT series quirk (default=%s)", DEFAULT_CPUTQUIRK);
addvar(VAR_FLAG, "cputquirk", temp);

#ifndef SHUT_MODE
/* allow -x vendor=X, vendorid=X, product=X, productid=X, serial=X */
nut_usb_addvars();
Expand Down Expand Up @@ -1422,8 +1432,22 @@ static void ups_status_set(void)
dstate_delinfo("input.transfer.reason");
}

if (ups_status & STATUS(ONLINE)) {
status_set("OL"); /* on line */

if ((ups_status & STATUS(ONLINE)) && (ups_status & STATUS(DISCHRG))) {
/* warning or CyberPower UT quirk */
if (cputquirk) {
status_set("OB");
} else if ((ups_status & STATUS(CAL))) {
status_set("OL");
} else {
upslogx(LOG_WARNING, "%s: seems that UPS [%s] is OL+DISCHRG state now. "
"Is it calibrating or do you perhaps want to set 'cputquirk' option? "
"Some CyberPower UT series emit OL+DISCHRG when offline.",
__func__, ups->upsname)
status_set("OL");
}
} else if ((ups_status & STATUS(ONLINE))) {
status_set("OL");
} else {
status_set("OB"); /* on battery */
}
Expand Down